code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
833 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
private int getHandleFromNode(Node node) { if (null != node) { int len = m_nodes.size(); boolean isMore; int i = 0; do { for (; i < len; i++) { if (m_nodes.elementAt(i) == node) return makeNodeHandle(i); } isMore = nextNode(); len = m_nodes.size(); } while(isMore || i < len); } return DTM.NULL; }
Get the handle from a Node. <p>%OPT% This will be pretty slow.</p> <p>%OPT% An XPath-like search (walk up DOM to root, tracking path; walk down DTM reconstructing path) might be considerably faster on later nodes in large documents. That might also imply improving this call to handle nodes which would be in this DTM but have not yet been built, which might or might not be a Good Thing.</p> %REVIEW% This relies on being able to test node-identity via object-identity. DTM2DOM proxying is a great example of a case where that doesn't work. DOM Level 3 will provide the isSameNode() method to fix that, but until then this is going to be flaky. @param node A node, which may be null. @return The node handle or <code>DTM.NULL</code>.
DOM2DTM::getHandleFromNode
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public int getHandleOfNode(Node node) { if (null != node) { // Is Node actually within the same document? If not, don't search! // This would be easier if m_root was always the Document node, but // we decided to allow wrapping a DTM around a subtree. if((m_root==node) || (m_root.getNodeType()==DOCUMENT_NODE && m_root==node.getOwnerDocument()) || (m_root.getNodeType()!=DOCUMENT_NODE && m_root.getOwnerDocument()==node.getOwnerDocument()) ) { // If node _is_ in m_root's tree, find its handle // // %OPT% This check may be improved significantly when DOM // Level 3 nodeKey and relative-order tests become // available! for(Node cursor=node; cursor!=null; cursor= (cursor.getNodeType()!=ATTRIBUTE_NODE) ? cursor.getParentNode() : ((org.w3c.dom.Attr)cursor).getOwnerElement()) { if(cursor==m_root) // We know this node; find its handle. return getHandleFromNode(node); } // for ancestors of node } // if node and m_root in same Document } // if node!=null return DTM.NULL; }
Get the handle from a Node. This is a more robust version of getHandleFromNode, intended to be usable by the public. <p>%OPT% This will be pretty slow.</p> %REVIEW% This relies on being able to test node-identity via object-identity. DTM2DOM proxying is a great example of a case where that doesn't work. DOM Level 3 will provide the isSameNode() method to fix that, but until then this is going to be flaky. @param node A node, which may be null. * @return The node handle or <code>DTM.NULL</code>.
DOM2DTM::getHandleOfNode
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { // %OPT% This is probably slower than it needs to be. if (null == namespaceURI) namespaceURI = ""; int type = getNodeType(nodeHandle); if (DTM.ELEMENT_NODE == type) { // Assume that attributes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { // Assume this can not be null. type = _type(identity); // %REVIEW% // Should namespace nodes be retrievable DOM-style as attrs? // If not we need a separate function... which may be desirable // architecturally, but which is ugly from a code point of view. // (If we REALLY insist on it, this code should become a subroutine // of both -- retrieve the node, then test if the type matches // what you're looking for.) if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE) { Node node = lookupNode(identity); String nodeuri = node.getNamespaceURI(); if (null == nodeuri) nodeuri = ""; String nodelocalname = node.getLocalName(); if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname)) return makeNodeHandle(identity); } else // if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
Retrieves an attribute node by by qualified name and namespace URI. @param nodeHandle int Handle of the node upon which to look up this attribute.. @param namespaceURI The namespace URI of the attribute to retrieve, or null. @param name The local name of the attribute to retrieve. @return The attribute node handle with the specified name ( <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such attribute.
DOM2DTM::getAttributeNode
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public XMLString getStringValue(int nodeHandle) { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); // %TBD% If an element only has one text node, we should just use it // directly. if(DTM.ELEMENT_NODE == type || DTM.DOCUMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type) { FastStringBuffer buf = StringBufferPool.get(); String s; try { getNodeData(node, buf); s = (buf.length() > 0) ? buf.toString() : ""; } finally { StringBufferPool.free(buf); } return m_xstrf.newstr( s ); } else if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { // If this is a DTM text node, it may be made of multiple DOM text // nodes -- including navigating into Entity References. DOM2DTM // records the first node in the sequence and requires that we // pick up the others when we retrieve the DTM node's value. // // %REVIEW% DOM Level 3 is expected to add a "whole text" // retrieval method which performs this function for us. FastStringBuffer buf = StringBufferPool.get(); while(node!=null) { buf.append(node.getNodeValue()); node=logicalNextDOMTextNode(node); } String s=(buf.length() > 0) ? buf.toString() : ""; StringBufferPool.free(buf); return m_xstrf.newstr( s ); } else return m_xstrf.newstr( node.getNodeValue() ); }
Get the string-value of a node as a String object (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value). @param nodeHandle The node ID. @return A string object that represents the string-value of the given node.
DOM2DTM::getStringValue
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public boolean isWhitespace(int nodeHandle) { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { // If this is a DTM text node, it may be made of multiple DOM text // nodes -- including navigating into Entity References. DOM2DTM // records the first node in the sequence and requires that we // pick up the others when we retrieve the DTM node's value. // // %REVIEW% DOM Level 3 is expected to add a "whole text" // retrieval method which performs this function for us. FastStringBuffer buf = StringBufferPool.get(); while(node!=null) { buf.append(node.getNodeValue()); node=logicalNextDOMTextNode(node); } boolean b = buf.isWhitespace(0, buf.length()); StringBufferPool.free(buf); return b; } return false; }
Determine if the string-value of a node is whitespace @param nodeHandle The node Handle. @return Return true if the given node is whitespace.
DOM2DTM::isWhitespace
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
protected static void getNodeData(Node node, FastStringBuffer buf) { switch (node.getNodeType()) { case Node.DOCUMENT_FRAGMENT_NODE : case Node.DOCUMENT_NODE : case Node.ELEMENT_NODE : { for (Node child = node.getFirstChild(); null != child; child = child.getNextSibling()) { getNodeData(child, buf); } } break; case Node.TEXT_NODE : case Node.CDATA_SECTION_NODE : case Node.ATTRIBUTE_NODE : // Never a child but might be our starting node buf.append(node.getNodeValue()); break; case Node.PROCESSING_INSTRUCTION_NODE : // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING); break; default : // ignore break; } }
Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object. Note that attributes are not considered part of the content of an element. <p> There are open questions regarding whitespace stripping. Currently we make no special effort in that regard, since the standard DOM doesn't yet provide DTD-based information to distinguish whitespace-in-element-context from genuine #PCDATA. Note that we should probably also consider xml:space if/when we address this. DOM Level 3 may solve the problem for us. <p> %REVIEW% Actually, since this method operates on the DOM side of the fence rather than the DTM side, it SHOULDN'T do any special handling. The DOM does what the DOM does; if you want DTM-level abstractions, use DTM-level methods. @param node Node whose subtree is to be walked, gathering the contents of all Text or CDATASection nodes. @param buf FastStringBuffer into which the contents of the text nodes are to be concatenated.
DOM2DTM::getNodeData
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getNodeName(int nodeHandle) { Node node = getNode(nodeHandle); // Assume non-null. return node.getNodeName(); }
Given a node handle, return its DOM-style node name. This will include names such as #text or #document. @param nodeHandle the id of the node. @return String Name of this node, which may be an empty string. %REVIEW% Document when empty string is possible... %REVIEW-COMMENT% It should never be empty, should it?
DOM2DTM::getNodeName
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getNodeNameX(int nodeHandle) { String name; short type = getNodeType(nodeHandle); switch (type) { case DTM.NAMESPACE_NODE : { Node node = getNode(nodeHandle); // assume not null. name = node.getNodeName(); if(name.startsWith("xmlns:")) { name = QName.getLocalPart(name); } else if(name.equals("xmlns")) { name = ""; } } break; case DTM.ATTRIBUTE_NODE : case DTM.ELEMENT_NODE : case DTM.ENTITY_REFERENCE_NODE : case DTM.PROCESSING_INSTRUCTION_NODE : { Node node = getNode(nodeHandle); // assume not null. name = node.getNodeName(); } break; default : name = ""; } return name; }
Given a node handle, return the XPath node name. This should be the name as described by the XPath data model, NOT the DOM-style name. @param nodeHandle the id of the node. @return String Name of this node, which may be an empty string.
DOM2DTM::getNodeNameX
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getLocalName(int nodeHandle) { if(JJK_NEWCODE) { int id=makeNodeIdentity(nodeHandle); if(NULL==id) return null; Node newnode=(Node)m_nodes.elementAt(id); String newname=newnode.getLocalName(); if (null == newname) { // XSLT treats PIs, and possibly other things, as having QNames. String qname = newnode.getNodeName(); if('#'==qname.charAt(0)) { // Match old default for this function // This conversion may or may not be necessary newname=""; } else { int index = qname.indexOf(':'); newname = (index < 0) ? qname : qname.substring(index + 1); } } return newname; } else { String name; short type = getNodeType(nodeHandle); switch (type) { case DTM.ATTRIBUTE_NODE : case DTM.ELEMENT_NODE : case DTM.ENTITY_REFERENCE_NODE : case DTM.NAMESPACE_NODE : case DTM.PROCESSING_INSTRUCTION_NODE : { Node node = getNode(nodeHandle); // assume not null. name = node.getLocalName(); if (null == name) { String qname = node.getNodeName(); int index = qname.indexOf(':'); name = (index < 0) ? qname : qname.substring(index + 1); } } break; default : name = ""; } return name; } }
Given a node handle, return its XPath-style localname. (As defined in Namespaces, this is the portion of the name after any colon character). @param nodeHandle the id of the node. @return String Local name of this node.
DOM2DTM::getLocalName
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getPrefix(int nodeHandle) { String prefix; short type = getNodeType(nodeHandle); switch (type) { case DTM.NAMESPACE_NODE : { Node node = getNode(nodeHandle); // assume not null. String qname = node.getNodeName(); int index = qname.indexOf(':'); prefix = (index < 0) ? "" : qname.substring(index + 1); } break; case DTM.ATTRIBUTE_NODE : case DTM.ELEMENT_NODE : { Node node = getNode(nodeHandle); // assume not null. String qname = node.getNodeName(); int index = qname.indexOf(':'); prefix = (index < 0) ? "" : qname.substring(0, index); } break; default : prefix = ""; } return prefix; }
Given a namespace handle, return the prefix that the namespace decl is mapping. Given a node handle, return the prefix used to map to the namespace. <p> %REVIEW% Are you sure you want "" for no prefix? </p> <p> %REVIEW-COMMENT% I think so... not totally sure. -sb </p> @param nodeHandle the id of the node. @return String prefix of this node's name, or "" if no explicit namespace prefix was given.
DOM2DTM::getPrefix
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getNamespaceURI(int nodeHandle) { if(JJK_NEWCODE) { int id=makeNodeIdentity(nodeHandle); if(id==NULL) return null; Node node=(Node)m_nodes.elementAt(id); return node.getNamespaceURI(); } else { String nsuri; short type = getNodeType(nodeHandle); switch (type) { case DTM.ATTRIBUTE_NODE : case DTM.ELEMENT_NODE : case DTM.ENTITY_REFERENCE_NODE : case DTM.NAMESPACE_NODE : case DTM.PROCESSING_INSTRUCTION_NODE : { Node node = getNode(nodeHandle); // assume not null. nsuri = node.getNamespaceURI(); // %TBD% Handle DOM1? } break; default : nsuri = null; } return nsuri; } }
Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.) <p>%REVIEW% Null or ""? -sb</p> @param nodeHandle the id of the node. @return String URI value of this node's namespace, or null if no namespace was resolved.
DOM2DTM::getNamespaceURI
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
private Node logicalNextDOMTextNode(Node n) { Node p=n.getNextSibling(); if(p==null) { // Walk out of any EntityReferenceNodes that ended with text for(n=n.getParentNode(); n!=null && ENTITY_REFERENCE_NODE == n.getNodeType(); n=n.getParentNode()) { p=n.getNextSibling(); if(p!=null) break; } } n=p; while(n!=null && ENTITY_REFERENCE_NODE == n.getNodeType()) { // Walk into any EntityReferenceNodes that start with text if(n.hasChildNodes()) n=n.getFirstChild(); else n=n.getNextSibling(); } if(n!=null) { // Found a logical next sibling. Is it text? int ntype=n.getNodeType(); if(TEXT_NODE != ntype && CDATA_SECTION_NODE != ntype) n=null; } return n; }
Utility function: Given a DOM Text node, determine whether it is logically followed by another Text or CDATASection node. This may involve traversing into Entity References. %REVIEW% DOM Level 3 is expected to add functionality which may allow us to retire this.
DOM2DTM::logicalNextDOMTextNode
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getNodeValue(int nodeHandle) { // The _type(nodeHandle) call was taking the lion's share of our // time, and was wrong anyway since it wasn't coverting handle to // identity. Inlined it. int type = _exptype(makeNodeIdentity(nodeHandle)); type=(NULL != type) ? getNodeType(nodeHandle) : NULL; if(TEXT_NODE!=type && CDATA_SECTION_NODE!=type) return getNode(nodeHandle).getNodeValue(); // If this is a DTM text node, it may be made of multiple DOM text // nodes -- including navigating into Entity References. DOM2DTM // records the first node in the sequence and requires that we // pick up the others when we retrieve the DTM node's value. // // %REVIEW% DOM Level 3 is expected to add a "whole text" // retrieval method which performs this function for us. Node node = getNode(nodeHandle); Node n=logicalNextDOMTextNode(node); if(n==null) return node.getNodeValue(); FastStringBuffer buf = StringBufferPool.get(); buf.append(node.getNodeValue()); while(n!=null) { buf.append(n.getNodeValue()); n=logicalNextDOMTextNode(n); } String s = (buf.length() > 0) ? buf.toString() : ""; StringBufferPool.free(buf); return s; }
Given a node handle, return its node value. This is mostly as defined by the DOM, but may ignore some conveniences. <p> @param nodeHandle The node id. @return String Value of this node, or null if not meaningful for this node type.
DOM2DTM::getNodeValue
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getDocumentTypeDeclarationSystemIdentifier() { Document doc; if (m_root.getNodeType() == Node.DOCUMENT_NODE) doc = (Document) m_root; else doc = m_root.getOwnerDocument(); if (null != doc) { DocumentType dtd = doc.getDoctype(); if (null != dtd) { return dtd.getSystemId(); } } return null; }
A document type declaration information item has the following properties: 1. [system identifier] The system identifier of the external subset, if it exists. Otherwise this property has no value. @return the system identifier String object, or null if there is none.
DOM2DTM::getDocumentTypeDeclarationSystemIdentifier
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getDocumentTypeDeclarationPublicIdentifier() { Document doc; if (m_root.getNodeType() == Node.DOCUMENT_NODE) doc = (Document) m_root; else doc = m_root.getOwnerDocument(); if (null != doc) { DocumentType dtd = doc.getDoctype(); if (null != dtd) { return dtd.getPublicId(); } } return null; }
Return the public identifier of the external subset, normalized as described in 4.2.2 External Entities [XML]. If there is no external subset or if it has no public identifier, this property has no value. @return the public identifier String object, or null if there is none.
DOM2DTM::getDocumentTypeDeclarationPublicIdentifier
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public int getElementById(String elementId) { Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE) ? (Document) m_root : m_root.getOwnerDocument(); if(null != doc) { Node elem = doc.getElementById(elementId); if(null != elem) { int elemHandle = getHandleFromNode(elem); if(DTM.NULL == elemHandle) { int identity = m_nodes.size()-1; while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { Node node = getNode(identity); if(node == elem) { elemHandle = getHandleFromNode(elem); break; } } } return elemHandle; } } return DTM.NULL; }
Returns the <code>Element</code> whose <code>ID</code> is given by <code>elementId</code>. If no such element exists, returns <code>DTM.NULL</code>. Behavior is not defined if more than one element has this <code>ID</code>. Attributes (including those with the name "ID") are not of type ID unless so defined by DTD/Schema information available to the DTM implementation. Implementations that do not know whether attributes are of type ID or not are expected to return <code>DTM.NULL</code>. <p>%REVIEW% Presumably IDs are still scoped to a single document, and this operation searches only within a single document, right? Wouldn't want collisions between DTMs in the same process.</p> @param elementId The unique <code>id</code> value for an element. @return The handle of the matching element.
DOM2DTM::getElementById
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public String getUnparsedEntityURI(String name) { String url = ""; Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE) ? (Document) m_root : m_root.getOwnerDocument(); if (null != doc) { DocumentType doctype = doc.getDoctype(); if (null != doctype) { NamedNodeMap entities = doctype.getEntities(); if(null == entities) return url; Entity entity = (Entity) entities.getNamedItem(name); if(null == entity) return url; String notationName = entity.getNotationName(); if (null != notationName) // then it's unparsed { // The draft says: "The XSLT processor may use the public // identifier to generate a URI for the entity instead of the URI // specified in the system identifier. If the XSLT processor does // not use the public identifier to generate the URI, it must use // the system identifier; if the system identifier is a relative // URI, it must be resolved into an absolute URI using the URI of // the resource containing the entity declaration as the base // URI [RFC2396]." // So I'm falling a bit short here. url = entity.getSystemId(); if (null == url) { url = entity.getPublicId(); } else { // This should be resolved to an absolute URL, but that's hard // to do from here. } } } } return url; }
The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]). It returns the empty string if there is no such entity. <p> XML processors may choose to use the System Identifier (if one is provided) to resolve the entity, rather than the URI in the Public Identifier. The details are dependent on the processor, and we would have to support some form of plug-in resolver to handle this properly. Currently, we simply return the System Identifier if present, and hope that it a usable URI or that our caller can map it to one. TODO: Resolve Public Identifiers... or consider changing function name. <p> If we find a relative URI reference, XML expects it to be resolved in terms of the base URI of the document. The DOM doesn't do that for us, and it isn't entirely clear whether that should be done here; currently that's pushed up to a higher level of our application. (Note that DOM Level 1 didn't store the document's base URI.) TODO: Consider resolving Relative URIs. <p> (The DOM's statement that "An XML processor may choose to completely expand entities before the structure model is passed to the DOM" refers only to parsed entities, not unparsed, and hence doesn't affect this function.) @param name A string containing the Entity Name of the unparsed entity. @return String containing the URI of the Unparsed Entity, or an empty string if no such entity exists.
DOM2DTM::getUnparsedEntityURI
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public boolean isAttributeSpecified(int attributeHandle) { int type = getNodeType(attributeHandle); if (DTM.ATTRIBUTE_NODE == type) { Attr attr = (Attr)getNode(attributeHandle); return attr.getSpecified(); } return false; }
5. [specified] A flag indicating whether this attribute was actually specified in the start-tag of its element, or was defaulted from the DTD. @param attributeHandle the attribute handle @return <code>true</code> if the attribute was specified; <code>false</code> if it was defaulted.
DOM2DTM::isAttributeSpecified
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public void setIncrementalSAXSource(IncrementalSAXSource source) { }
Bind an IncrementalSAXSource to this DTM. NOT RELEVANT for DOM2DTM, since we're wrapped around an existing DOM. @param source The IncrementalSAXSource that we want to recieve events from on demand.
DOM2DTM::setIncrementalSAXSource
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.ContentHandler getContentHandler() { return null; }
getContentHandler returns "our SAX builder" -- the thing that someone else should send SAX events to in order to extend this DTM model. @return null if this model doesn't respond to SAX events, "this" if the DTM object has a built-in SAX ContentHandler, the IncrmentalSAXSource if we're bound to one and should receive the SAX stream via it for incremental build purposes... *
DOM2DTM::getContentHandler
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.ext.LexicalHandler getLexicalHandler() { return null; }
Return this DTM's lexical handler. %REVIEW% Should this return null if constrution already done/begun? @return null if this model doesn't respond to lexical SAX events, "this" if the DTM object has a built-in SAX ContentHandler, the IncrementalSAXSource if we're bound to one and should receive the SAX stream via it for incremental build purposes...
DOM2DTM::getLexicalHandler
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.EntityResolver getEntityResolver() { return null; }
Return this DTM's EntityResolver. @return null if this model doesn't respond to SAX entity ref events.
DOM2DTM::getEntityResolver
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.DTDHandler getDTDHandler() { return null; }
Return this DTM's DTDHandler. @return null if this model doesn't respond to SAX dtd events.
DOM2DTM::getDTDHandler
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.ErrorHandler getErrorHandler() { return null; }
Return this DTM's ErrorHandler. @return null if this model doesn't respond to SAX error events.
DOM2DTM::getErrorHandler
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public org.xml.sax.ext.DeclHandler getDeclHandler() { return null; }
Return this DTM's DeclHandler. @return null if this model doesn't respond to SAX Decl events.
DOM2DTM::getDeclHandler
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public boolean needsTwoThreads() { return false; }
@return true iff we're building this model incrementally (eg we're partnered with a IncrementalSAXSource) and thus require that the transformation and the parse run simultaneously. Guidance to the DTMManager. *
DOM2DTM::needsTwoThreads
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
private static boolean isSpace(char ch) { return XMLCharacterRecognizer.isWhiteSpace(ch); // Take the easy way out for now. }
Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition of whitespace. Refer to <A href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S"> the definition of <CODE>S</CODE></A> for details. @param ch Character to check as XML whitespace. @return =true if <var>ch</var> is XML whitespace; otherwise =false.
DOM2DTM::isSpace
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public void dispatchCharactersEvents( int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException { if(normalize) { XMLString str = getStringValue(nodeHandle); str = str.fixWhiteSpace(true, true, false); str.dispatchCharactersEvents(ch); } else { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); dispatchNodeData(node, ch, 0); // Text coalition -- a DTM text node may represent multiple // DOM nodes. if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { while( null != (node=logicalNextDOMTextNode(node)) ) { dispatchNodeData(node, ch, 0); } } } }
Directly call the characters method on the passed ContentHandler for the string-value of the given node (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value). Multiple calls to the ContentHandler's characters methods may well occur for a single call to this method. @param nodeHandle The node ID. @param ch A non-null reference to a ContentHandler. @throws org.xml.sax.SAXException
DOM2DTM::dispatchCharactersEvents
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
protected static void dispatchNodeData(Node node, org.xml.sax.ContentHandler ch, int depth) throws org.xml.sax.SAXException { switch (node.getNodeType()) { case Node.DOCUMENT_FRAGMENT_NODE : case Node.DOCUMENT_NODE : case Node.ELEMENT_NODE : { for (Node child = node.getFirstChild(); null != child; child = child.getNextSibling()) { dispatchNodeData(child, ch, depth+1); } } break; case Node.PROCESSING_INSTRUCTION_NODE : // %REVIEW% case Node.COMMENT_NODE : if(0 != depth) break; // NOTE: Because this operation works in the DOM space, it does _not_ attempt // to perform Text Coalition. That should only be done in DTM space. case Node.TEXT_NODE : case Node.CDATA_SECTION_NODE : case Node.ATTRIBUTE_NODE : String str = node.getNodeValue(); if(ch instanceof CharacterNodeHandler) { ((CharacterNodeHandler)ch).characters(node); } else { ch.characters(str.toCharArray(), 0, str.length()); } break; // /* case Node.PROCESSING_INSTRUCTION_NODE : // // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING); // break; */ default : // ignore break; } }
Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object. Note that attributes are not considered part of the content of an element. <p> There are open questions regarding whitespace stripping. Currently we make no special effort in that regard, since the standard DOM doesn't yet provide DTD-based information to distinguish whitespace-in-element-context from genuine #PCDATA. Note that we should probably also consider xml:space if/when we address this. DOM Level 3 may solve the problem for us. <p> %REVIEW% Note that as a DOM-level operation, it can be argued that this routine _shouldn't_ perform any processing beyond what the DOM already does, and that whitespace stripping and so on belong at the DTM level. If you want a stripped DOM view, wrap DTM2DOM around DOM2DTM. @param node Node whose subtree is to be walked, gathering the contents of all Text or CDATASection nodes.
DOM2DTM::dispatchNodeData
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) throws org.xml.sax.SAXException { TreeWalker treeWalker = m_walker; ContentHandler prevCH = treeWalker.getContentHandler(); if(null != prevCH) { treeWalker = new TreeWalker(null); } treeWalker.setContentHandler(ch); try { Node node = getNode(nodeHandle); treeWalker.traverseFragment(node); } finally { treeWalker.setContentHandler(null); } }
Directly create SAX parser events from a subtree. @param nodeHandle The node ID. @param ch A non-null reference to a ContentHandler. @throws org.xml.sax.SAXException
DOM2DTM::dispatchToEvents
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public void setProperty(String property, Object value) { }
For the moment all the run time properties are ignored by this class. @param property a <code>String</code> value @param value an <code>Object</code> value
DOM2DTM::setProperty
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public SourceLocator getSourceLocatorFor(int node) { return null; }
No source information is available for DOM2DTM, so return <code>null</code> here. @param node an <code>int</code> value @return null
DOM2DTM::getSourceLocatorFor
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
MIT
public CopticChronology() { }
Public Constructor to be instantiated by the ServiceLoader
CopticChronology::CopticChronology
java
Reginer/aosp-android-jar
android-34/src/tck/java/time/chrono/CopticChronology.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/tck/java/time/chrono/CopticChronology.java
MIT
private Object readResolve() { return INSTANCE; }
Resolve singleton. @return the singleton instance, not null
CopticChronology::readResolve
java
Reginer/aosp-android-jar
android-34/src/tck/java/time/chrono/CopticChronology.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/tck/java/time/chrono/CopticChronology.java
MIT
public static Bundle createDontSendToRestrictedAppsBundle(@Nullable Bundle bundle) { final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setDontSendToRestrictedApps(true); if (bundle == null) { return options.toBundle(); } bundle.putAll(options.toBundle()); return bundle; }
Creates a Bundle that can be used to restrict the background PendingIntents. @param bundle when provided, will merge the extra options to restrict background PendingIntent into the existing bundle. @return the created Bundle.
PendingIntentUtils::createDontSendToRestrictedAppsBundle
java
Reginer/aosp-android-jar
android-34/src/com/android/server/PendingIntentUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/PendingIntentUtils.java
MIT
public static CharSequence formatElapsedTime(Context context, double millis, boolean withSeconds, boolean collapseTimeUnit) { SpannableStringBuilder sb = new SpannableStringBuilder(); int seconds = (int) Math.floor(millis / 1000); if (!withSeconds) { // Round up. seconds += 30; } int days = 0, hours = 0, minutes = 0; if (seconds >= SECONDS_PER_DAY) { days = seconds / SECONDS_PER_DAY; seconds -= days * SECONDS_PER_DAY; } if (seconds >= SECONDS_PER_HOUR) { hours = seconds / SECONDS_PER_HOUR; seconds -= hours * SECONDS_PER_HOUR; } if (seconds >= SECONDS_PER_MINUTE) { minutes = seconds / SECONDS_PER_MINUTE; seconds -= minutes * SECONDS_PER_MINUTE; } final ArrayList<Measure> measureList = new ArrayList(4); if (days > 0) { measureList.add(new Measure(days, MeasureUnit.DAY)); } if (hours > 0) { measureList.add(new Measure(hours, MeasureUnit.HOUR)); } if (minutes > 0) { measureList.add(new Measure(minutes, MeasureUnit.MINUTE)); } if (withSeconds && seconds > 0) { measureList.add(new Measure(seconds, MeasureUnit.SECOND)); } if (measureList.size() == 0) { // Everything addable was zero, so nothing was added. We add a zero. measureList.add(new Measure(0, withSeconds ? MeasureUnit.SECOND : MeasureUnit.MINUTE)); } if (collapseTimeUnit && measureList.size() > LIMITED_TIME_UNIT_COUNT) { // Limit the output to top 2 time unit. measureList.subList(LIMITED_TIME_UNIT_COUNT, measureList.size()).clear(); } final Measure[] measureArray = measureList.toArray(new Measure[measureList.size()]); final Locale locale = context.getResources().getConfiguration().locale; final MeasureFormat measureFormat = MeasureFormat.getInstance( locale, FormatWidth.SHORT); sb.append(measureFormat.formatMeasures(measureArray)); if (measureArray.length == 1 && MeasureUnit.MINUTE.equals(measureArray[0].getUnit())) { // Add ttsSpan if it only have minute value, because it will be read as "meters" final TtsSpan ttsSpan = new TtsSpan.MeasureBuilder().setNumber(minutes) .setUnit("minute").build(); sb.setSpan(ttsSpan, 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } return sb; }
Returns elapsed time for the given millis, in the following format: 2 days, 5 hr, 40 min, 29 sec @param context the application context @param millis the elapsed time in milli seconds @param withSeconds include seconds? @param collapseTimeUnit limit the output to top 2 time unit e.g 2 days, 5 hr, 40 min, 29 sec will convert to 2 days, 5 hr @return the formatted elapsed time
StringUtil::formatElapsedTime
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/utils/StringUtil.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/utils/StringUtil.java
MIT
public static CharSequence formatRelativeTime(Context context, double millis, boolean withSeconds, RelativeDateTimeFormatter.Style formatStyle) { final int seconds = (int) Math.floor(millis / 1000); final RelativeUnit unit; final int value; if (withSeconds && seconds < 2 * SECONDS_PER_MINUTE) { return context.getResources().getString(R.string.time_unit_just_now); } else if (seconds < 2 * SECONDS_PER_HOUR) { unit = RelativeUnit.MINUTES; value = (seconds + SECONDS_PER_MINUTE / 2) / SECONDS_PER_MINUTE; } else if (seconds < 2 * SECONDS_PER_DAY) { unit = RelativeUnit.HOURS; value = (seconds + SECONDS_PER_HOUR / 2) / SECONDS_PER_HOUR; } else { unit = RelativeUnit.DAYS; value = (seconds + SECONDS_PER_DAY / 2) / SECONDS_PER_DAY; } final Locale locale = context.getResources().getConfiguration().locale; final RelativeDateTimeFormatter formatter = RelativeDateTimeFormatter.getInstance( ULocale.forLocale(locale), null /* default NumberFormat */, formatStyle, android.icu.text.DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE); return formatter.format(value, RelativeDateTimeFormatter.Direction.LAST, unit); }
Returns relative time for the given millis in the past with different format style. In a short format such as "2 days ago", "5 hr. ago", "40 min. ago", or "29 sec. ago". In a long format such as "2 days ago", "5 hours ago", "40 minutes ago" or "29 seconds ago". <p>The unit is chosen to have good information value while only using one unit. So 27 hours and 50 minutes would be formatted as "28 hr. ago", while 50 hours would be formatted as "2 days ago". @param context the application context @param millis the elapsed time in milli seconds @param withSeconds include seconds? @param formatStyle format style @return the formatted elapsed time
StringUtil::formatRelativeTime
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/utils/StringUtil.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/utils/StringUtil.java
MIT
public static String getIcuPluralsString(Context context, int count, int resId) { MessageFormat msgFormat = new MessageFormat(context.getResources().getString(resId), Locale.getDefault()); Map<String, Object> arguments = new HashMap<>(); arguments.put("count", count); return msgFormat.format(arguments); }
Get ICU plural string without additional arguments @param context Context used to get the string @param count The number used to get the correct string for the current language's plural rules. @param resId Resource id of the string @return Formatted plural string
StringUtil::getIcuPluralsString
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/utils/StringUtil.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/utils/StringUtil.java
MIT
public static String getIcuPluralsString(Context context, Map<String, Object> args, int resId) { MessageFormat msgFormat = new MessageFormat(context.getResources().getString(resId), Locale.getDefault()); return msgFormat.format(args); }
Get ICU plural string with additional arguments @param context Context used to get the string @param args String arguments @param resId Resource id of the string @return Formatted plural string
StringUtil::getIcuPluralsString
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/utils/StringUtil.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/utils/StringUtil.java
MIT
public ResponderLocation(byte[] lciBuffer, byte[] lcrBuffer) { boolean isLciIeValid = false; boolean isLcrIeValid = false; setLciSubelementDefaults(); setZaxisSubelementDefaults(); setUsageSubelementDefaults(); setBssidListSubelementDefaults(); setCivicLocationSubelementDefaults(); setMapImageSubelementDefaults(); if (lciBuffer != null && lciBuffer.length > LEAD_LCI_ELEMENT_BYTES.length) { isLciIeValid = parseInformationElementBuffer( MEASUREMENT_TYPE_LCI, lciBuffer, LEAD_LCI_ELEMENT_BYTES); } if (lcrBuffer != null && lcrBuffer.length > LEAD_LCR_ELEMENT_BYTES.length) { isLcrIeValid = parseInformationElementBuffer( MEASUREMENT_TYPE_LCR, lcrBuffer, LEAD_LCR_ELEMENT_BYTES); } boolean isLciValid = isLciIeValid && mIsUsageValid && (mIsLciValid || mIsZValid || mIsBssidListValid); boolean isLcrValid = isLcrIeValid && mIsUsageValid && (mIsLocationCivicValid || mIsMapImageValid); mIsValid = isLciValid || isLcrValid; if (!mIsValid) { setLciSubelementDefaults(); setZaxisSubelementDefaults(); setCivicLocationSubelementDefaults(); setMapImageSubelementDefaults(); } }
Constructor @param lciBuffer the bytes received in the LCI Measurement Report Information Element @param lcrBuffer the bytes received in the LCR Measurement Report Information Element @hide
ResponderLocation::ResponderLocation
java
Reginer/aosp-android-jar
android-32/src/android/net/wifi/rtt/ResponderLocation.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/net/wifi/rtt/ResponderLocation.java
MIT
public static AccountManagerService getSingleton() { return sThis.get(); }
This should only be called by system code. One should only call this after the service has started. @return a reference to the AccountManagerService instance @hide
UserAccounts::getSingleton
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private Map<Account, Integer> getAccountsAndVisibilityForPackage(String packageName, List<String> accountTypes, Integer callingUid, UserAccounts accounts) { if (!packageExistsForUser(packageName, accounts.userId)) { Log.d(TAG, "Package not found " + packageName); return new LinkedHashMap<>(); } Map<Account, Integer> result = new LinkedHashMap<>(); for (String accountType : accountTypes) { synchronized (accounts.dbLock) { synchronized (accounts.cacheLock) { final Account[] accountsOfType = accounts.accountCache.get(accountType); if (accountsOfType != null) { for (Account account : accountsOfType) { result.put(account, resolveAccountVisibility(account, packageName, accounts)); } } } } } return filterSharedAccounts(accounts, result, callingUid, packageName); }
This should only be called by system code. One should only call this after the service has started. @return a reference to the AccountManagerService instance @hide public static AccountManagerService getSingleton() { return sThis.get(); } public AccountManagerService(Injector injector) { mInjector = injector; mContext = injector.getContext(); mPackageManager = mContext.getPackageManager(); mAppOpsManager = mContext.getSystemService(AppOpsManager.class); mHandler = new MessageHandler(injector.getMessageHandlerLooper()); mAuthenticatorCache = mInjector.getAccountAuthenticatorCache(); mAuthenticatorCache.setListener(this, mHandler); sThis.set(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context1, Intent intent) { // Don't delete accounts when updating a authenticator's // package. if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { /* Purging data requires file io, don't block the main thread. This is probably less than ideal because we are introducing a race condition where old grants could be exercised until they are purged. But that race condition existed anyway with the broadcast receiver. Ideally, we would completely clear the cache, purge data from the database, and then rebuild the cache. All under the cache lock. But that change is too large at this point. final String removedPackageName = intent.getData().getSchemeSpecificPart(); Runnable purgingRunnable = new Runnable() { @Override public void run() { purgeOldGrantsAll(); // Notify authenticator about removed app? removeVisibilityValuesForPackage(removedPackageName); } }; mHandler.post(purgingRunnable); } } }, intentFilter); injector.addLocalService(new AccountManagerInternalImpl()); IntentFilter userFilter = new IntentFilter(); userFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiverAsUser(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_USER_REMOVED.equals(action)) { int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); if (userId < 1) return; Slog.i(TAG, "User " + userId + " removed"); purgeUserData(userId); } } }, UserHandle.ALL, userFilter, null, null); // Need to cancel account request notifications if the update/install can access the account new PackageMonitor() { @Override public void onPackageAdded(String packageName, int uid) { // Called on a handler, and running as the system cancelAccountAccessRequestNotificationIfNeeded(uid, true); } @Override public void onPackageUpdateFinished(String packageName, int uid) { // Called on a handler, and running as the system cancelAccountAccessRequestNotificationIfNeeded(uid, true); } }.register(mContext, mHandler.getLooper(), UserHandle.ALL, true); // Cancel account request notification if an app op was preventing the account access mAppOpsManager.startWatchingMode(AppOpsManager.OP_GET_ACCOUNTS, null, new AppOpsManager.OnOpChangedInternalListener() { @Override public void onOpChanged(int op, String packageName) { try { final int userId = ActivityManager.getCurrentUser(); final int uid = mPackageManager.getPackageUidAsUser(packageName, userId); final int mode = mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_GET_ACCOUNTS, uid, packageName); if (mode == AppOpsManager.MODE_ALLOWED) { final long identity = Binder.clearCallingIdentity(); try { cancelAccountAccessRequestNotificationIfNeeded(packageName, uid, true); } finally { Binder.restoreCallingIdentity(identity); } } } catch (NameNotFoundException e) { /* ignore } } }); // Cancel account request notification if a permission was preventing the account access mPackageManager.addOnPermissionsChangeListener( (int uid) -> { // Permission changes cause requires updating accounts cache. AccountManager.invalidateLocalAccountsDataCaches(); Account[] accounts = null; String[] packageNames = mPackageManager.getPackagesForUid(uid); if (packageNames != null) { final int userId = UserHandle.getUserId(uid); final long identity = Binder.clearCallingIdentity(); try { for (String packageName : packageNames) { // if app asked for permission we need to cancel notification even // for O+ applications. if (mPackageManager.checkPermission( Manifest.permission.GET_ACCOUNTS, packageName) != PackageManager.PERMISSION_GRANTED) { continue; } if (accounts == null) { accounts = getAccountsAsUser(null, userId, "android"); if (ArrayUtils.isEmpty(accounts)) { return; } } for (Account account : accounts) { cancelAccountAccessRequestNotificationIfNeeded( account, uid, packageName, true); } } } finally { Binder.restoreCallingIdentity(identity); } } }); } boolean getBindInstantServiceAllowed(int userId) { return mAuthenticatorCache.getBindInstantServiceAllowed(userId); } void setBindInstantServiceAllowed(int userId, boolean allowed) { mAuthenticatorCache.setBindInstantServiceAllowed(userId, allowed); } private void cancelAccountAccessRequestNotificationIfNeeded(int uid, boolean checkAccess) { Account[] accounts = getAccountsAsUser(null, UserHandle.getUserId(uid), "android"); for (Account account : accounts) { cancelAccountAccessRequestNotificationIfNeeded(account, uid, checkAccess); } } private void cancelAccountAccessRequestNotificationIfNeeded(String packageName, int uid, boolean checkAccess) { Account[] accounts = getAccountsAsUser(null, UserHandle.getUserId(uid), "android"); for (Account account : accounts) { cancelAccountAccessRequestNotificationIfNeeded(account, uid, packageName, checkAccess); } } private void cancelAccountAccessRequestNotificationIfNeeded(Account account, int uid, boolean checkAccess) { String[] packageNames = mPackageManager.getPackagesForUid(uid); if (packageNames != null) { for (String packageName : packageNames) { cancelAccountAccessRequestNotificationIfNeeded(account, uid, packageName, checkAccess); } } } private void cancelAccountAccessRequestNotificationIfNeeded(Account account, int uid, String packageName, boolean checkAccess) { if (!checkAccess || hasAccountAccess(account, packageName, UserHandle.getUserHandleForUid(uid))) { cancelNotification(getCredentialPermissionNotificationId(account, AccountManager.ACCOUNT_ACCESS_TOKEN_TYPE, uid), UserHandle.getUserHandleForUid(uid)); } } @Override public boolean addAccountExplicitlyWithVisibility(Account account, String password, Bundle extras, Map packageToVisibility, String opPackageName) { Bundle.setDefusable(extras, true); int callingUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "addAccountExplicitly: " + account + ", caller's uid " + callingUid + ", pid " + Binder.getCallingPid()); } Objects.requireNonNull(account, "account cannot be null"); if (!isAccountManagedByCaller(account.type, callingUid, userId)) { String msg = String.format("uid %s cannot explicitly add accounts of type: %s", callingUid, account.type); throw new SecurityException(msg); } /* Child users are not allowed to add accounts. Only the accounts that are shared by the parent profile can be added to child profile. TODO: Only allow accounts that were shared to be added by a limited user. // fails if the account already exists final long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(userId); return addAccountInternal(accounts, account, password, extras, callingUid, (Map<String, Integer>) packageToVisibility, opPackageName); } finally { restoreCallingIdentity(identityToken); } } @Override public Map<Account, Integer> getAccountsAndVisibilityForPackage(String packageName, String accountType) { int callingUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); boolean isSystemUid = UserHandle.isSameApp(callingUid, Process.SYSTEM_UID); List<String> managedTypes = getTypesForCaller(callingUid, userId, isSystemUid); if ((accountType != null && !managedTypes.contains(accountType)) || (accountType == null && !isSystemUid)) { throw new SecurityException( "getAccountsAndVisibilityForPackage() called from unauthorized uid " + callingUid + " with packageName=" + packageName); } if (accountType != null) { managedTypes = new ArrayList<String>(); managedTypes.add(accountType); } final long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(userId); return getAccountsAndVisibilityForPackage(packageName, managedTypes, callingUid, accounts); } finally { restoreCallingIdentity(identityToken); } } /* accountTypes may not be null
UserAccounts::getAccountsAndVisibilityForPackage
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private @NonNull Map<String, Integer> getPackagesAndVisibilityForAccountLocked(Account account, UserAccounts accounts) { Map<String, Integer> accountVisibility = accounts.visibilityCache.get(account); if (accountVisibility == null) { Log.d(TAG, "Visibility was not initialized"); accountVisibility = new HashMap<>(); accounts.visibilityCache.put(account, accountVisibility); AccountManager.invalidateLocalAccountsDataCaches(); } return accountVisibility; }
Returns Map with all package names and visibility values for given account. The method and returned map must be guarded by accounts.cacheLock @param account Account to get visibility values. @param accounts UserAccount that currently hosts the account and application @return Map with cache for package names to visibility.
UserAccounts::getPackagesAndVisibilityForAccountLocked
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private int getAccountVisibilityFromCache(Account account, String packageName, UserAccounts accounts) { synchronized (accounts.cacheLock) { Map<String, Integer> accountVisibility = getPackagesAndVisibilityForAccountLocked(account, accounts); Integer visibility = accountVisibility.get(packageName); return visibility != null ? visibility : AccountManager.VISIBILITY_UNDEFINED; } }
Method returns visibility for given account and package name. @param account The account to check visibility. @param packageName Package name to check visibility. @param accounts UserAccount that currently hosts the account and application @return Visibility value, AccountManager.VISIBILITY_UNDEFINED if no value was stored.
UserAccounts::getAccountVisibilityFromCache
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private Integer resolveAccountVisibility(Account account, @NonNull String packageName, UserAccounts accounts) { Objects.requireNonNull(packageName, "packageName cannot be null"); int uid = -1; try { final long identityToken = clearCallingIdentity(); try { uid = mPackageManager.getPackageUidAsUser(packageName, accounts.userId); } finally { restoreCallingIdentity(identityToken); } } catch (NameNotFoundException e) { Log.d(TAG, "Package not found " + e.getMessage()); return AccountManager.VISIBILITY_NOT_VISIBLE; } // System visibility can not be restricted. if (UserHandle.isSameApp(uid, Process.SYSTEM_UID)) { return AccountManager.VISIBILITY_VISIBLE; } int signatureCheckResult = checkPackageSignature(account.type, uid, accounts.userId); // Authenticator can not restrict visibility to itself. if (signatureCheckResult == SIGNATURE_CHECK_UID_MATCH) { return AccountManager.VISIBILITY_VISIBLE; // Authenticator can always see the account } // Return stored value if it was set. int visibility = getAccountVisibilityFromCache(account, packageName, accounts); if (AccountManager.VISIBILITY_UNDEFINED != visibility) { return visibility; } boolean isPrivileged = isPermittedForPackage(packageName, accounts.userId, Manifest.permission.GET_ACCOUNTS_PRIVILEGED); // Device/Profile owner gets visibility by default. if (isProfileOwner(uid)) { return AccountManager.VISIBILITY_VISIBLE; } boolean preO = isPreOApplication(packageName); if ((signatureCheckResult != SIGNATURE_CHECK_MISMATCH) || (preO && checkGetAccountsPermission(packageName, accounts.userId)) || (checkReadContactsPermission(packageName, accounts.userId) && accountTypeManagesContacts(account.type, accounts.userId)) || isPrivileged) { // Use legacy for preO apps with GET_ACCOUNTS permission or pre/postO with signature // match. visibility = getAccountVisibilityFromCache(account, AccountManager.PACKAGE_NAME_KEY_LEGACY_VISIBLE, accounts); if (AccountManager.VISIBILITY_UNDEFINED == visibility) { visibility = AccountManager.VISIBILITY_USER_MANAGED_VISIBLE; } } else { visibility = getAccountVisibilityFromCache(account, AccountManager.PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE, accounts); if (AccountManager.VISIBILITY_UNDEFINED == visibility) { visibility = AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE; } } return visibility; }
Method which handles default values for Account visibility. @param account The account to check visibility. @param packageName Package name to check visibility @param accounts UserAccount that currently hosts the account and application @return Visibility value, the method never returns AccountManager.VISIBILITY_UNDEFINED
UserAccounts::resolveAccountVisibility
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private boolean isPreOApplication(String packageName) { try { final long identityToken = clearCallingIdentity(); ApplicationInfo applicationInfo; try { applicationInfo = mPackageManager.getApplicationInfo(packageName, 0); } finally { restoreCallingIdentity(identityToken); } if (applicationInfo != null) { int version = applicationInfo.targetSdkVersion; return version < android.os.Build.VERSION_CODES.O; } return true; } catch (NameNotFoundException e) { Log.d(TAG, "Package not found " + e.getMessage()); return true; } }
Checks targetSdk for a package; @param packageName Package name @return True if package's target SDK is below {@link android.os.Build.VERSION_CODES#O}, or undefined
UserAccounts::isPreOApplication
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private boolean setAccountVisibility(Account account, String packageName, int newVisibility, boolean notify, UserAccounts accounts) { synchronized (accounts.dbLock) { synchronized (accounts.cacheLock) { Map<String, Integer> packagesToVisibility; List<String> accountRemovedReceivers; if (notify) { if (isSpecialPackageKey(packageName)) { packagesToVisibility = getRequestingPackages(account, accounts); accountRemovedReceivers = getAccountRemovedReceivers(account, accounts); } else { if (!packageExistsForUser(packageName, accounts.userId)) { return false; // package is not installed. } packagesToVisibility = new HashMap<>(); packagesToVisibility.put(packageName, resolveAccountVisibility(account, packageName, accounts)); accountRemovedReceivers = new ArrayList<>(); if (shouldNotifyPackageOnAccountRemoval(account, packageName, accounts)) { accountRemovedReceivers.add(packageName); } } } else { // Notifications will not be send - only used during add account. if (!isSpecialPackageKey(packageName) && !packageExistsForUser(packageName, accounts.userId)) { // package is not installed and not meta value. return false; } packagesToVisibility = Collections.emptyMap(); accountRemovedReceivers = Collections.emptyList(); } if (!updateAccountVisibilityLocked(account, packageName, newVisibility, accounts)) { return false; } if (notify) { for (Entry<String, Integer> packageToVisibility : packagesToVisibility .entrySet()) { int oldVisibility = packageToVisibility.getValue(); int currentVisibility = resolveAccountVisibility(account, packageName, accounts); if (isVisible(oldVisibility) != isVisible(currentVisibility)) { notifyPackage(packageToVisibility.getKey(), accounts); } } for (String packageNameToNotify : accountRemovedReceivers) { sendAccountRemovedBroadcast(account, packageNameToNotify, accounts.userId); } sendAccountsChangedBroadcast(accounts.userId); } return true; } } }
Updates visibility for given account name and package. @param account Account to update visibility. @param packageName Package name for which visibility is updated. @param newVisibility New visibility calue @param notify if the flag is set applications will get notification about visibility change @param accounts UserAccount that currently hosts the account and application @return True if account visibility was changed.
UserAccounts::setAccountVisibility
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private void notifyPackage(String packageName, UserAccounts accounts) { Intent intent = new Intent(AccountManager.ACTION_VISIBLE_ACCOUNTS_CHANGED); intent.setPackage(packageName); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mContext.sendBroadcastAsUser(intent, new UserHandle(accounts.userId)); }
Sends a direct intent to a package, notifying it of account visibility change. @param packageName to send Account to @param accounts UserAccount that currently hosts the account
UserAccounts::notifyPackage
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private boolean isSpecialPackageKey(String packageName) { return (AccountManager.PACKAGE_NAME_KEY_LEGACY_VISIBLE.equals(packageName) || AccountManager.PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE.equals(packageName)); }
Returns true if packageName is one of special values.
UserAccounts::isSpecialPackageKey
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
public void validateAccounts(int userId) { final UserAccounts accounts = getUserAccounts(userId); // Invalidate user-specific cache to make sure we catch any // removed authenticators. validateAccountsInternal(accounts, true /* invalidateAuthenticatorCache */); }
Validate internal set of accounts against installed authenticators for given user. Clears cached authenticators before validating.
UserAccounts::validateAccounts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private void validateAccountsInternal( UserAccounts accounts, boolean invalidateAuthenticatorCache) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "validateAccountsInternal " + accounts.userId + " isCeDatabaseAttached=" + accounts.accountsDb.isCeDatabaseAttached() + " userLocked=" + mLocalUnlockedUsers.get(accounts.userId)); } if (invalidateAuthenticatorCache) { mAuthenticatorCache.invalidateCache(accounts.userId); } final HashMap<String, Integer> knownAuth = getAuthenticatorTypeAndUIDForUser( mAuthenticatorCache, accounts.userId); boolean userUnlocked = isLocalUnlockedUser(accounts.userId); synchronized (accounts.dbLock) { synchronized (accounts.cacheLock) { boolean accountDeleted = false; // Get a map of stored authenticator types to UID final AccountsDb accountsDb = accounts.accountsDb; Map<String, Integer> metaAuthUid = accountsDb.findMetaAuthUid(); // Create a list of authenticator type whose previous uid no longer exists HashSet<String> obsoleteAuthType = Sets.newHashSet(); SparseBooleanArray knownUids = null; for (Entry<String, Integer> authToUidEntry : metaAuthUid.entrySet()) { String type = authToUidEntry.getKey(); int uid = authToUidEntry.getValue(); Integer knownUid = knownAuth.get(type); if (knownUid != null && uid == knownUid) { // Remove it from the knownAuth list if it's unchanged. knownAuth.remove(type); } else { /* * The authenticator is presently not cached and should only be triggered * when we think an authenticator has been removed (or is being updated). * But we still want to check if any data with the associated uid is * around. This is an (imperfect) signal that the package may be updating. * * A side effect of this is that an authenticator sharing a uid with * multiple apps won't get its credentials wiped as long as some app with * that uid is still on the device. But I suspect that this is a rare case. * And it isn't clear to me how an attacker could really exploit that * feature. * * The upshot is that we don't have to worry about accounts getting * uninstalled while the authenticator's package is being updated. * */ if (knownUids == null) { knownUids = getUidsOfInstalledOrUpdatedPackagesAsUser(accounts.userId); } if (!knownUids.get(uid)) { // The authenticator is not presently available to the cache. And the // package no longer has a data directory (so we surmise it isn't // updating). So purge its data from the account databases. obsoleteAuthType.add(type); // And delete it from the TABLE_META accountsDb.deleteMetaByAuthTypeAndUid(type, uid); } } } // Add the newly registered authenticator to TABLE_META. If old authenticators have // been re-enabled (after being updated for example), then we just overwrite the old // values. for (Entry<String, Integer> entry : knownAuth.entrySet()) { accountsDb.insertOrReplaceMetaAuthTypeAndUid(entry.getKey(), entry.getValue()); } final Map<Long, Account> accountsMap = accountsDb.findAllDeAccounts(); try { accounts.accountCache.clear(); final HashMap<String, ArrayList<String>> accountNamesByType = new LinkedHashMap<>(); for (Entry<Long, Account> accountEntry : accountsMap.entrySet()) { final long accountId = accountEntry.getKey(); final Account account = accountEntry.getValue(); if (obsoleteAuthType.contains(account.type)) { Slog.w(TAG, "deleting account " + account.toSafeString() + " because type " + account.type + "'s registered authenticator no longer exist."); Map<String, Integer> packagesToVisibility = getRequestingPackages(account, accounts); List<String> accountRemovedReceivers = getAccountRemovedReceivers(account, accounts); accountsDb.beginTransaction(); try { accountsDb.deleteDeAccount(accountId); // Also delete from CE table if user is unlocked; if user is // currently locked the account will be removed later by // syncDeCeAccountsLocked if (userUnlocked) { accountsDb.deleteCeAccount(accountId); } accountsDb.setTransactionSuccessful(); } finally { accountsDb.endTransaction(); } accountDeleted = true; logRecord(AccountsDb.DEBUG_ACTION_AUTHENTICATOR_REMOVE, AccountsDb.TABLE_ACCOUNTS, accountId, accounts); accounts.userDataCache.remove(account); accounts.authTokenCache.remove(account); accounts.accountTokenCaches.remove(account); accounts.visibilityCache.remove(account); for (Entry<String, Integer> packageToVisibility : packagesToVisibility.entrySet()) { if (isVisible(packageToVisibility.getValue())) { notifyPackage(packageToVisibility.getKey(), accounts); } } for (String packageName : accountRemovedReceivers) { sendAccountRemovedBroadcast(account, packageName, accounts.userId); } } else { ArrayList<String> accountNames = accountNamesByType.get(account.type); if (accountNames == null) { accountNames = new ArrayList<>(); accountNamesByType.put(account.type, accountNames); } accountNames.add(account.name); } } for (Map.Entry<String, ArrayList<String>> cur : accountNamesByType.entrySet()) { final String accountType = cur.getKey(); final ArrayList<String> accountNames = cur.getValue(); final Account[] accountsForType = new Account[accountNames.size()]; for (int i = 0; i < accountsForType.length; i++) { accountsForType[i] = new Account(accountNames.get(i), accountType, UUID.randomUUID().toString()); } accounts.accountCache.put(accountType, accountsForType); } accounts.visibilityCache.putAll(accountsDb.findAllVisibilityValues()); AccountManager.invalidateLocalAccountsDataCaches(); } finally { if (accountDeleted) { sendAccountsChangedBroadcast(accounts.userId); } } } } }
Validate internal set of accounts against installed authenticators for given user. Clear cached authenticators before validating when requested.
UserAccounts::validateAccountsInternal
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private AuthenticatorDescription[] getAuthenticatorTypesInternal(int userId) { mAuthenticatorCache.updateServices(userId); Collection<AccountAuthenticatorCache.ServiceInfo<AuthenticatorDescription>> authenticatorCollection = mAuthenticatorCache.getAllServices(userId); AuthenticatorDescription[] types = new AuthenticatorDescription[authenticatorCollection.size()]; int i = 0; for (AccountAuthenticatorCache.ServiceInfo<AuthenticatorDescription> authenticator : authenticatorCollection) { types[i] = authenticator.type; i++; } return types; }
Should only be called inside of a clearCallingIdentity block.
UserAccounts::getAuthenticatorTypesInternal
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
private void addAccountToLinkedRestrictedUsers(Account account, int parentUserId) { List<UserInfo> users = getUserManager().getUsers(); for (UserInfo user : users) { if (user.isRestricted() && (parentUserId == user.restrictedProfileParentId)) { addSharedAccountAsUser(account, user.id); if (isLocalUnlockedUser(user.id)) { mHandler.sendMessage(mHandler.obtainMessage( MESSAGE_COPY_SHARED_ACCOUNT, parentUserId, user.id, account)); } } } }
Adds the account to all linked restricted users as shared accounts. If the user is currently running, then clone the account too. @param account the account to share with limited users
UserAccounts::addAccountToLinkedRestrictedUsers
java
Reginer/aosp-android-jar
android-32/src/com/android/server/accounts/AccountManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/accounts/AccountManagerService.java
MIT
public SystemSensorManager(Context context, Looper mainLooper) { synchronized (sLock) { if (!sNativeClassInited) { sNativeClassInited = true; nativeClassInit(); } } mMainLooper = mainLooper; ApplicationInfo appInfo = context.getApplicationInfo(); mTargetSdkLevel = appInfo.targetSdkVersion; mContext = context; mNativeInstance = nativeCreate(context.getOpPackageName()); mIsPackageDebuggable = (0 != (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE)); // initialize the sensor list for (int index = 0;; ++index) { Sensor sensor = new Sensor(); if (android.companion.virtual.flags.Flags.enableNativeVdm()) { if (!nativeGetDefaultDeviceSensorAtIndex(mNativeInstance, sensor, index)) break; } else { if (!nativeGetSensorAtIndex(mNativeInstance, sensor, index)) break; } mFullSensorsList.add(sensor); mHandleToSensor.put(sensor.getHandle(), sensor); } }
For apps targeting S and above, a SecurityException is thrown when they do not have HIGH_SAMPLING_RATE_SENSORS permission, run in debug mode, and request sampling rates that are faster than 200 Hz. @ChangeId @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.R) static final long CHANGE_ID_SAMPLING_RATE_SENSORS_PERMISSION = 136069189L; private static native void nativeClassInit(); private static native long nativeCreate(String opPackageName); private static native boolean nativeGetSensorAtIndex(long nativeInstance, Sensor sensor, int index); private static native boolean nativeGetDefaultDeviceSensorAtIndex(long nativeInstance, Sensor sensor, int index); private static native void nativeGetDynamicSensors(long nativeInstance, List<Sensor> list); private static native void nativeGetRuntimeSensors( long nativeInstance, int deviceId, List<Sensor> list); private static native boolean nativeIsDataInjectionEnabled(long nativeInstance); private static native boolean nativeIsReplayDataInjectionEnabled(long nativeInstance); private static native boolean nativeIsHalBypassReplayDataInjectionEnabled(long nativeInstance); private static native int nativeCreateDirectChannel( long nativeInstance, int deviceId, long size, int channelType, int fd, HardwareBuffer buffer); private static native void nativeDestroyDirectChannel( long nativeInstance, int channelHandle); private static native int nativeConfigDirectChannel( long nativeInstance, int channelHandle, int sensorHandle, int rate); private static native int nativeSetOperationParameter( long nativeInstance, int handle, int type, float[] floatValues, int[] intValues); private static final Object sLock = new Object(); @GuardedBy("sLock") private static boolean sNativeClassInited = false; @GuardedBy("sLock") private static InjectEventQueue sInjectEventQueue = null; private final ArrayList<Sensor> mFullSensorsList = new ArrayList<>(); private List<Sensor> mFullDynamicSensorsList = new ArrayList<>(); private final SparseArray<List<Sensor>> mFullRuntimeSensorListByDevice = new SparseArray<>(); private final SparseArray<SparseArray<List<Sensor>>> mRuntimeSensorListByDeviceByType = new SparseArray<>(); private boolean mDynamicSensorListDirty = true; private final HashMap<Integer, Sensor> mHandleToSensor = new HashMap<>(); // Listener list private final HashMap<SensorEventListener, SensorEventQueue> mSensorListeners = new HashMap<SensorEventListener, SensorEventQueue>(); private final HashMap<TriggerEventListener, TriggerEventQueue> mTriggerListeners = new HashMap<TriggerEventListener, TriggerEventQueue>(); // Dynamic Sensor callbacks private HashMap<DynamicSensorCallback, Handler> mDynamicSensorCallbacks = new HashMap<>(); private BroadcastReceiver mDynamicSensorBroadcastReceiver; private BroadcastReceiver mRuntimeSensorBroadcastReceiver; private VirtualDeviceManager.VirtualDeviceListener mVirtualDeviceListener; // Looper associated with the context in which this instance was created. private final Looper mMainLooper; private final int mTargetSdkLevel; private final boolean mIsPackageDebuggable; private final Context mContext; private final long mNativeInstance; private VirtualDeviceManager mVdm; private Optional<Boolean> mHasHighSamplingRateSensorsPermission = Optional.empty(); /** {@hide}
SystemSensorManager::SystemSensorManager
java
Reginer/aosp-android-jar
android-35/src/android/hardware/SystemSensorManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/hardware/SystemSensorManager.java
MIT
public ArrayIndexOutOfBoundsException() { super(); }
Constructs an {@code ArrayIndexOutOfBoundsException} with no detail message.
ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException
java
Reginer/aosp-android-jar
android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
MIT
public ArrayIndexOutOfBoundsException(String s) { super(s); }
Constructs an {@code ArrayIndexOutOfBoundsException} class with the specified detail message. @param s the detail message.
ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException
java
Reginer/aosp-android-jar
android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
MIT
public ArrayIndexOutOfBoundsException(int index) { super("Array index out of range: " + index); }
Constructs a new {@code ArrayIndexOutOfBoundsException} class with an argument indicating the illegal index. <p>The index is included in this exception's detail message. The exact presentation format of the detail message is unspecified. @param index the illegal index.
ArrayIndexOutOfBoundsException::ArrayIndexOutOfBoundsException
java
Reginer/aosp-android-jar
android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/lang/ArrayIndexOutOfBoundsException.java
MIT
public AudioDeviceAttributes(int nativeType, @NonNull String address) { mRole = (nativeType & AudioSystem.DEVICE_BIT_IN) != 0 ? ROLE_INPUT : ROLE_OUTPUT; mType = AudioDeviceInfo.convertInternalDeviceToDeviceType(nativeType); mAddress = address; mNativeType = nativeType; }
@hide Constructor from internal device type and address @param type the internal device type, as defined in {@link AudioSystem} @param address the address of the device, or an empty string for devices without one
AudioDeviceAttributes::AudioDeviceAttributes
java
Reginer/aosp-android-jar
android-32/src/android/media/AudioDeviceAttributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/media/AudioDeviceAttributes.java
MIT
public int getInternalType() { return mNativeType; }
@hide Returns the internal device type of a device @return the internal device type
AudioDeviceAttributes::getInternalType
java
Reginer/aosp-android-jar
android-32/src/android/media/AudioDeviceAttributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/media/AudioDeviceAttributes.java
MIT
public static String roleToString(@Role int role) { return (role == ROLE_OUTPUT ? "output" : "input"); }
@hide Returns the internal device type of a device @return the internal device type public int getInternalType() { return mNativeType; } @Override public int hashCode() { return Objects.hash(mRole, mType, mAddress); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AudioDeviceAttributes that = (AudioDeviceAttributes) o; return ((mRole == that.mRole) && (mType == that.mType) && mAddress.equals(that.mAddress)); } /** @hide
AudioDeviceAttributes::roleToString
java
Reginer/aosp-android-jar
android-32/src/android/media/AudioDeviceAttributes.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/media/AudioDeviceAttributes.java
MIT
public ToStream() { }
Default constructor
ToStream::ToStream
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected void closeCDATA() throws org.xml.sax.SAXException { try { m_writer.write(CDATA_DELIMITER_CLOSE); // write out a CDATA section closing "]]>" m_cdataTagOpen = false; // Remember that we have done so. } catch (IOException e) { throw new SAXException(e); } }
This helper method to writes out "]]>" when closing a CDATA section. @throws org.xml.sax.SAXException
ToStream::closeCDATA
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void serialize(Node node) throws IOException { try { TreeWalker walker = new TreeWalker(this); walker.traverse(node); } catch (org.xml.sax.SAXException se) { throw new WrappedRuntimeException(se); } }
Serializes the DOM node. Throws an exception only if an I/O exception occured while serializing. @param node Node to serialize. @throws IOException An I/O exception occured while serializing
ToStream::serialize
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected final void flushWriter() throws org.xml.sax.SAXException { final java.io.Writer writer = m_writer; if (null != writer) { try { if (writer instanceof WriterToUTF8Buffered) { if (m_shouldFlush) ((WriterToUTF8Buffered) writer).flush(); else ((WriterToUTF8Buffered) writer).flushBuffer(); } if (writer instanceof WriterToASCI) { if (m_shouldFlush) writer.flush(); } else { // Flush always. // Not a great thing if the writer was created // by this class, but don't have a choice. writer.flush(); } } catch (IOException ioe) { throw new org.xml.sax.SAXException(ioe); } } }
Flush the formatter's result stream. @throws org.xml.sax.SAXException
ToStream::flushWriter
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public OutputStream getOutputStream() { return m_outputStream; }
Get the output stream where the events will be serialized to. @return reference to the result stream, or null of only a writer was set.
ToStream::getOutputStream
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void elementDecl(String name, String model) throws SAXException { // Do not inline external DTD if (m_inExternalDTD) return; try { final java.io.Writer writer = m_writer; DTDprolog(); writer.write("<!ELEMENT "); writer.write(name); writer.write(' '); writer.write(model); writer.write('>'); writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { throw new SAXException(e); } }
Report an element type declaration. <p>The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed,and will include the enclosing parentheses.</p> @param name The element type name. @param model The content model as a normalized string. @exception SAXException The application may raise an exception.
ToStream::elementDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void internalEntityDecl(String name, String value) throws SAXException { // Do not inline external DTD if (m_inExternalDTD) return; try { DTDprolog(); outputEntityDecl(name, value); } catch (IOException e) { throw new SAXException(e); } }
Report an internal entity declaration. <p>Only the effective (first) declaration for each entity will be reported.</p> @param name The name of the entity. If it is a parameter entity, the name will begin with '%'. @param value The replacement text of the entity. @exception SAXException The application may raise an exception. @see #externalEntityDecl @see org.xml.sax.DTDHandler#unparsedEntityDecl
ToStream::internalEntityDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
void outputEntityDecl(String name, String value) throws IOException { final java.io.Writer writer = m_writer; writer.write("<!ENTITY "); writer.write(name); writer.write(" \""); writer.write(value); writer.write("\">"); writer.write(m_lineSep, 0, m_lineSepLen); }
Output the doc type declaration. @param name non-null reference to document type name. NEEDSDOC @param value @throws org.xml.sax.SAXException
ToStream::outputEntityDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected final void outputLineSep() throws IOException { m_writer.write(m_lineSep, 0, m_lineSepLen); }
Output a system-dependent line break. @throws org.xml.sax.SAXException
ToStream::outputLineSep
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void setOutputFormat(Properties format) { boolean shouldFlush = m_shouldFlush; if (format != null) { // Set the default values first, // and the non-default values after that, // just in case there is some unexpected // residual values left over from over-ridden default values Enumeration propNames; propNames = format.propertyNames(); while (propNames.hasMoreElements()) { String key = (String) propNames.nextElement(); // Get the value, possibly a default value String value = format.getProperty(key); // Get the non-default value (if any). String explicitValue = (String) format.get(key); if (explicitValue == null && value != null) { // This is a default value this.setOutputPropertyDefault(key,value); } if (explicitValue != null) { // This is an explicit non-default value this.setOutputProperty(key,explicitValue); } } } // Access this only from the Hashtable level... we don't want to // get default properties. String entitiesFileName = (String) format.get(OutputPropertiesFactory.S_KEY_ENTITIES); if (null != entitiesFileName) { String method = (String) format.get(OutputKeys.METHOD); m_charInfo = CharInfo.getCharInfo(entitiesFileName, method); } m_shouldFlush = shouldFlush; }
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document. @param format The output format to use
ToStream::setOutputFormat
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public Properties getOutputFormat() { Properties def = new Properties(); { Set s = getOutputPropDefaultKeys(); Iterator i = s.iterator(); while (i.hasNext()) { String key = (String) i.next(); String val = getOutputPropertyDefault(key); def.put(key, val); } } Properties props = new Properties(def); { Set s = getOutputPropKeys(); Iterator i = s.iterator(); while (i.hasNext()) { String key = (String) i.next(); String val = getOutputPropertyNonDefault(key); if (val != null) props.put(key, val); } } return props; }
Returns the output format for this serializer. @return The output format in use
ToStream::getOutputFormat
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void setWriter(Writer writer) { setWriterInternal(writer, true); }
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document. @param writer The output writer stream
ToStream::setWriter
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public boolean setLineSepUse(boolean use_sytem_line_break) { boolean oldValue = m_lineSepUse; m_lineSepUse = use_sytem_line_break; return oldValue; }
Set if the operating systems end-of-line line separator should be used when serializing. If set false NL character (decimal 10) is left alone, otherwise the new-line will be replaced on output with the systems line separator. For example on UNIX this is NL, while on Windows it is two characters, CR NL, where CR is the carriage-return (decimal 13). @param use_sytem_line_break True if an input NL is replaced with the operating systems end-of-line separator. @return The previously set value of the serializer.
ToStream::setLineSepUse
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void setOutputStream(OutputStream output) { setOutputStreamInternal(output, true); }
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document. <p> The encoding specified in the output properties is used, or if no encoding was specified, the default for the selected output method. @param output The output stream
ToStream::setOutputStream
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public boolean setEscaping(boolean escape) { final boolean temp = m_escaping; m_escaping = escape; return temp; }
@see SerializationHandler#setEscaping(boolean)
ToStream::setEscaping
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected void indent(int depth) throws IOException { if (m_startNewLine) outputLineSep(); /* For m_indentAmount > 0 this extra test might be slower * but Xalan's default value is 0, so this extra test * will run faster in that situation. */ if (m_indentAmount > 0) printSpace(depth * m_indentAmount); }
Might print a newline character and the indentation amount of the given depth. @param depth the indentation depth (element nesting depth) @throws org.xml.sax.SAXException if an error occurs during writing.
ToStream::indent
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected void indent() throws IOException { indent(m_elemContext.m_currentElemDepth); }
Indent at the current element nesting depth. @throws IOException
ToStream::indent
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private void printSpace(int n) throws IOException { final java.io.Writer writer = m_writer; for (int i = 0; i < n; i++) { writer.write(' '); } }
Prints <var>n</var> spaces. @param n Number of spaces to print. @throws org.xml.sax.SAXException if an error occurs when writing.
ToStream::printSpace
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void attributeDecl( String eName, String aName, String type, String valueDefault, String value) throws SAXException { // Do not inline external DTD if (m_inExternalDTD) return; try { final java.io.Writer writer = m_writer; DTDprolog(); writer.write("<!ATTLIST "); writer.write(eName); writer.write(' '); writer.write(aName); writer.write(' '); writer.write(type); if (valueDefault != null) { writer.write(' '); writer.write(valueDefault); } //writer.write(" "); //writer.write(value); writer.write('>'); writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { throw new SAXException(e); } }
Report an attribute type declaration. <p>Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.</p> @param eName The name of the associated element. @param aName The name of the attribute. @param type A string representing the attribute type. @param valueDefault A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies. @param value A string representing the attribute's default value, or null if there is none. @exception SAXException The application may raise an exception.
ToStream::attributeDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public Writer getWriter() { return m_writer; }
Get the character stream where the events will be serialized to. @return Reference to the result Writer, or null.
ToStream::getWriter
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void externalEntityDecl( String name, String publicId, String systemId) throws SAXException { try { DTDprolog(); m_writer.write("<!ENTITY "); m_writer.write(name); if (publicId != null) { m_writer.write(" PUBLIC \""); m_writer.write(publicId); } else { m_writer.write(" SYSTEM \""); m_writer.write(systemId); } m_writer.write("\" >"); m_writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Report a parsed external entity declaration. <p>Only the effective (first) declaration for each entity will be reported.</p> @param name The name of the entity. If it is a parameter entity, the name will begin with '%'. @param publicId The declared public identifier of the entity, or null if none was declared. @param systemId The declared system identifier of the entity. @exception SAXException The application may raise an exception. @see #internalEntityDecl @see org.xml.sax.DTDHandler#unparsedEntityDecl
ToStream::externalEntityDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected boolean escapingNotNeeded(char ch) { final boolean ret; if (ch < 127) { // This is the old/fast code here, but is this // correct for all encodings? if (ch >= CharInfo.S_SPACE || (CharInfo.S_LINEFEED == ch || CharInfo.S_CARRIAGERETURN == ch || CharInfo.S_HORIZONAL_TAB == ch)) ret= true; else ret = false; } else { ret = m_encodingInfo.isInEncoding(ch); } return ret; }
Tell if this character can be written without escaping.
ToStream::escapingNotNeeded
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected int writeUTF16Surrogate(char c, char ch[], int i, int end) throws IOException { int codePoint = 0; if (i + 1 >= end) { throw new IOException( Utils.messages.createMessage( MsgKey.ER_INVALID_UTF16_SURROGATE, new Object[] { Integer.toHexString((int) c)})); } final char high = c; final char low = ch[i+1]; if (!Encodings.isLowUTF16Surrogate(low)) { throw new IOException( Utils.messages.createMessage( MsgKey.ER_INVALID_UTF16_SURROGATE, new Object[] { Integer.toHexString((int) c) + " " + Integer.toHexString(low)})); } final java.io.Writer writer = m_writer; // If we make it to here we have a valid high, low surrogate pair if (m_encodingInfo.isInEncoding(c,low)) { // If the character formed by the surrogate pair // is in the encoding, so just write it out writer.write(ch,i,2); } else { // Don't know what to do with this char, it is // not in the encoding and not a high char in // a surrogate pair, so write out as an entity ref final String encoding = getEncoding(); if (encoding != null) { /* The output encoding is known, * so somthing is wrong. */ codePoint = Encodings.toCodePoint(high, low); // not in the encoding, so write out a character reference writer.write('&'); writer.write('#'); writer.write(Integer.toString(codePoint)); writer.write(';'); } else { /* The output encoding is not known, * so just write it out as-is. */ writer.write(ch, i, 2); } } // non-zero only if character reference was written out. return codePoint; }
Once a surrogate has been detected, write out the pair of characters if it is in the encoding, or if there is no encoding, otherwise write out an entity reference of the value of the unicode code point of the character represented by the high/low surrogate pair. <p> An exception is thrown if there is no low surrogate in the pair, because the array ends unexpectely, or if the low char is there but its value is such that it is not a low surrogate. @param c the first (high) part of the surrogate, which must be confirmed before calling this method. @param ch Character array. @param i position Where the surrogate was detected. @param end The end index of the significant characters. @return 0 if the pair of characters was written out as-is, the unicode code point of the character represented by the surrogate pair if an entity reference with that value was written out. @throws IOException @throws org.xml.sax.SAXException if invalid UTF-16 surrogate detected.
ToStream::writeUTF16Surrogate
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
int accumDefaultEntity( java.io.Writer writer, char ch, int i, char[] chars, int len, boolean fromTextNode, boolean escLF) throws IOException { if (!escLF && CharInfo.S_LINEFEED == ch) { writer.write(m_lineSep, 0, m_lineSepLen); } else { // if this is text node character and a special one of those, // or if this is a character from attribute value and a special one of those if ((fromTextNode && m_charInfo.shouldMapTextChar(ch)) || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch))) { String outputStringForChar = m_charInfo.getOutputStringForChar(ch); if (null != outputStringForChar) { writer.write(outputStringForChar); } else return i; } else return i; } return i + 1; }
Handle one of the default entities, return false if it is not a default entity. @param ch character to be escaped. @param i index into character array. @param chars non-null reference to character array. @param len length of chars. @param fromTextNode true if the characters being processed are from a text node, false if they are from an attribute value @param escLF true if the linefeed should be escaped. @return i+1 if the character was written, else i. @throws java.io.IOException
ToStream::accumDefaultEntity
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
void writeNormalizedChars( char ch[], int start, int length, boolean isCData, boolean useSystemLineSeparator) throws IOException, org.xml.sax.SAXException { final java.io.Writer writer = m_writer; int end = start + length; for (int i = start; i < end; i++) { char c = ch[i]; if (CharInfo.S_LINEFEED == c && useSystemLineSeparator) { writer.write(m_lineSep, 0, m_lineSepLen); } else if (isCData && (!escapingNotNeeded(c))) { // if (i != 0) if (m_cdataTagOpen) closeCDATA(); // This needs to go into a function... if (Encodings.isHighUTF16Surrogate(c)) { writeUTF16Surrogate(c, ch, i, end); i++ ; // process two input characters } else { writer.write("&#"); String intStr = Integer.toString((int) c); writer.write(intStr); writer.write(';'); } // if ((i != 0) && (i < (end - 1))) // if (!m_cdataTagOpen && (i < (end - 1))) // { // writer.write(CDATA_DELIMITER_OPEN); // m_cdataTagOpen = true; // } } else if ( isCData && ((i < (end - 2)) && (']' == c) && (']' == ch[i + 1]) && ('>' == ch[i + 2]))) { writer.write(CDATA_CONTINUE); i += 2; } else { if (escapingNotNeeded(c)) { if (isCData && !m_cdataTagOpen) { writer.write(CDATA_DELIMITER_OPEN); m_cdataTagOpen = true; } writer.write(c); } // This needs to go into a function... else if (Encodings.isHighUTF16Surrogate(c)) { if (m_cdataTagOpen) closeCDATA(); writeUTF16Surrogate(c, ch, i, end); i++; // process two input characters } else { if (m_cdataTagOpen) closeCDATA(); writer.write("&#"); String intStr = Integer.toString((int) c); writer.write(intStr); writer.write(';'); } } } }
Normalize the characters, but don't escape. @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @param isCData true if a CDATA block should be built around the characters. @param useSystemLineSeparator true if the operating systems end-of-line separator should be output rather than a new-line character. @throws IOException @throws org.xml.sax.SAXException
ToStream::writeNormalizedChars
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void endNonEscaping() throws org.xml.sax.SAXException { m_disableOutputEscapingStates.pop(); }
Ends an un-escaping section. @see #startNonEscaping @throws org.xml.sax.SAXException
ToStream::endNonEscaping
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void startNonEscaping() throws org.xml.sax.SAXException { m_disableOutputEscapingStates.push(true); }
Starts an un-escaping section. All characters printed within an un- escaping section are printed as is, without escaping special characters into entity references. Only XML and HTML serializers need to support this method. <p> The contents of the un-escaping section will be delivered through the regular <tt>characters</tt> event. @throws org.xml.sax.SAXException
ToStream::startNonEscaping
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected void cdata(char ch[], int start, final int length) throws org.xml.sax.SAXException { try { final int old_start = start; if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } m_ispreserve = true; if (shouldIndent()) indent(); boolean writeCDataBrackets = (((length >= 1) && escapingNotNeeded(ch[start]))); /* Write out the CDATA opening delimiter only if * we are supposed to, and if we are not already in * the middle of a CDATA section */ if (writeCDataBrackets && !m_cdataTagOpen) { m_writer.write(CDATA_DELIMITER_OPEN); m_cdataTagOpen = true; } // writer.write(ch, start, length); if (isEscapingDisabled()) { charactersRaw(ch, start, length); } else writeNormalizedChars(ch, start, length, true, m_lineSepUse); /* used to always write out CDATA closing delimiter here, * but now we delay, so that we can merge CDATA sections on output. * need to write closing delimiter later */ if (writeCDataBrackets) { /* if the CDATA section ends with ] don't leave it open * as there is a chance that an adjacent CDATA sections * starts with ]>. * We don't want to merge ]] with > , or ] with ]> */ if (ch[start + length - 1] == ']') closeCDATA(); } // time to fire off CDATA event if (m_tracer != null) super.fireCDATAEvent(ch, old_start, length); } catch (IOException ioe) { throw new org.xml.sax.SAXException( Utils.messages.createMessage( MsgKey.ER_OIERROR, null), ioe); //"IO error", ioe); } }
Receive notification of cdata. <p>The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.</p> <p>The application must not attempt to read from the array outside of the specified range.</p> <p>Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).</p> @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see #ignorableWhitespace @see org.xml.sax.Locator @throws org.xml.sax.SAXException
ToStream::cdata
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private boolean isEscapingDisabled() { return m_disableOutputEscapingStates.peekOrFalse(); }
Tell if the character escaping should be disabled for the current state. @return true if the character escaping should be disabled.
ToStream::isEscapingDisabled
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
protected void charactersRaw(char ch[], int start, int length) throws org.xml.sax.SAXException { if (m_inEntityRef) return; try { if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } m_ispreserve = true; m_writer.write(ch, start, length); } catch (IOException e) { throw new SAXException(e); } }
If available, when the disable-output-escaping attribute is used, output raw text without escaping. @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @throws org.xml.sax.SAXException
ToStream::charactersRaw
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void characters(final char chars[], final int start, final int length) throws org.xml.sax.SAXException { // It does not make sense to continue with rest of the method if the number of // characters to read from array is 0. // Section 7.6.1 of XSLT 1.0 (http://www.w3.org/TR/xslt#value-of) suggest no text node // is created if string is empty. if (length == 0 || (m_inEntityRef && !m_expandDTDEntities)) return; m_docIsEmpty = false; if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } else if (m_needToCallStartDocument) { startDocumentInternal(); } if (m_cdataStartCalled || m_elemContext.m_isCdataSection) { /* either due to startCDATA() being called or due to * cdata-section-elements atribute, we need this as cdata */ cdata(chars, start, length); return; } if (m_cdataTagOpen) closeCDATA(); if (m_disableOutputEscapingStates.peekOrFalse() || (!m_escaping)) { charactersRaw(chars, start, length); // time to fire off characters generation event if (m_tracer != null) super.fireCharEvent(chars, start, length); return; } if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } try { int i; int startClean; // skip any leading whitspace // don't go off the end and use a hand inlined version // of isWhitespace(ch) final int end = start + length; int lastDirtyCharProcessed = start - 1; // last non-clean character that was processed // that was processed final Writer writer = m_writer; boolean isAllWhitespace = true; // process any leading whitspace i = start; while (i < end && isAllWhitespace) { char ch1 = chars[i]; if (m_charInfo.shouldMapTextChar(ch1)) { // The character is supposed to be replaced by a String // so write out the clean whitespace characters accumulated // so far // then the String. writeOutCleanChars(chars, i, lastDirtyCharProcessed); String outputStringForChar = m_charInfo .getOutputStringForChar(ch1); writer.write(outputStringForChar); // We can't say that everything we are writing out is // all whitespace, we just wrote out a String. isAllWhitespace = false; lastDirtyCharProcessed = i; // mark the last non-clean // character processed i++; } else { // The character is clean, but is it a whitespace ? switch (ch1) { // TODO: Any other whitespace to consider? case CharInfo.S_SPACE: // Just accumulate the clean whitespace i++; break; case CharInfo.S_LINEFEED: lastDirtyCharProcessed = processLineFeed(chars, i, lastDirtyCharProcessed, writer); i++; break; case CharInfo.S_CARRIAGERETURN: writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#13;"); lastDirtyCharProcessed = i; i++; break; case CharInfo.S_HORIZONAL_TAB: // Just accumulate the clean whitespace i++; break; default: // The character was clean, but not a whitespace // so break the loop to continue with this character // (we don't increment index i !!) isAllWhitespace = false; break; } } } /* If there is some non-whitespace, mark that we may need * to preserve this. This is only important if we have indentation on. */ if (i < end || !isAllWhitespace) m_ispreserve = true; for (; i < end; i++) { char ch = chars[i]; if (m_charInfo.shouldMapTextChar(ch)) { // The character is supposed to be replaced by a String // e.g. '&' --> "&amp;" // e.g. '<' --> "&lt;" writeOutCleanChars(chars, i, lastDirtyCharProcessed); String outputStringForChar = m_charInfo.getOutputStringForChar(ch); writer.write(outputStringForChar); lastDirtyCharProcessed = i; } else { if (ch <= 0x1F) { // Range 0x00 through 0x1F inclusive // // This covers the non-whitespace control characters // in the range 0x1 to 0x1F inclusive. // It also covers the whitespace control characters in the same way: // 0x9 TAB // 0xA NEW LINE // 0xD CARRIAGE RETURN // // We also cover 0x0 ... It isn't valid // but we will output "&#0;" // The default will handle this just fine, but this // is a little performance boost to handle the more // common TAB, NEW-LINE, CARRIAGE-RETURN switch (ch) { case CharInfo.S_HORIZONAL_TAB: // Leave whitespace TAB as a real character break; case CharInfo.S_LINEFEED: lastDirtyCharProcessed = processLineFeed(chars, i, lastDirtyCharProcessed, writer); break; case CharInfo.S_CARRIAGERETURN: writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#13;"); lastDirtyCharProcessed = i; // Leave whitespace carriage return as a real character break; default: writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); lastDirtyCharProcessed = i; break; } } else if (ch < 0x7F) { // Range 0x20 through 0x7E inclusive // Normal ASCII chars, do nothing, just add it to // the clean characters } else if (ch <= 0x9F){ // Range 0x7F through 0x9F inclusive // More control characters, including NEL (0x85) writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); lastDirtyCharProcessed = i; } else if (ch == CharInfo.S_LINE_SEPARATOR) { // LINE SEPARATOR writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#8232;"); lastDirtyCharProcessed = i; } else if (m_encodingInfo.isInEncoding(ch)) { // If the character is in the encoding, and // not in the normal ASCII range, we also // just leave it get added on to the clean characters } else { // This is a fallback plan, we should never get here // but if the character wasn't previously handled // (i.e. isn't in the encoding, etc.) then what // should we do? We choose to write out an entity writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); lastDirtyCharProcessed = i; } } } // we've reached the end. Any clean characters at the // end of the array than need to be written out? startClean = lastDirtyCharProcessed + 1; if (i > startClean) { int lengthClean = i - startClean; m_writer.write(chars, startClean, lengthClean); } // For indentation purposes, mark that we've just writen text out m_isprevtext = true; } catch (IOException e) { throw new SAXException(e); } // time to fire off characters generation event if (m_tracer != null) super.fireCharEvent(chars, start, length); }
Receive notification of character data. <p>The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.</p> <p>The application must not attempt to read from the array outside of the specified range.</p> <p>Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).</p> @param chars The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see #ignorableWhitespace @see org.xml.sax.Locator @throws org.xml.sax.SAXException
ToStream::characters
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private static boolean isCharacterInC0orC1Range(char ch) { if(ch == 0x09 || ch == 0x0A || ch == 0x0D) return false; else return (ch >= 0x7F && ch <= 0x9F)|| (ch >= 0x01 && ch <= 0x1F); }
This method checks if a given character is between C0 or C1 range of Control characters. This method is added to support Control Characters for XML 1.1 If a given character is TAB (0x09), LF (0x0A) or CR (0x0D), this method return false. Since they are whitespace characters, no special processing is needed. @param ch @return boolean
ToStream::isCharacterInC0orC1Range
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private static boolean isNELorLSEPCharacter(char ch) { return (ch == 0x85 || ch == 0x2028); }
This method checks if a given character either NEL (0x85) or LSEP (0x2028) These are new end of line charcters added in XML 1.1. These characters must be written as Numeric Character References (NCR) in XML 1.1 output document. @param ch @return boolean
ToStream::isNELorLSEPCharacter
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private int processDirty( char[] chars, int end, int i, char ch, int lastDirty, boolean fromTextNode) throws IOException { int startClean = lastDirty + 1; // if we have some clean characters accumulated // process them before the dirty one. if (i > startClean) { int lengthClean = i - startClean; m_writer.write(chars, startClean, lengthClean); } // process the "dirty" character if (CharInfo.S_LINEFEED == ch && fromTextNode) { m_writer.write(m_lineSep, 0, m_lineSepLen); } else { startClean = accumDefaultEscape( m_writer, (char)ch, i, chars, end, fromTextNode, false); i = startClean - 1; } // Return the index of the last character that we just processed // which is a dirty character. return i; }
Process a dirty character and any preeceding clean characters that were not yet processed. @param chars array of characters being processed @param end one (1) beyond the last character in chars to be processed @param i the index of the dirty character @param ch the character in chars[i] @param lastDirty the last dirty character previous to i @param fromTextNode true if the characters being processed are from a text node, false if they are from an attribute value. @return the index of the last character processed
ToStream::processDirty
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void characters(String s) throws org.xml.sax.SAXException { if (m_inEntityRef && !m_expandDTDEntities) return; final int length = s.length(); if (length > m_charsBuff.length) { m_charsBuff = new char[length * 2 + 1]; } s.getChars(0, length, m_charsBuff, 0); characters(m_charsBuff, 0, length); }
Receive notification of character data. @param s The string of characters to process. @throws org.xml.sax.SAXException
ToStream::characters
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
private int accumDefaultEscape( Writer writer, char ch, int i, char[] chars, int len, boolean fromTextNode, boolean escLF) throws IOException { int pos = accumDefaultEntity(writer, ch, i, chars, len, fromTextNode, escLF); if (i == pos) { if (Encodings.isHighUTF16Surrogate(ch)) { // Should be the UTF-16 low surrogate of the hig/low pair. char next; // Unicode code point formed from the high/low pair. int codePoint = 0; if (i + 1 >= len) { throw new IOException( Utils.messages.createMessage( MsgKey.ER_INVALID_UTF16_SURROGATE, new Object[] { Integer.toHexString(ch)})); //"Invalid UTF-16 surrogate detected: " //+Integer.toHexString(ch)+ " ?"); } else { next = chars[++i]; if (!(Encodings.isLowUTF16Surrogate(next))) throw new IOException( Utils.messages.createMessage( MsgKey .ER_INVALID_UTF16_SURROGATE, new Object[] { Integer.toHexString(ch) + " " + Integer.toHexString(next)})); //"Invalid UTF-16 surrogate detected: " //+Integer.toHexString(ch)+" "+Integer.toHexString(next)); codePoint = Encodings.toCodePoint(ch,next); } writer.write("&#"); writer.write(Integer.toString(codePoint)); writer.write(';'); pos += 2; // count the two characters that went into writing out this entity } else { /* This if check is added to support control characters in XML 1.1. * If a character is a Control Character within C0 and C1 range, it is desirable * to write it out as Numeric Character Reference(NCR) regardless of XML Version * being used for output document. */ if (isCharacterInC0orC1Range(ch) || isNELorLSEPCharacter(ch)) { writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); } else if ((!escapingNotNeeded(ch) || ( (fromTextNode && m_charInfo.shouldMapTextChar(ch)) || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch)))) && m_elemContext.m_currentElemDepth > 0) { writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); } else { writer.write(ch); } pos++; // count the single character that was processed } } return pos; }
Escape and writer.write a character. @param ch character to be escaped. @param i index into character array. @param chars non-null reference to character array. @param len length of chars. @param fromTextNode true if the characters being processed are from a text node, false if the characters being processed are from an attribute value. @param escLF true if the linefeed should be escaped. @return i+1 if a character was written, i+2 if two characters were written out, else return i. @throws org.xml.sax.SAXException
ToStream::accumDefaultEscape
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void startElement( String namespaceURI, String localName, String name, Attributes atts) throws org.xml.sax.SAXException { if (m_inEntityRef) return; if (m_needToCallStartDocument) { startDocumentInternal(); m_needToCallStartDocument = false; m_docIsEmpty = false; } else if (m_cdataTagOpen) closeCDATA(); try { if (m_needToOutputDocTypeDecl) { if(null != getDoctypeSystem()) { outputDocTypeDecl(name, true); } m_needToOutputDocTypeDecl = false; } /* before we over-write the current elementLocalName etc. * lets close out the old one (if we still need to) */ if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } if (namespaceURI != null) ensurePrefixIsDeclared(namespaceURI, name); m_ispreserve = false; if (shouldIndent() && m_startNewLine) { indent(); } m_startNewLine = true; final java.io.Writer writer = m_writer; writer.write('<'); writer.write(name); } catch (IOException e) { throw new SAXException(e); } // process the attributes now, because after this SAX call they might be gone if (atts != null) addAttributes(atts); m_elemContext = m_elemContext.push(namespaceURI,localName,name); m_isprevtext = false; if (m_tracer != null) firePseudoAttributes(); }
Receive notification of the beginning of an element, although this is a SAX method additional namespace or attribute information can occur before or after this call, that is associated with this element. @param namespaceURI The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param localName The local name (without prefix), or the empty string if Namespace processing is not being performed. @param name The element type name. @param atts The attributes attached to the element, if any. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see org.xml.sax.ContentHandler#startElement @see org.xml.sax.ContentHandler#endElement @see org.xml.sax.AttributeList @throws org.xml.sax.SAXException
ToStream::startElement
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void startElement( String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException { startElement(elementNamespaceURI, elementLocalName, elementName, null); }
Receive notification of the beginning of an element, additional namespace or attribute information can occur before or after this call, that is associated with this element. @param elementNamespaceURI The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param elementLocalName The local name (without prefix), or the empty string if Namespace processing is not being performed. @param elementName The element type name. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see org.xml.sax.ContentHandler#startElement @see org.xml.sax.ContentHandler#endElement @see org.xml.sax.AttributeList @throws org.xml.sax.SAXException
ToStream::startElement
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
void outputDocTypeDecl(String name, boolean closeDecl) throws SAXException { if (m_cdataTagOpen) closeCDATA(); try { final java.io.Writer writer = m_writer; writer.write("<!DOCTYPE "); writer.write(name); String doctypePublic = getDoctypePublic(); if (null != doctypePublic) { writer.write(" PUBLIC \""); writer.write(doctypePublic); writer.write('\"'); } String doctypeSystem = getDoctypeSystem(); if (null != doctypeSystem) { if (null == doctypePublic) writer.write(" SYSTEM \""); else writer.write(" \""); writer.write(doctypeSystem); if (closeDecl) { writer.write("\">"); writer.write(m_lineSep, 0, m_lineSepLen); closeDecl = false; // done closing } else writer.write('\"'); } } catch (IOException e) { throw new SAXException(e); } }
Output the doc type declaration. @param name non-null reference to document type name. NEEDSDOC @param closeDecl @throws java.io.IOException
ToStream::outputDocTypeDecl
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT
public void processAttributes(java.io.Writer writer, int nAttrs) throws IOException, SAXException { /* real SAX attributes are not passed in, so process the * attributes that were collected after the startElement call. * _attribVector is a "cheap" list for Stream serializer output * accumulated over a series of calls to attribute(name,value) */ String encoding = getEncoding(); for (int i = 0; i < nAttrs; i++) { // elementAt is JDK 1.1.8 final String name = m_attributes.getQName(i); final String value = m_attributes.getValue(i); writer.write(' '); writer.write(name); writer.write("=\""); writeAttrString(writer, value, encoding); writer.write('\"'); } }
Process the attributes, which means to write out the currently collected attributes to the writer. The attributes are not cleared by this method @param writer the writer to write processed attributes to. @param nAttrs the number of attributes in m_attributes to be processed @throws java.io.IOException @throws org.xml.sax.SAXException
ToStream::processAttributes
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/ToStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/ToStream.java
MIT