code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public Store<X509CertificateHolder> getCertificates() { return HELPER.getCertificates(signedData.getCertificates()); }
Return any X.509 certificate objects in this SignedData structure as a Store of X509CertificateHolder objects. @return a Store of X509CertificateHolder objects.
CMSSignedData::getCertificates
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public Store<X509CRLHolder> getCRLs() { return HELPER.getCRLs(signedData.getCRLs()); }
Return any X.509 CRL objects in this SignedData structure as a Store of X509CRLHolder objects. @return a Store of X509CRLHolder objects.
CMSSignedData::getCRLs
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public Store<X509AttributeCertificateHolder> getAttributeCertificates() { return HELPER.getAttributeCertificates(signedData.getCertificates()); }
Return any X.509 attribute certificate objects in this SignedData structure as a Store of X509AttributeCertificateHolder objects. @return a Store of X509AttributeCertificateHolder objects.
CMSSignedData::getAttributeCertificates
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public Set<AlgorithmIdentifier> getDigestAlgorithmIDs() { Set<AlgorithmIdentifier> digests = new HashSet<AlgorithmIdentifier>(signedData.getDigestAlgorithms().size()); for (Enumeration en = signedData.getDigestAlgorithms().getObjects(); en.hasMoreElements();) { digests.add(AlgorithmIdentifier.getInstance(en.nextElement())); } return Collections.unmodifiableSet(digests); }
Return the digest algorithm identifiers for the SignedData object @return the set of digest algorithm identifiers
CMSSignedData::getDigestAlgorithmIDs
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public String getSignedContentTypeOID() { return signedData.getEncapContentInfo().getContentType().getId(); }
Return the a string representation of the OID associated with the encapsulated content info structure carried in the signed data. @return the OID for the content type.
CMSSignedData::getSignedContentTypeOID
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public ContentInfo toASN1Structure() { return contentInfo; }
return the ContentInfo
CMSSignedData::toASN1Structure
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public byte[] getEncoded() throws IOException { return contentInfo.getEncoded(); }
return the ASN.1 encoded representation of this object.
CMSSignedData::getEncoded
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public byte[] getEncoded(String encoding) throws IOException { return contentInfo.getEncoded(encoding); }
return the ASN.1 encoded representation of this object using the specified encoding. @param encoding the ASN.1 encoding format to use ("BER", "DL", or "DER").
CMSSignedData::getEncoded
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public static CMSSignedData replaceSigners( CMSSignedData signedData, SignerInformationStore signerInformationStore) { // // copy // CMSSignedData cms = new CMSSignedData(signedData); // // replace the store // cms.signerInfoStore = signerInformationStore; // // replace the signers in the SignedData object // ASN1EncodableVector digestAlgs = new ASN1EncodableVector(); ASN1EncodableVector vec = new ASN1EncodableVector(); Iterator it = signerInformationStore.getSigners().iterator(); while (it.hasNext()) { SignerInformation signer = (SignerInformation)it.next(); digestAlgs.add(CMSSignedHelper.INSTANCE.fixAlgID(signer.getDigestAlgorithmID())); vec.add(signer.toASN1Structure()); } ASN1Set digests = new DERSet(digestAlgs); ASN1Set signers = new DLSet(vec); ASN1Sequence sD = (ASN1Sequence)signedData.signedData.toASN1Primitive(); vec = new ASN1EncodableVector(); // // signers are the last item in the sequence. // vec.add(sD.getObjectAt(0)); // version vec.add(digests); for (int i = 2; i != sD.size() - 1; i++) { vec.add(sD.getObjectAt(i)); } vec.add(signers); cms.signedData = SignedData.getInstance(new BERSequence(vec)); // // replace the contentInfo with the new one // cms.contentInfo = new ContentInfo(cms.contentInfo.getContentType(), cms.signedData); return cms; }
Replace the SignerInformation store associated with this CMSSignedData object with the new one passed in. You would probably only want to do this if you wanted to change the unsigned attributes associated with a signer, or perhaps delete one. @param signedData the signed data object to be used as a base. @param signerInformationStore the new signer information store to use. @return a new signed data object.
CMSSignedData::replaceSigners
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public static CMSSignedData replaceCertificatesAndCRLs( CMSSignedData signedData, Store certificates, Store attrCerts, Store revocations) throws CMSException { // // copy // CMSSignedData cms = new CMSSignedData(signedData); // // replace the certs and revocations in the SignedData object // ASN1Set certSet = null; ASN1Set crlSet = null; if (certificates != null || attrCerts != null) { List certs = new ArrayList(); if (certificates != null) { certs.addAll(CMSUtils.getCertificatesFromStore(certificates)); } if (attrCerts != null) { certs.addAll(CMSUtils.getAttributeCertificatesFromStore(attrCerts)); } ASN1Set set = CMSUtils.createBerSetFromList(certs); if (set.size() != 0) { certSet = set; } } if (revocations != null) { ASN1Set set = CMSUtils.createBerSetFromList(CMSUtils.getCRLsFromStore(revocations)); if (set.size() != 0) { crlSet = set; } } // // replace the CMS structure. // cms.signedData = new SignedData(signedData.signedData.getDigestAlgorithms(), signedData.signedData.getEncapContentInfo(), certSet, crlSet, signedData.signedData.getSignerInfos()); // // replace the contentInfo with the new one // cms.contentInfo = new ContentInfo(cms.contentInfo.getContentType(), cms.signedData); return cms; }
Replace the certificate and CRL information associated with this CMSSignedData object with the new one passed in. @param signedData the signed data object to be used as a base. @param certificates the new certificates to be used. @param attrCerts the new attribute certificates to be used. @param revocations the new CRLs to be used - a collection of X509CRLHolder objects, OtherRevocationInfoFormat, or both. @return a new signed data object. @exception CMSException if there is an error processing the CertStore
CMSSignedData::replaceCertificatesAndCRLs
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/cms/CMSSignedData.java
MIT
public NamespaceSupport2 () { reset(); }
Create a new Namespace support object.
NamespaceSupport2::NamespaceSupport2
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public void reset () { // Discarding the whole stack doesn't save us a lot versus // creating a new NamespaceSupport. Do we care, or should we // change this to just reset the root context? currentContext = new Context2(null); currentContext.declarePrefix("xml", XMLNS); }
Reset this Namespace support object for reuse. <p>It is necessary to invoke this method before reusing the Namespace support object for a new session.</p>
NamespaceSupport2::reset
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public void pushContext () { // JJK: Context has a parent pointer. // That means we don't need a stack to pop. // We may want to retain for reuse, but that can be done via // a child pointer. Context2 parentContext=currentContext; currentContext = parentContext.getChild(); if (currentContext == null){ currentContext = new Context2(parentContext); } else{ // JJK: This will wipe out any leftover data // if we're reusing a previously allocated Context. currentContext.setParent(parentContext); } }
Start a new Namespace context. <p>Normally, you should push a new context at the beginning of each XML element: the new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.</p> <p>The Namespace support object always starts with a base context already in force: in this context, only the "xml" prefix is declared.</p> @see #popContext
NamespaceSupport2::pushContext
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public void popContext () { Context2 parentContext=currentContext.getParent(); if(parentContext==null) throw new EmptyStackException(); else currentContext = parentContext; }
Revert to the previous Namespace context. <p>Normally, you should pop the context at the end of each XML element. After popping the context, all Namespace prefix mappings that were previously in force are restored.</p> <p>You must not attempt to declare additional Namespace prefixes after popping a context, unless you push another context first.</p> @see #pushContext
NamespaceSupport2::popContext
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public boolean declarePrefix (String prefix, String uri) { if (prefix.equals("xml") || prefix.equals("xmlns")) { return false; } else { currentContext.declarePrefix(prefix, uri); return true; } }
Declare a Namespace prefix. <p>This method declares a prefix in the current Namespace context; the prefix will remain in force until this context is popped, unless it is shadowed in a descendant context.</p> <p>To declare a default Namespace, use the empty string. The prefix must not be "xml" or "xmlns".</p> <p>Note that you must <em>not</em> declare a prefix after you've pushed and popped another Namespace.</p> <p>Note that there is an asymmetry in this library: while {@link #getPrefix getPrefix} will not return the default "" prefix, even if you have declared one; to check for a default prefix, you have to look it up explicitly using {@link #getURI getURI}. This asymmetry exists to make it easier to look up prefixes for attribute names, where the default prefix is not allowed.</p> @param prefix The prefix to declare, or null for the empty string. @param uri The Namespace URI to associate with the prefix. @return true if the prefix was legal, false otherwise @see #processName @see #getURI @see #getPrefix
NamespaceSupport2::declarePrefix
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public String [] processName (String qName, String[] parts, boolean isAttribute) { String[] name=currentContext.processName(qName, isAttribute); if(name==null) return null; // JJK: This recopying is required because processName may return // a cached result. I Don't Like It. ***** System.arraycopy(name,0,parts,0,3); return parts; }
Process a raw XML 1.0 name. <p>This method processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among the prefixes currently declared. The return value will be the array supplied by the caller, filled in as follows:</p> <dl> <dt>parts[0]</dt> <dd>The Namespace URI, or an empty string if none is in use.</dd> <dt>parts[1]</dt> <dd>The local name (without prefix).</dd> <dt>parts[2]</dt> <dd>The original raw name.</dd> </dl> <p>All of the strings in the array will be internalized. If the raw name has a prefix that has not been declared, then the return value will be null.</p> <p>Note that attribute names are processed differently than element names: an unprefixed element name will received the default Namespace (if any), while an unprefixed element name will not.</p> @param qName The raw XML 1.0 name to be processed. @param parts A string array supplied by the caller, capable of holding at least three members. @param isAttribute A flag indicating whether this is an attribute name (true) or an element name (false). @return The supplied array holding three internalized strings representing the Namespace URI (or empty string), the local name, and the raw XML 1.0 name; or null if there is an undeclared prefix. @see #declarePrefix * @see java.lang.String#intern
NamespaceSupport2::processName
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public String getURI (String prefix) { return currentContext.getURI(prefix); }
Look up a prefix and get the currently-mapped Namespace URI. <p>This method looks up the prefix in the current context. Use the empty string ("") for the default Namespace.</p> @param prefix The prefix to look up. @return The associated Namespace URI, or null if the prefix is undeclared in this context. @see #getPrefix @see #getPrefixes
NamespaceSupport2::getURI
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public Enumeration getPrefixes () { return currentContext.getPrefixes(); }
Return an enumeration of all prefixes currently declared. <p><strong>Note:</strong> if there is a default prefix, it will not be returned in this enumeration; check for the default prefix using the {@link #getURI getURI} with an argument of "".</p> @return An enumeration of all prefixes declared in the current context except for the empty (default) prefix. @see #getDeclaredPrefixes @see #getURI
NamespaceSupport2::getPrefixes
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public String getPrefix (String uri) { return currentContext.getPrefix(uri); }
Return one of the prefixes mapped to a Namespace URI. <p>If more than one prefix is currently mapped to the same URI, this method will make an arbitrary selection; if you want all of the prefixes, use the {@link #getPrefixes} method instead.</p> <p><strong>Note:</strong> this will never return the empty (default) prefix; to check for a default prefix, use the {@link #getURI getURI} method with an argument of "".</p> @param uri The Namespace URI. @return One of the prefixes currently mapped to the URI supplied, or null if none is mapped or if the URI is assigned to the default Namespace. @see #getPrefixes(java.lang.String) * @see #getURI
NamespaceSupport2::getPrefix
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public Enumeration getPrefixes (String uri) { // JJK: The old code involved creating a vector, filling it // with all the matching prefixes, and then getting its // elements enumerator. Wastes storage, wastes cycles if we // don't actually need them all. Better to either implement // a specific enumerator for these prefixes... or a filter // around the all-prefixes enumerator, which comes out to // roughly the same thing. // // **** Currently a filter. That may not be most efficient // when I'm done restructuring storage! return new PrefixForUriEnumerator(this,uri,getPrefixes()); }
Return an enumeration of all prefixes currently declared for a URI. <p>This method returns prefixes mapped to a specific Namespace URI. The xml: prefix will be included. If you want only one prefix that's mapped to the Namespace URI, and you don't care which one you get, use the {@link #getPrefix getPrefix} method instead.</p> <p><strong>Note:</strong> the empty (default) prefix is <em>never</em> included in this enumeration; to check for the presence of a default Namespace, use the {@link #getURI getURI} method with an argument of "".</p> @param uri The Namespace URI. @return An enumeration of all prefixes declared in the current context. @see #getPrefix @see #getDeclaredPrefixes * @see #getURI
NamespaceSupport2::getPrefixes
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
public Enumeration getDeclaredPrefixes () { return currentContext.getDeclaredPrefixes(); }
Return an enumeration of all prefixes declared in this context. <p>The empty (default) prefix will be included in this enumeration; note that this behaviour differs from that of {@link #getPrefix} and {@link #getPrefixes}.</p> @return An enumeration of all prefixes declared in this context. @see #getPrefixes @see #getURI
NamespaceSupport2::getDeclaredPrefixes
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
Context2 (Context2 parent) { if(parent==null) { prefixTable = new Hashtable(); uriTable = new Hashtable(); elementNameTable=null; attributeNameTable=null; } else setParent(parent); }
Create a new Namespace context.
Context2::Context2
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
Context2 getChild() { return child; }
@returns The child Namespace context object, or null if this is the last currently on the chain.
Context2::getChild
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
Context2 getParent() { return parent; }
@returns The parent Namespace context object, or null if this is the root.
Context2::getParent
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
void setParent (Context2 parent) { this.parent = parent; parent.child = this; // JJK: Doubly-linked declarations = null; prefixTable = parent.prefixTable; uriTable = parent.uriTable; elementNameTable = parent.elementNameTable; attributeNameTable = parent.attributeNameTable; defaultNS = parent.defaultNS; tablesDirty = false; }
(Re)set the parent of this Namespace context. This is separate from the c'tor because it's re-applied when a Context2 is reused by push-after-pop. @param context The parent Namespace context object.
Context2::setParent
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
void declarePrefix (String prefix, String uri) { // Lazy processing... if (!tablesDirty) { copyTables(); } if (declarations == null) { declarations = new Vector(); } prefix = prefix.intern(); uri = uri.intern(); if ("".equals(prefix)) { if ("".equals(uri)) { defaultNS = null; } else { defaultNS = uri; } } else { prefixTable.put(prefix, uri); uriTable.put(uri, prefix); // may wipe out another prefix } declarations.addElement(prefix); }
Declare a Namespace prefix for this context. @param prefix The prefix to declare. @param uri The associated Namespace URI. @see org.xml.sax.helpers.NamespaceSupport2#declarePrefix
Context2::declarePrefix
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
String [] processName (String qName, boolean isAttribute) { String name[]; Hashtable table; // Select the appropriate table. if (isAttribute) { if(elementNameTable==null) elementNameTable=new Hashtable(); table = elementNameTable; } else { if(attributeNameTable==null) attributeNameTable=new Hashtable(); table = attributeNameTable; } // Start by looking in the cache, and // return immediately if the name // is already known in this content name = (String[])table.get(qName); if (name != null) { return name; } // We haven't seen this name in this // context before. name = new String[3]; int index = qName.indexOf(':'); // No prefix. if (index == -1) { if (isAttribute || defaultNS == null) { name[0] = ""; } else { name[0] = defaultNS; } name[1] = qName.intern(); name[2] = name[1]; } // Prefix else { String prefix = qName.substring(0, index); String local = qName.substring(index+1); String uri; if ("".equals(prefix)) { uri = defaultNS; } else { uri = (String)prefixTable.get(prefix); } if (uri == null) { return null; } name[0] = uri; name[1] = local.intern(); name[2] = qName.intern(); } // Save in the cache for future use. table.put(name[2], name); tablesDirty = true; return name; }
Process a raw XML 1.0 name in this context. @param qName The raw XML 1.0 name. @param isAttribute true if this is an attribute name. @return An array of three strings containing the URI part (or empty string), the local part, and the raw name, all internalized, or null if there is an undeclared prefix. @see org.xml.sax.helpers.NamespaceSupport2#processName
Context2::processName
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
String getURI (String prefix) { if ("".equals(prefix)) { return defaultNS; } else if (prefixTable == null) { return null; } else { return (String)prefixTable.get(prefix); } }
Look up the URI associated with a prefix in this context. @param prefix The prefix to look up. @return The associated Namespace URI, or null if none is declared. @see org.xml.sax.helpers.NamespaceSupport2#getURI
Context2::getURI
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
String getPrefix (String uri) { if (uriTable == null) { return null; } else { return (String)uriTable.get(uri); } }
Look up one of the prefixes associated with a URI in this context. <p>Since many prefixes may be mapped to the same URI, the return value may be unreliable.</p> @param uri The URI to look up. @return The associated prefix, or null if none is declared. @see org.xml.sax.helpers.NamespaceSupport2#getPrefix
Context2::getPrefix
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
Enumeration getDeclaredPrefixes () { if (declarations == null) { return EMPTY_ENUMERATION; } else { return declarations.elements(); } }
Return an enumeration of prefixes declared in this context. @return An enumeration of prefixes (possibly empty). @see org.xml.sax.helpers.NamespaceSupport2#getDeclaredPrefixes
Context2::getDeclaredPrefixes
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
Enumeration getPrefixes () { if (prefixTable == null) { return EMPTY_ENUMERATION; } else { return prefixTable.keys(); } }
Return an enumeration of all prefixes currently in force. <p>The default prefix, if in force, is <em>not</em> returned, and will have to be checked for separately.</p> @return An enumeration of prefixes (never empty). @see org.xml.sax.helpers.NamespaceSupport2#getPrefixes
Context2::getPrefixes
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
private void copyTables () { // Start by copying our parent's bindings prefixTable = (Hashtable)prefixTable.clone(); uriTable = (Hashtable)uriTable.clone(); // Replace the caches with empty ones, rather than // trying to determine which bindings should be flushed. // As far as I can tell, these caches are never actually // used in Xalan... More efficient to remove the whole // cache system? **** if(elementNameTable!=null) elementNameTable=new Hashtable(); if(attributeNameTable!=null) attributeNameTable=new Hashtable(); tablesDirty = true; }
Copy on write for the internal tables in this context. <p>This class is optimized for the normal case where most elements do not contain Namespace declarations. In that case, the Context2 will share data structures with its parent. New tables are obtained only when new declarations are issued, so they can be popped off the stack.</p> <p> JJK: **** Alternative: each Context2 might declare _only_ its local bindings, and delegate upward if not found.</p>
Context2::copyTables
java
Reginer/aosp-android-jar
android-35/src/org/apache/xml/utils/NamespaceSupport2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xml/utils/NamespaceSupport2.java
MIT
protected boolean isDividerAllowedAbove(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedAbove(); }
Whether a divider is allowed above the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed above this view holder.
DividerItemDecoration::isDividerAllowedAbove
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
protected boolean isDividerAllowedBelow(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedBelow(); }
Whether a divider is allowed below the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed below this view holder.
DividerItemDecoration::isDividerAllowedBelow
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public void setDivider(Drawable divider) { if (divider != null) { dividerIntrinsicHeight = divider.getIntrinsicHeight(); } else { dividerIntrinsicHeight = 0; } this.divider = divider; }
Whether a divider is allowed below the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed below this view holder. protected boolean isDividerAllowedBelow(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedBelow(); } /** Sets the drawable to be used as the divider.
DividerItemDecoration::setDivider
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public Drawable getDivider() { return divider; }
Whether a divider is allowed below the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed below this view holder. protected boolean isDividerAllowedBelow(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedBelow(); } /** Sets the drawable to be used as the divider. public void setDivider(Drawable divider) { if (divider != null) { dividerIntrinsicHeight = divider.getIntrinsicHeight(); } else { dividerIntrinsicHeight = 0; } this.divider = divider; } /** Gets the drawable currently used as the divider.
DividerItemDecoration::getDivider
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public void setDividerHeight(int dividerHeight) { this.dividerHeight = dividerHeight; }
Whether a divider is allowed below the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed below this view holder. protected boolean isDividerAllowedBelow(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedBelow(); } /** Sets the drawable to be used as the divider. public void setDivider(Drawable divider) { if (divider != null) { dividerIntrinsicHeight = divider.getIntrinsicHeight(); } else { dividerIntrinsicHeight = 0; } this.divider = divider; } /** Gets the drawable currently used as the divider. public Drawable getDivider() { return divider; } /** Sets the divider height, in pixels.
DividerItemDecoration::setDividerHeight
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public int getDividerHeight() { return dividerHeight; }
Whether a divider is allowed below the view holder. The allowed values will be combined according to {@link #getDividerCondition()}. The default implementation delegates to {@link com.android.setupwizardlib.DividerItemDecoration.DividedViewHolder}, or simply allows the divider if the view holder doesn't implement {@code DividedViewHolder}. Subclasses can override this to give more information to decide whether a divider should be drawn. @return True if divider is allowed below this view holder. protected boolean isDividerAllowedBelow(RecyclerView.ViewHolder viewHolder) { return !(viewHolder instanceof DividedViewHolder) || ((DividedViewHolder) viewHolder).isDividerAllowedBelow(); } /** Sets the drawable to be used as the divider. public void setDivider(Drawable divider) { if (divider != null) { dividerIntrinsicHeight = divider.getIntrinsicHeight(); } else { dividerIntrinsicHeight = 0; } this.divider = divider; } /** Gets the drawable currently used as the divider. public Drawable getDivider() { return divider; } /** Sets the divider height, in pixels. public void setDividerHeight(int dividerHeight) { this.dividerHeight = dividerHeight; } /** Gets the divider height, in pixels.
DividerItemDecoration::getDividerHeight
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public void setDividerCondition(@DividerCondition int dividerCondition) { this.dividerCondition = dividerCondition; }
Sets whether the divider needs permission from both the item view holder below and above from where the divider would draw itself or just needs permission from one or the other before drawing itself.
DividerItemDecoration::setDividerCondition
java
Reginer/aosp-android-jar
android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/setupwizardlib/DividerItemDecoration.java
MIT
public Address(Locale locale) { mLocale = locale; }
Constructs a new Address object set to the given Locale and with all other fields initialized to null or false.
Address::Address
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public Locale getLocale() { return mLocale; }
Returns the Locale associated with this address.
Address::getLocale
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public int getMaxAddressLineIndex() { return mMaxAddressLineIndex; }
Returns the largest index currently in use to specify an address line. If no address lines are specified, -1 is returned.
Address::getMaxAddressLineIndex
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getAddressLine(int index) { if (index < 0) { throw new IllegalArgumentException("index = " + index + " < 0"); } return mAddressLines == null? null : mAddressLines.get(index); }
Returns a line of the address numbered by the given index (starting at 0), or null if no such line is present. @throws IllegalArgumentException if index < 0
Address::getAddressLine
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setAddressLine(int index, String line) { if (index < 0) { throw new IllegalArgumentException("index = " + index + " < 0"); } if (mAddressLines == null) { mAddressLines = new HashMap<Integer, String>(); } mAddressLines.put(index, line); if (line == null) { // We've eliminated a line, recompute the max index mMaxAddressLineIndex = -1; for (Integer i : mAddressLines.keySet()) { mMaxAddressLineIndex = Math.max(mMaxAddressLineIndex, i); } } else { mMaxAddressLineIndex = Math.max(mMaxAddressLineIndex, index); } }
Sets the line of the address numbered by index (starting at 0) to the given String, which may be null. @throws IllegalArgumentException if index < 0
Address::setAddressLine
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getFeatureName() { return mFeatureName; }
Returns the feature name of the address, for example, "Golden Gate Bridge", or null if it is unknown
Address::getFeatureName
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setFeatureName(String featureName) { mFeatureName = featureName; }
Sets the feature name of the address to the given String, which may be null
Address::setFeatureName
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getAdminArea() { return mAdminArea; }
Returns the administrative area name of the address, for example, "CA", or null if it is unknown
Address::getAdminArea
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setAdminArea(String adminArea) { this.mAdminArea = adminArea; }
Sets the administrative area name of the address to the given String, which may be null
Address::setAdminArea
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getSubAdminArea() { return mSubAdminArea; }
Returns the sub-administrative area name of the address, for example, "Santa Clara County", or null if it is unknown
Address::getSubAdminArea
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setSubAdminArea(String subAdminArea) { this.mSubAdminArea = subAdminArea; }
Sets the sub-administrative area name of the address to the given String, which may be null
Address::setSubAdminArea
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getLocality() { return mLocality; }
Returns the locality of the address, for example "Mountain View", or null if it is unknown.
Address::getLocality
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setLocality(String locality) { mLocality = locality; }
Sets the locality of the address to the given String, which may be null.
Address::setLocality
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getSubLocality() { return mSubLocality; }
Returns the sub-locality of the address, or null if it is unknown. For example, this may correspond to the neighborhood of the locality.
Address::getSubLocality
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setSubLocality(String sublocality) { mSubLocality = sublocality; }
Sets the sub-locality of the address to the given String, which may be null.
Address::setSubLocality
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getThoroughfare() { return mThoroughfare; }
Returns the thoroughfare name of the address, for example, "1600 Ampitheater Parkway", which may be null
Address::getThoroughfare
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setThoroughfare(String thoroughfare) { this.mThoroughfare = thoroughfare; }
Sets the thoroughfare name of the address, which may be null.
Address::setThoroughfare
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getSubThoroughfare() { return mSubThoroughfare; }
Returns the sub-thoroughfare name of the address, which may be null. This may correspond to the street number of the address.
Address::getSubThoroughfare
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setSubThoroughfare(String subthoroughfare) { this.mSubThoroughfare = subthoroughfare; }
Sets the sub-thoroughfare name of the address, which may be null.
Address::setSubThoroughfare
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getPremises() { return mPremises; }
Returns the premises of the address, or null if it is unknown.
Address::getPremises
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setPremises(String premises) { mPremises = premises; }
Sets the premises of the address to the given String, which may be null.
Address::setPremises
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getPostalCode() { return mPostalCode; }
Returns the postal code of the address, for example "94110", or null if it is unknown.
Address::getPostalCode
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setPostalCode(String postalCode) { mPostalCode = postalCode; }
Sets the postal code of the address to the given String, which may be null.
Address::setPostalCode
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getCountryCode() { return mCountryCode; }
Returns the country code of the address, for example "US", or null if it is unknown.
Address::getCountryCode
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setCountryCode(String countryCode) { mCountryCode = countryCode; }
Sets the country code of the address to the given String, which may be null.
Address::setCountryCode
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getCountryName() { return mCountryName; }
Returns the localized country name of the address, for example "Iceland", or null if it is unknown.
Address::getCountryName
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setCountryName(String countryName) { mCountryName = countryName; }
Sets the country name of the address to the given String, which may be null.
Address::setCountryName
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public boolean hasLatitude() { return mHasLatitude; }
Returns true if a latitude has been assigned to this Address, false otherwise.
Address::hasLatitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public double getLatitude() { if (mHasLatitude) { return mLatitude; } else { throw new IllegalStateException(); } }
Returns the latitude of the address if known. @throws IllegalStateException if this Address has not been assigned a latitude.
Address::getLatitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setLatitude(double latitude) { mLatitude = latitude; mHasLatitude = true; }
Sets the latitude associated with this address.
Address::setLatitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void clearLatitude() { mHasLatitude = false; }
Removes any latitude associated with this address.
Address::clearLatitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public boolean hasLongitude() { return mHasLongitude; }
Returns true if a longitude has been assigned to this Address, false otherwise.
Address::hasLongitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public double getLongitude() { if (mHasLongitude) { return mLongitude; } else { throw new IllegalStateException(); } }
Returns the longitude of the address if known. @throws IllegalStateException if this Address has not been assigned a longitude.
Address::getLongitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setLongitude(double longitude) { mLongitude = longitude; mHasLongitude = true; }
Sets the longitude associated with this address.
Address::setLongitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void clearLongitude() { mHasLongitude = false; }
Removes any longitude associated with this address.
Address::clearLongitude
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getPhone() { return mPhone; }
Returns the phone number of the address if known, or null if it is unknown. @throws IllegalStateException if this Address has not been assigned a phone number.
Address::getPhone
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setPhone(String phone) { mPhone = phone; }
Sets the phone number associated with this address.
Address::setPhone
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public String getUrl() { return mUrl; }
Returns the public URL for the address if known, or null if it is unknown.
Address::getUrl
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setUrl(String Url) { mUrl = Url; }
Sets the public URL associated with this address.
Address::setUrl
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public Bundle getExtras() { return mExtras; }
Returns additional provider-specific information about the address as a Bundle. The keys and values are determined by the provider. If no additional information is available, null is returned. <!-- <p> A number of common key/value pairs are listed below. Providers that use any of the keys on this list must provide the corresponding value as described below. <ul> </ul> -->
Address::getExtras
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public void setExtras(Bundle extras) { mExtras = (extras == null) ? null : new Bundle(extras); }
Sets the extra information associated with this fix to the given Bundle.
Address::setExtras
java
Reginer/aosp-android-jar
android-34/src/android/location/Address.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/location/Address.java
MIT
public TrackSelectionArray(@NullableType TrackSelection... trackSelections) { this.trackSelections = trackSelections; this.length = trackSelections.length; }
/* Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. package com.google.android.exoplayer2.trackselection; import androidx.annotation.Nullable; import java.util.Arrays; import org.checkerframework.checker.nullness.compatqual.NullableType; /** An array of {@link TrackSelection}s. public final class TrackSelectionArray { /** The length of this array. public final int length; private final @NullableType TrackSelection[] trackSelections; // Lazily initialized hashcode. private int hashCode; /** @param trackSelections The selections. Must not be null, but may contain null elements.
TrackSelectionArray::TrackSelectionArray
java
Reginer/aosp-android-jar
android-34/src/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java
MIT
public @NullableType TrackSelection[] getAll() { return trackSelections.clone(); }
Returns the selection at a given index. @param index The index of the selection. @return The selection. @Nullable public TrackSelection get(int index) { return trackSelections[index]; } /** Returns the selections in a newly allocated array.
TrackSelectionArray::getAll
java
Reginer/aosp-android-jar
android-34/src/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java
MIT
public IImsEcbm getImsEcbm() { return mImsEcbm; }
Base implementation of ImsEcbm, which implements stub versions of the methods in the IImsEcbm AIDL. Override the methods that your implementation of ImsEcbm supports. DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you will break other implementations of ImsEcbm maintained by other ImsServices. @hide @SystemApi public class ImsEcbmImplBase { private static final String TAG = "ImsEcbmImplBase"; private final Object mLock = new Object(); private IImsEcbmListener mListener; private Executor mExecutor = Runnable::run; private final IImsEcbm mImsEcbm = new IImsEcbm.Stub() { @Override public void setListener(IImsEcbmListener listener) { executeMethodAsync(() -> { if (mListener != null && !mListener.asBinder().isBinderAlive()) { Log.w(TAG, "setListener: discarding dead Binder"); mListener = null; } if (mListener != null && listener != null && Objects.equals( mListener.asBinder(), listener.asBinder())) { return; } if (listener == null) { mListener = null; } else if (listener != null && mListener == null) { mListener = listener; } else { // Warn that the listener is being replaced while active Log.w(TAG, "setListener is being called when there is already an active " + "listener"); mListener = listener; } }, "setListener"); } @Override public void exitEmergencyCallbackMode() { executeMethodAsync(() -> ImsEcbmImplBase.this.exitEmergencyCallbackMode(), "exitEmergencyCallbackMode"); } // Call the methods with a clean calling identity on the executor and wait indefinitely for // the future to return. private void executeMethodAsync(Runnable r, String errorLogName) { try { CompletableFuture.runAsync( () -> TelephonyUtils.runWithCleanCallingIdentity(r), mExecutor).join(); } catch (CancellationException | CompletionException e) { Log.w(TAG, "ImsEcbmImplBase Binder - " + errorLogName + " exception: " + e.getMessage()); } } }; /** @hide
ImsEcbmImplBase::getImsEcbm
java
Reginer/aosp-android-jar
android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
MIT
public void exitEmergencyCallbackMode() { Log.d(TAG, "exitEmergencyCallbackMode() not implemented"); }
This method should be implemented by the IMS provider. Framework will trigger this method to request to come out of ECBM mode
ImsEcbmImplBase::exitEmergencyCallbackMode
java
Reginer/aosp-android-jar
android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
MIT
public final void enteredEcbm() { Log.d(TAG, "Entered ECBM."); IImsEcbmListener listener; synchronized (mLock) { listener = mListener; } if (listener != null) { try { listener.enteredECBM(); } catch (RemoteException e) { throw new RuntimeException(e); } } }
Notifies the framework when the device enters Emergency Callback Mode. @throws RuntimeException if the connection to the framework is not available.
ImsEcbmImplBase::enteredEcbm
java
Reginer/aosp-android-jar
android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
MIT
public final void exitedEcbm() { Log.d(TAG, "Exited ECBM."); IImsEcbmListener listener; synchronized (mLock) { listener = mListener; } if (listener != null) { try { listener.exitedECBM(); } catch (RemoteException e) { throw new RuntimeException(e); } } }
Notifies the framework when the device exits Emergency Callback Mode. @throws RuntimeException if the connection to the framework is not available.
ImsEcbmImplBase::exitedEcbm
java
Reginer/aosp-android-jar
android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
MIT
public final void setDefaultExecutor(@NonNull Executor executor) { mExecutor = executor; }
Set default Executor from MmTelFeature. @param executor The default executor for the framework to use when executing the methods overridden by the implementation of ImsEcbm. @hide
ImsEcbmImplBase::setDefaultExecutor
java
Reginer/aosp-android-jar
android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/ims/stub/ImsEcbmImplBase.java
MIT
public ArrayList<Uri> getCreatedUris() { return mCreatedUris; }
Returns the list of created Uris. This list should not be modified by the caller as it is not a clone.
VCardEntryCommitter::getCreatedUris
java
Reginer/aosp-android-jar
android-34/src/com/android/vcard/VCardEntryCommitter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/vcard/VCardEntryCommitter.java
MIT
public elementretrieveallattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { org.w3c.domts.DocumentBuilderSetting[] settings = new org.w3c.domts.DocumentBuilderSetting[] { org.w3c.domts.DocumentBuilderSetting.validating }; DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); setFactory(testFactory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "staff", false); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
elementretrieveallattributes::elementretrieveallattributes
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
MIT
public void runTest() throws Throwable { Document doc; NodeList addressList; Node testAddress; NamedNodeMap attributes; doc = (Document) load("staff", false); addressList = doc.getElementsByTagName("address"); testAddress = addressList.item(0); attributes = testAddress.getAttributes(); assertSize("elementRetrieveAllAttributesAssert", 2, attributes); }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
elementretrieveallattributes::runTest
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrieveallattributes"; }
Gets URI that identifies the test. @return uri identifier of test
elementretrieveallattributes::getTargetURI
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(elementretrieveallattributes.class, args); }
Runs this test from the command line. @param args command line arguments
elementretrieveallattributes::main
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/elementretrieveallattributes.java
MIT
public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row.
PropsVectors::PropsVectors
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* * Rows need to be split if they partially overlap with the input range * (only possible for the first and last rows) and if their value * differs from the input value. */ splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException
PropsVectors::setValue
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact().
PropsVectors::getValue
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public int[] getRow(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } int[] rowToReturn = new int[columns - 2]; System.arraycopy(v, rowIndex * columns + 2, rowToReturn, 0, columns - 2); return rowToReturn; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact(). public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; } /* Returns an array which contains value elements in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException
PropsVectors::getRow
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public int getRowStart(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns]; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact(). public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; } /* Returns an array which contains value elements in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int[] getRow(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } int[] rowToReturn = new int[columns - 2]; System.arraycopy(v, rowIndex * columns + 2, rowToReturn, 0, columns - 2); return rowToReturn; } /* Returns an int which is the start codepoint in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException
PropsVectors::getRowStart
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public int getRowEnd(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns + 1] - 1; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact(). public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; } /* Returns an array which contains value elements in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int[] getRow(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } int[] rowToReturn = new int[columns - 2]; System.arraycopy(v, rowIndex * columns + 2, rowToReturn, 0, columns - 2); return rowToReturn; } /* Returns an int which is the start codepoint in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int getRowStart(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns]; } /* Returns an int which is the limit codepoint minus 1 in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException
PropsVectors::getRowEnd
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public void compact(CompactHandler compactor) { if (isCompacted) { return; } // Set the flag now: Sorting and compacting destroys the builder // data structure. isCompacted = true; int valueColumns = columns - 2; // not counting start & limit // sort the properties vectors to find unique vector values Integer[] indexArray = new Integer[rows]; for (int i = 0; i < rows; ++i) { indexArray[i] = columns * i; } Arrays.sort(indexArray, new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { int indexOfRow1 = o1.intValue(); int indexOfRow2 = o2.intValue(); int count = columns; // includes start/limit columns // start comparing after start/limit // but wrap around to them int index = 2; do { if (v[indexOfRow1 + index] != v[indexOfRow2 + index]) { return v[indexOfRow1 + index] < v[indexOfRow2 + index] ? -1 : 1; } if (++index == columns) { index = 0; } } while (--count > 0); return 0; } }); /* * Find and set the special values. This has to do almost the same work * as the compaction below, to find the indexes where the special-value * rows will move. */ int count = -valueColumns; for (int i = 0; i < rows; ++i) { int start = v[indexArray[i].intValue()]; // count a new values vector if it is different // from the current one if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2, v, indexArray[i-1].intValue() + 2, valueColumns)) { count += valueColumns; } if (start == INITIAL_VALUE_CP) { compactor.setRowIndexForInitialValue(count); } else if (start == ERROR_VALUE_CP) { compactor.setRowIndexForErrorValue(count); } } // count is at the beginning of the last vector, // add valueColumns to include that last vector count += valueColumns; // Call the handler once more to signal the start of // delivering real values. compactor.startRealValues(count); /* * Move vector contents up to a contiguous array with only unique * vector values, and call the handler function for each vector. * * This destroys the Properties Vector structure and replaces it * with an array of just vector values. */ int[] temp = new int[count]; count = -valueColumns; for (int i = 0; i < rows; ++i) { int start = v[indexArray[i].intValue()]; int limit = v[indexArray[i].intValue() + 1]; // count a new values vector if it is different // from the current one if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2, temp, count, valueColumns)) { count += valueColumns; System.arraycopy(v, indexArray[i].intValue() + 2, temp, count, valueColumns); } if (start < FIRST_SPECIAL_CP) { compactor.setRowIndexForRange(start, limit - 1, count); } } v = temp; // count is at the beginning of the last vector, // add one to include that last vector rows = count / valueColumns + 1; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact(). public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; } /* Returns an array which contains value elements in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int[] getRow(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } int[] rowToReturn = new int[columns - 2]; System.arraycopy(v, rowIndex * columns + 2, rowToReturn, 0, columns - 2); return rowToReturn; } /* Returns an int which is the start codepoint in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int getRowStart(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns]; } /* Returns an int which is the limit codepoint minus 1 in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int getRowEnd(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns + 1] - 1; } /* Compact the vectors: - modify the memory - keep only unique vectors - store them contiguously from the beginning of the memory - for each (non-unique) row, call the respective function in CompactHandler The handler's rowIndex is the index of the row in the compacted memory block. Therefore, it starts at 0 increases in increments of the columns value. In a first phase, only special values are delivered (each exactly once). Then CompactHandler::startRealValues() is called where rowIndex is the length of the compacted array. Then, in the second phase, the CompactHandler::setRowIndexForRange() is called for each row of real values.
PropsVectors::compact
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT
public int[] getCompactedArray() { if (!isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method before compact()"); } return v; }
Unicode Properties Vectors associated with code point ranges. Rows of primitive integers in a contiguous array store the range limits and the properties vectors. In each row, row[0] contains the start code point and row[1] contains the limit code point, which is the start of the next range. Initially, there is only one range [0..0x110000] with values 0. It would be possible to store only one range boundary per row, but self-contained rows allow to later sort them by contents. @hide Only a subset of ICU is exposed in Android public class PropsVectors { private int v[]; private int columns; // number of columns, plus two for start // and limit values private int maxRows; private int rows; private int prevRow; // search optimization: remember last row seen private boolean isCompacted; // internal function to compare elements in v and target. Return true iff // elements in v starting from index1 to index1 + length - 1 // are exactly the same as elements in target // starting from index2 to index2 + length - 1 private boolean areElementsSame(int index1, int[] target, int index2, int length) { for (int i = 0; i < length; ++i) { if (v[index1 + i] != target[index2 + i]) { return false; } } return true; } // internal function which given rangeStart, returns // index where v[index]<=rangeStart<v[index+1]. // The returned index is a multiple of columns, and therefore // points to the start of a row. private int findRow(int rangeStart) { int index = 0; // check the vicinity of the last-seen row (start // searching with an unrolled loop) index = prevRow * columns; if (rangeStart >= v[index]) { if (rangeStart < v[index + 1]) { // same row as last seen return index; } else { index += columns; if (rangeStart < v[index + 1]) { ++prevRow; return index; } else { index += columns; if (rangeStart < v[index + 1]) { prevRow += 2; return index; } else if ((rangeStart - v[index + 1]) < 10) { // we are close, continue looping prevRow += 2; do { ++prevRow; index += columns; } while (rangeStart >= v[index + 1]); return index; } } } } else if (rangeStart < v[1]) { // the very first row prevRow = 0; return 0; } // do a binary search for the start of the range int start = 0; int mid = 0; int limit = rows; while (start < limit - 1) { mid = (start + limit) / 2; index = columns * mid; if (rangeStart < v[index]) { limit = mid; } else if (rangeStart < v[index + 1]) { prevRow = mid; return index; } else { start = mid; } } // must be found because all ranges together always cover // all of Unicode prevRow = start; index = start * columns; return index; } /* Special pseudo code points for storing the initialValue and the errorValue which are used to initialize a Trie or similar. public final static int FIRST_SPECIAL_CP = 0x110000; public final static int INITIAL_VALUE_CP = 0x110000; public final static int ERROR_VALUE_CP = 0x110001; public final static int MAX_CP = 0x110001; public final static int INITIAL_ROWS = 1 << 12; public final static int MEDIUM_ROWS = 1 << 16; public final static int MAX_ROWS = MAX_CP + 1; /* Constructor. @param numOfColumns Number of value integers (32-bit int) per row. public PropsVectors(int numOfColumns) { if (numOfColumns < 1) { throw new IllegalArgumentException("numOfColumns need to be no " + "less than 1; but it is " + numOfColumns); } columns = numOfColumns + 2; // count range start and limit columns v = new int[INITIAL_ROWS * columns]; maxRows = INITIAL_ROWS; rows = 2 + (MAX_CP - FIRST_SPECIAL_CP); prevRow = 0; isCompacted = false; v[0] = 0; v[1] = 0x110000; int index = columns; for (int cp = FIRST_SPECIAL_CP; cp <= MAX_CP; ++cp) { v[index] = cp; v[index + 1] = cp + 1; index += columns; } } /* In rows for code points [start..end], select the column, reset the mask bits and set the value bits (ANDed with the mask). @throws IllegalArgumentException @throws IllegalStateException @throws IndexOutOfBoundsException public void setValue(int start, int end, int column, int value, int mask) { if (start < 0 || start > end || end > MAX_CP || column < 0 || column >= (columns - 2)) { throw new IllegalArgumentException(); } if (isCompacted) { throw new IllegalStateException("Shouldn't be called after" + "compact()!"); } int firstRow, lastRow; int limit = end + 1; boolean splitFirstRow, splitLastRow; // skip range start and limit columns column += 2; value &= mask; // find the rows whose ranges overlap with the input range // find the first and last row, always successful firstRow = findRow(start); lastRow = findRow(end); /* Rows need to be split if they partially overlap with the input range (only possible for the first and last rows) and if their value differs from the input value. splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask)); splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask)); // split first/last rows if necessary if (splitFirstRow || splitLastRow) { int rowsToExpand = 0; if (splitFirstRow) { ++rowsToExpand; } if (splitLastRow) { ++rowsToExpand; } int newMaxRows = 0; if ((rows + rowsToExpand) > maxRows) { if (maxRows < MEDIUM_ROWS) { newMaxRows = MEDIUM_ROWS; } else if (maxRows < MAX_ROWS) { newMaxRows = MAX_ROWS; } else { throw new IndexOutOfBoundsException( "MAX_ROWS exceeded! Increase it to a higher value" + "in the implementation"); } int[] temp = new int[newMaxRows * columns]; System.arraycopy(v, 0, temp, 0, rows * columns); v = temp; maxRows = newMaxRows; } // count the number of row cells to move after the last row, // and move them int count = (rows * columns) - (lastRow + columns); if (count > 0) { System.arraycopy(v, lastRow + columns, v, lastRow + (1 + rowsToExpand) * columns, count); } rows += rowsToExpand; // split the first row, and move the firstRow pointer // to the second part if (splitFirstRow) { // copy all affected rows up one and move the lastRow pointer count = lastRow - firstRow + columns; System.arraycopy(v, firstRow, v, firstRow + columns, count); lastRow += columns; // split the range and move the firstRow pointer v[firstRow + 1] = v[firstRow + columns] = start; firstRow += columns; } // split the last row if (splitLastRow) { // copy the last row data System.arraycopy(v, lastRow, v, lastRow + columns, columns); // split the range and move the firstRow pointer v[lastRow + 1] = v[lastRow + columns] = limit; } } // set the "row last seen" to the last row for the range prevRow = lastRow / columns; // set the input value in all remaining rows firstRow += column; lastRow += column; mask = ~mask; for (;;) { v[firstRow] = (v[firstRow] & mask) | value; if (firstRow == lastRow) { break; } firstRow += columns; } } /* Always returns 0 if called after compact(). public int getValue(int c, int column) { if (isCompacted || c < 0 || c > MAX_CP || column < 0 || column >= (columns - 2)) { return 0; } int index = findRow(c); return v[index + 2 + column]; } /* Returns an array which contains value elements in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int[] getRow(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } int[] rowToReturn = new int[columns - 2]; System.arraycopy(v, rowIndex * columns + 2, rowToReturn, 0, columns - 2); return rowToReturn; } /* Returns an int which is the start codepoint in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int getRowStart(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns]; } /* Returns an int which is the limit codepoint minus 1 in row rowIndex. @throws IllegalStateException @throws IllegalArgumentException public int getRowEnd(int rowIndex) { if (isCompacted) { throw new IllegalStateException( "Illegal Invocation of the method after compact()"); } if (rowIndex < 0 || rowIndex > rows) { throw new IllegalArgumentException("rowIndex out of bound!"); } return v[rowIndex * columns + 1] - 1; } /* Compact the vectors: - modify the memory - keep only unique vectors - store them contiguously from the beginning of the memory - for each (non-unique) row, call the respective function in CompactHandler The handler's rowIndex is the index of the row in the compacted memory block. Therefore, it starts at 0 increases in increments of the columns value. In a first phase, only special values are delivered (each exactly once). Then CompactHandler::startRealValues() is called where rowIndex is the length of the compacted array. Then, in the second phase, the CompactHandler::setRowIndexForRange() is called for each row of real values. public void compact(CompactHandler compactor) { if (isCompacted) { return; } // Set the flag now: Sorting and compacting destroys the builder // data structure. isCompacted = true; int valueColumns = columns - 2; // not counting start & limit // sort the properties vectors to find unique vector values Integer[] indexArray = new Integer[rows]; for (int i = 0; i < rows; ++i) { indexArray[i] = columns * i; } Arrays.sort(indexArray, new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { int indexOfRow1 = o1.intValue(); int indexOfRow2 = o2.intValue(); int count = columns; // includes start/limit columns // start comparing after start/limit // but wrap around to them int index = 2; do { if (v[indexOfRow1 + index] != v[indexOfRow2 + index]) { return v[indexOfRow1 + index] < v[indexOfRow2 + index] ? -1 : 1; } if (++index == columns) { index = 0; } } while (--count > 0); return 0; } }); /* Find and set the special values. This has to do almost the same work as the compaction below, to find the indexes where the special-value rows will move. int count = -valueColumns; for (int i = 0; i < rows; ++i) { int start = v[indexArray[i].intValue()]; // count a new values vector if it is different // from the current one if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2, v, indexArray[i-1].intValue() + 2, valueColumns)) { count += valueColumns; } if (start == INITIAL_VALUE_CP) { compactor.setRowIndexForInitialValue(count); } else if (start == ERROR_VALUE_CP) { compactor.setRowIndexForErrorValue(count); } } // count is at the beginning of the last vector, // add valueColumns to include that last vector count += valueColumns; // Call the handler once more to signal the start of // delivering real values. compactor.startRealValues(count); /* Move vector contents up to a contiguous array with only unique vector values, and call the handler function for each vector. This destroys the Properties Vector structure and replaces it with an array of just vector values. int[] temp = new int[count]; count = -valueColumns; for (int i = 0; i < rows; ++i) { int start = v[indexArray[i].intValue()]; int limit = v[indexArray[i].intValue() + 1]; // count a new values vector if it is different // from the current one if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2, temp, count, valueColumns)) { count += valueColumns; System.arraycopy(v, indexArray[i].intValue() + 2, temp, count, valueColumns); } if (start < FIRST_SPECIAL_CP) { compactor.setRowIndexForRange(start, limit - 1, count); } } v = temp; // count is at the beginning of the last vector, // add one to include that last vector rows = count / valueColumns + 1; } /* Get the vectors array after calling compact(). @throws IllegalStateException
PropsVectors::getCompactedArray
java
Reginer/aosp-android-jar
android-35/src/android/icu/impl/PropsVectors.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/icu/impl/PropsVectors.java
MIT