// Returns all the public fields of the current System.Type. public __FieldInfo[] GetFields() { var f = this.InternalTypeDescription.getDeclaredFields(); var a = new java.util.ArrayList <__FieldInfo>(); for (int i = 0; i < f.Length; i++) { var fi = f[i]; // via https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2012/20120-1/20120817-wordpress var isPublic = Modifier.isPublic(fi.getModifiers()); var isFinal = Modifier.isFinal(fi.getModifiers()); if (isPublic || isFinal) { a.add( new __FieldInfo { InternalField = fi } ); } } // otherwise, a new array of the same runtime type is allocated return(a.toArray(new __FieldInfo[0])); }
// // GetNestedTypes // public override Type[] GetNestedTypes(BindingFlags bindingAttr) { bool takePublic = (bindingAttr & BindingFlags.Public) != 0; bool takeNonPublic = (bindingAttr & BindingFlags.NonPublic) != 0; if (takePublic || takeNonPublic) { var innerClasses = JavaClass.getDeclaredClasses(); if (innerClasses.Length > 0) { var list = new java.util.ArrayList(); for (int i = 0; i < innerClasses.Length; i++) { var innerCls = innerClasses[i]; var isPublic = (0 != (innerCls.getModifiers() & java.lang.reflect.Modifier.PUBLIC)); if (takePublic == isPublic || takeNonPublic != isPublic) { var innerType = GetType(innerCls); var generic = ((RuntimeType)innerType).Generic; list.add(generic != null ? generic.PrimaryType : innerType); } } return((Type[])list.toArray(system.RuntimeType.EmptyTypeArray)); } } return(system.RuntimeType.EmptyTypeArray); }
/** * Removes a collection from the those being decorated in this composite. * * @param coll collection to be removed */ public virtual void removeComposited(java.util.Collection <Object> coll) { java.util.ArrayList <Object> list = new java.util.ArrayList <Object>(this.all.Length); list.addAll(java.util.Arrays <Object> .asList <Object>(this.all)); list.remove(coll); this.all = (java.util.Collection <Object>[])list.toArray(new java.util.Collection <Object> [list.size()]); }
/** * Gets all user (public) listeners in one array. * * @param emptyArray - empty array, it's for deriving particular listeners class. * @return array of all user listeners. */ public AT[] getUserListeners <AT>(AT[] emptyArray) { lock (this) { return(userList != null ? userList.toArray(emptyArray) : emptyArray); } }
public static string[] SplitStringByChar(string e, char p) { if (null == e) { throw new InvalidOperationException(); } var a = new java.util.ArrayList(); int i = -1; bool b = true; while (b) { int j = e.IndexOf(p, i + 1); if (j == -1) { a.add(e.Substring(i + 1)); b = false; } else { a.add(e.Substring(i + 1, j - i - 1)); i = j; } } return((string[])a.toArray(new string[a.size()])); }
public override Object[] toArray <Object>(Object[] arr) { // special implementation to handle disappearing values java.util.List <Object> list = new java.util.ArrayList <Object>(parent.size()); for (java.util.Iterator <Object> it = (java.util.Iterator <Object>)iterator(); it.hasNext();) { list.add(it.next()); } return(list.toArray(arr)); }
public override T[] toArray <T>(T[] contents) { java.util.Collection <K> coll = new java.util.ArrayList <K>(this.size()); { for (java.util.Iterator <K> iter = this.iterator(); iter.hasNext();) { coll.add(iter.next()); } } return(coll.toArray <T>(contents)); }
private object[] collectActivityLifecycleCallbacks() { object[] callbacks = null; lock (mActivityLifecycleCallbacks) { if (mActivityLifecycleCallbacks.size() > 0) { callbacks = mActivityLifecycleCallbacks.toArray(); } } return(callbacks); }
private object[] collectComponentCallbacks() { object[] callbacks = null; lock (mComponentCallbacks) { if (mComponentCallbacks.size() > 0) { callbacks = mComponentCallbacks.toArray(); } } return(callbacks); }
public override Object[] toArray <Object>(Object[] arr) { // special implementation to handle disappearing entries java.util.ArrayList <Object> list = new java.util.ArrayList <Object>(); java.util.Iterator <Object> it = (java.util.Iterator <Object>) this.iterator(); while (it.hasNext()) { java.util.MapNS.Entry <Object, Object> e = (java.util.MapNS.Entry <Object, Object>)it.next(); //? right??? object o = new DefaultMapEntry(e.getKey(), e.getValue()); Object o2 = (Object)o; list.add(o2); } return(list.toArray(arr)); }
/** * Retrieves extra fields. * @param includeUnparseable whether to also return unparseable * extra fields as {@link UnparseableExtraFieldData} if such data * exists. * @return an array of the extra fields * * @since Apache Commons Compress 1.1 */ public ZipExtraField[] getExtraFields(bool includeUnparseable) { if (extraFields == null) { return(!includeUnparseable || unparseableExtra == null ? new ZipExtraField[0] : new ZipExtraField[] { unparseableExtra }); } java.util.List <ZipExtraField> result = new java.util.ArrayList <ZipExtraField>(extraFields.values()); if (includeUnparseable && unparseableExtra != null) { result.add(unparseableExtra); } return((ZipExtraField[])result.toArray(new ZipExtraField[0])); }
// // GetFields (called by system.RuntimeType.GetFields() // public static FieldInfo[] GetFields(BindingFlags bindingAttr, RuntimeType initialType) { var list = new java.util.ArrayList(); BindingFlagsIterator.Run(bindingAttr & ~BindingFlags.GetField, initialType, MemberTypes.Field, (javaAccessibleObject) => { var javaField = (java.lang.reflect.Field)javaAccessibleObject; javaField.setAccessible(true); list.add(new RuntimeFieldInfo(javaField, initialType)); return(true); }); return((RuntimeFieldInfo[])list.toArray(new RuntimeFieldInfo[0])); }
/// <summary>Gets a list of the files in the directory represented by this file.</summary> /// <remarks> /// Gets a list of the files in the directory represented by this file. This /// list is then filtered through a FilenameFilter and the names of files /// with matching names are returned as an array of strings. Returns /// <code>null</code> /// if this file is not a directory. If /// <code>filter</code> /// is /// <code>null</code> /// then all filenames match. /// <p> /// The entries /// <code>.</code> /// and /// <code>..</code> /// representing the current and parent /// directories are not returned as part of the list. /// </remarks> /// <param name="filter"> /// the filter to match names against, may be /// <code>null</code> /// . /// </param> /// <returns> /// an array of files or /// <code>null</code> /// . /// </returns> public string[] list(java.io.FilenameFilter filter) { string[] filenames = list(); if (filter == null || filenames == null) { return(filenames); } java.util.List <string> result = new java.util.ArrayList <string>(filenames.Length); foreach (string filename in filenames) { if (filter.accept(this, filename)) { result.add(filename); } } return(result.toArray(new string[result.size()])); }
/// <summary>Gets a list of the files in the directory represented by this file.</summary> /// <remarks> /// Gets a list of the files in the directory represented by this file. This /// list is then filtered through a FileFilter and matching files are /// returned as an array of files. Returns /// <code>null</code> /// if this file is not a /// directory. If /// <code>filter</code> /// is /// <code>null</code> /// then all files match. /// <p> /// The entries /// <code>.</code> /// and /// <code>..</code> /// representing the current and parent /// directories are not returned as part of the list. /// </remarks> /// <param name="filter"> /// the filter to match names against, may be /// <code>null</code> /// . /// </param> /// <returns> /// an array of files or /// <code>null</code> /// . /// </returns> public java.io.File[] listFiles(java.io.FileFilter filter) { java.io.File[] files = listFiles(); if (filter == null || files == null) { return(files); } java.util.List <java.io.File> result = new java.util.ArrayList <java.io.File>(files .Length); foreach (java.io.File file in files) { if (filter.accept(file)) { result.add(file); } } return(result.toArray(new java.io.File[result.size()])); }
public static IEnumerable <POS> Extract(string text, ref NLPCount count) { var segment = new List <POS>(); if (string.IsNullOrEmpty(text)) { return(segment); } var document = new Annotation(text); pipeline.annotate(document); var sentencesAnnotation = new SentencesAnnotation(); var tokensAnnotation = new TokensAnnotation(); var textAnnotation = new TextAnnotation(); var partOfSpeechAnnotation = new PartOfSpeechAnnotation(); java.util.ArrayList sentenceArrayList = (java.util.ArrayList)document.get(sentencesAnnotation.getClass()); var sentences = sentenceArrayList.toArray(); count.SentenceCount += sentences.Length; for (int i = 0; i < sentences.Length; i++) { var sentence = (edu.stanford.nlp.util.CoreMap)sentences[i]; var tokenArray = ((java.util.ArrayList)sentence.get(tokensAnnotation.getClass())); var tokens = tokenArray.toArray(); count.WordsPhraseCount += tokens.Length; for (int j = 0; j < tokens.Length; j++) { var coreLabel = (edu.stanford.nlp.ling.CoreLabel)tokens[j]; string posTag = (string)coreLabel.get(partOfSpeechAnnotation.getClass()); string word = (string)coreLabel.get(textAnnotation.getClass()); if (word.Length <= 100) { segment.Add(new POS() { Text = word, PosTag = posTag }); } } } return(segment.ToList()); }
public AppSecurityPermissions(android.content.Context context, android.content.pm.PackageParser .Package pkg) { mContext = context; mPm = mContext.getPackageManager(); mPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>(); java.util.Set <android.content.pm.PermissionInfo> permSet = new java.util.HashSet < android.content.pm.PermissionInfo>(); if (pkg == null) { return; } // Get requested permissions if (pkg.requestedPermissions != null) { java.util.ArrayList <string> strList = pkg.requestedPermissions; int size = strList.size(); if (size > 0) { extractPerms(strList.toArray(new string[size]), permSet); } } // Get permissions related to shared user if any if (pkg.mSharedUserId != null) { int sharedUid; try { sharedUid = mPm.getUidForSharedUser(pkg.mSharedUserId); getAllUsedPermissions(sharedUid, permSet); } catch (android.content.pm.PackageManager.NameNotFoundException) { android.util.Log.w(TAG, "Could'nt retrieve shared user id for:" + pkg.packageName ); } } // Retrieve list of permissions foreach (android.content.pm.PermissionInfo tmpInfo in Sharpen.IterableProxy.Create (permSet)) { mPermsList.add(tmpInfo); } }
public PropertyChangeListener[] getPropertyChangeListeners() { lock (this){} java.util.ArrayList <PropertyChangeListener> result = new java.util.ArrayList <PropertyChangeListener>( globalListeners); java.util.Iterator <String> it = children.keySet().iterator(); while (it.hasNext()) { String propertyName = it.next(); PropertyChangeSupport namedListener = children .get(propertyName); PropertyChangeListener[] listeners = namedListener .getPropertyChangeListeners(); for (int i = 0; i < listeners.Length; i++) { result.add(new PropertyChangeListenerProxy(propertyName, listeners[i])); } } return(result.toArray(new PropertyChangeListener[0])); }
private static string[] InternalSplit(java.lang.String str, object separator, int count, System.StringSplitOptions options) { if (count < 0) { throw new System.ArgumentOutOfRangeException(); } bool omit = (options == System.StringSplitOptions.None) ? false : (options == System.StringSplitOptions.RemoveEmptyEntries) ? true : throw new System.ArgumentException(); var emptyArray = new string[0]; if (count == 0) { return(emptyArray); } int length = str.length(); var list = new java.util.ArrayList(); if (separator is char[] charSeparator) { SplitCharacter(str, length, list, count, omit, charSeparator); } else if (separator is java.lang.String[] strSeparator) { SplitString(str, length, list, count, omit, strSeparator); } else // assuming separator is null { SplitWhiteSpace(str, length, list, count, omit); } return((string[])list.toArray(emptyArray)); }
/** * Add these Collections to the list of collections in this composite * * @param comps Collections to be appended to the composite */ public virtual void addComposited(java.util.Collection <Object>[] comps) { java.util.ArrayList <Object> list = new java.util.ArrayList <Object>(java.util.Arrays <Object> .asList <Object>(this.all)); list.addAll(java.util.Arrays <Object> .asList <Object>(comps)); all = (java.util.Collection <Object>[])list.toArray(new java.util.Collection <Object> [list.size()]); }
private void GetQuotes() { pageRandom = null; loading_panel.Visibility = Visibility.Visible; progressRing.IsActive = true; DoEvents(); list_quotes.Clear(); Thread threadGetPage = new Thread(GetPage); threadGetPage.Start(); while (pageRandom == null) { DoEvents(); } loading_panel.Visibility = Visibility.Hidden; progressRing.IsActive = false; HtmlDivision div_actions; HtmlDivision div_text; java.util.List divList = new java.util.ArrayList(); divList = pageRandom.getByXPath("//div[@class='quote']"); foreach (HtmlDivision div in divList.toArray()) { Quote quote = new Quote(); div_actions = (HtmlDivision)div.getFirstByXPath("./div[@class='actions']"); HtmlSpan rating = (HtmlSpan)div_actions.getFirstByXPath("./span[@class='rating-o']"); HtmlSpan date = (HtmlSpan)div_actions.getFirstByXPath("./span[@class='date']"); HtmlAnchor id = (HtmlAnchor)div_actions.getFirstByXPath("./a[@class='id']"); quote.rating = rating.asText(); quote.date_added = date.asText(); quote.ID = id.asText().Replace("#", ""); div_text = (HtmlDivision)div.getFirstByXPath("./div[@class='text']"); quote.quote_text = div_text.asText(); list_quotes.Add(quote); } DoEvents(); if (list_quotes.Count < 1) { Log("Not enough mana!"); lblCounter.Content = ""; } else { btnPrev.Visibility = Visibility.Visible; btnShare.Visibility = Visibility.Visible; btnNext.Content = "NEXT"; counter = 0; ShowQuote(counter); } try { lblCounter.Visibility = Visibility.Visible; lblData.Visibility = Visibility.Visible; lblRating.Visibility = Visibility.Visible; lblLink.Visibility = Visibility.Visible; tb_content.Visibility = Visibility.Visible; } catch { } }
public static string[] SplitStringByChar(string e, char p) { if (null == e) throw new InvalidOperationException(); var a = new java.util.ArrayList(); int i = -1; bool b = true; while (b) { int j = e.IndexOf(p, i + 1); if (j == -1) { a.add(e.Substring(i + 1)); b = false; } else { a.add(e.Substring(i + 1, j - i - 1)); i = j; } } return (string[])a.toArray(new string[a.size()]); }
/** * Read informations of a rpm file out of an input stream. * * @param rpmInputStream The input stream representing the rpm file * @throws IOException if an error occurs during read of the rpm file */ private void readFromStream(java.io.InputStream rpmInputStream) {//throws IOException { ByteCountInputStream allCountInputStream = new ByteCountInputStream( rpmInputStream); java.io.InputStream inputStream = new java.io.DataInputStream(allCountInputStream); lead = new RPMLead((java.io.DataInputStream)inputStream); signature = new RPMSignature((java.io.DataInputStream)inputStream, store); if (logger.isLoggable(java.util.logging.Level.FINER)) { logger.finer("Signature Size: " + signature.getSize()); } header = new RPMHeader((java.io.DataInputStream)inputStream, store); if (logger.isLoggable(java.util.logging.Level.FINER)) { logger.finer("Header Size: " + header.getSize()); } DataTypeIf payloadTag = getTag("PAYLOADFORMAT"); String payloadFormat = payloadTag != null?payloadTag.toString() : "cpio"; DataTypeIf payloadCompressionTag = getTag("PAYLOADCOMPRESSOR"); String payloadCompressor = payloadCompressionTag != null?payloadCompressionTag .toString() : "gzip"; if (payloadFormat.equals("cpio")) { if (logger.isLoggable(java.util.logging.Level.FINER)) { logger.finer("PAYLOADCOMPRESSOR: " + payloadCompressor); } if (payloadCompressor.equals("gzip")) { inputStream = new GzipCompressorInputStream(allCountInputStream); } else if (payloadCompressor.equals("bzip2")) { inputStream = new BZip2CompressorInputStream(allCountInputStream); } else if (payloadCompressor.equals("lzma")) { try { java.io.PipedOutputStream pout = new java.io.PipedOutputStream(); inputStream = new java.io.PipedInputStream(pout); byte[] properties = new byte[5]; if (allCountInputStream.read(properties, 0, 5) != 5) { throw (new java.io.IOException("input .lzma is too short")); } SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); decoder.SetDecoderProperties(properties); long outSize = 0; for (int i = 0; i < 8; i++) { int v = allCountInputStream.read(); if (v < 0) { throw (new java.io.IOException("lzma error : Can't Read 1")); } outSize |= ((long)v) << (8 * i); } if (outSize == -1) { outSize = java.lang.Long.MAX_VALUE; } Decode decoderRunnable = new Decode(decoder, allCountInputStream, pout, outSize); java.lang.Thread t = new java.lang.Thread(decoderRunnable, "LZMA Decoder"); t.start(); } catch (java.lang.NoClassDefFoundError) { String message = "No LZMA library found. Attach p7zip library to classpath (http://p7zip.sourceforge.net/)"; logger.severe(message); throw new java.io.IOException(message); } } else if (payloadCompressor.equals("none")) { inputStream = allCountInputStream; } else { throw new java.io.IOException("Unsupported compressor type " + payloadCompressor); } ByteCountInputStream countInputStream = new ByteCountInputStream(inputStream); CpioArchiveInputStream cpioInputStream = new CpioArchiveInputStream(countInputStream); CpioArchiveEntry readEntry; java.util.List <String> fileNamesList = new java.util.ArrayList <String>(); String fileEntry; while ((readEntry = cpioInputStream.getNextCPIOEntry()) != null) { if (logger.isLoggable(java.util.logging.Level.FINER)) { logger.finer("Read CPIO entry: " + readEntry.getName() + " ;mode:" + readEntry.getMode()); } if (readEntry.isRegularFile() || readEntry.isSymbolicLink() || readEntry.isDirectory()) { fileEntry = readEntry.getName(); if (fileEntry.startsWith("./")) { fileEntry = fileEntry.substring(1); } fileNamesList.add(fileEntry); } } store.setTag("FILENAMES", TypeFactory.createSTRING_ARRAY((String[])fileNamesList.toArray(new String[fileNamesList.size()]))); setHeaderTagFromSignature("ARCHIVESIZE", "PAYLOADSIZE"); // check ARCHIVESIZE with countInputStream.getCount(); Object archiveSizeObject = getTag("ARCHIVESIZE"); if (archiveSizeObject != null) { if (archiveSizeObject is INT32) { int archiveSize = ((INT32)archiveSizeObject).getData()[0]; if (archiveSize != countInputStream.getCount()) { new java.io.IOException("ARCHIVESIZE not correct"); } } } store.setTag("J_ARCHIVESIZE", TypeFactory .createINT64(new long[] { countInputStream.getCount() })); } else { throw new java.io.IOException("Unsupported Payload type " + payloadFormat); } // filling in signatures // TODO: check signatures! setHeaderTagFromSignature("SIGSIZE", "SIZE"); setHeaderTagFromSignature("SIGLEMD5_1", "LEMD5_1"); setHeaderTagFromSignature("SIGPGP", "PGP"); setHeaderTagFromSignature("SIGLEMD5_2", "LEMD5_2"); setHeaderTagFromSignature("SIGMD5", "MD5"); setHeaderTagFromSignature("SIGGPG", "GPG"); setHeaderTagFromSignature("SIGPGP5", "PGP5"); setHeaderTagFromSignature("DSAHEADER", "DSA"); setHeaderTagFromSignature("RSAHEADER", "RSA"); setHeaderTagFromSignature("SHA1HEADER", "SHA1"); store.setTag("J_FILESIZE", TypeFactory .createINT64(new long[] { allCountInputStream.getCount() })); rpmInputStream.close(); }
/* * Returns registered providers * * @return */ public static java.security.Provider[] getProviders() { return(providers.toArray(new java.security.Provider[providers.size()])); }
// Returns all the public fields of the current System.Type. public __FieldInfo[] GetFields() { var f = this.InternalTypeDescription.getDeclaredFields(); var a = new java.util.ArrayList<__FieldInfo>(); for (int i = 0; i < f.Length; i++) { var fi = f[i]; // via https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2012/20120-1/20120817-wordpress var isPublic = Modifier.isPublic(fi.getModifiers()); var isFinal = Modifier.isFinal(fi.getModifiers()); if (isPublic || isFinal) { a.add( new __FieldInfo { InternalField = fi } ); } } // otherwise, a new array of the same runtime type is allocated return a.toArray(new __FieldInfo[0]); }
/** * Split the array into ExtraFields and populate them with the * given data. * @param data an array of bytes * @param local whether data originates from the local file data * or the central directory * @param onUnparseableData what to do if the extra field data * cannot be parsed. * @return an array of ExtraFields * @throws ZipException on error * * @since Apache Commons Compress 1.1 */ public static ZipExtraField[] parse(byte[] data, bool local, UnparseableExtraField onUnparseableData) //throws ZipException { java.util.List <ZipExtraField> v = new java.util.ArrayList <ZipExtraField>(); int start = 0; LOOP: while (start <= data.Length - WORD) { ZipShort headerId = new ZipShort(data, start); int length = (new ZipShort(data, start + 2)).getValue(); if (start + WORD + length > data.Length) { switch (onUnparseableData.getKey()) { case UnparseableExtraField.THROW_KEY: throw new java.util.zip.ZipException("bad extra field starting at " + start + ". Block length of " + length + " bytes exceeds remaining" + " data of " + (data.Length - start - WORD) + " bytes."); case UnparseableExtraField.READ_KEY: UnparseableExtraFieldData field = new UnparseableExtraFieldData(); if (local) { field.parseFromLocalFileData(data, start, data.Length - start); } else { field.parseFromCentralDirectoryData(data, start, data.Length - start); } v.add(field); #region case UnparseableExtraField.SKIP_KEY: goto LOOP; #endregion //$FALL-THROUGH$ case UnparseableExtraField.SKIP_KEY: // since we cannot parse the data we must assume // the extra field consumes the whole rest of the // available data goto LOOP; // Basties Note: Bad coder!!! default: throw new java.util.zip.ZipException("unknown UnparseableExtraField key: " + onUnparseableData.getKey()); } } try { ZipExtraField ze = createExtraField(headerId); if (local) { ze.parseFromLocalFileData(data, start + WORD, length); } else { ze.parseFromCentralDirectoryData(data, start + WORD, length); } v.add(ze); } catch (MethodAccessException iae) { throw new java.util.zip.ZipException(iae.getMessage()); } catch (MemberAccessException ie) { throw new java.util.zip.ZipException(ie.getMessage()); } start += (length + WORD); } ZipExtraField[] result = new ZipExtraField[v.size()]; return((ZipExtraField[])v.toArray(result)); }
/** * Gets all the handlers associated with this logger. * * @return an array of all the handlers associated with this logger. */ public Handler[] getHandlers() { return(handlers.toArray(EMPTY_HANDLERS_ARRAY)); }