public void release() { refcount--; if (refcount == 0) { Portability.delete(this); } } }
/** * The C++ destructor. */ @SuppressWarnings("unused") private void destructor() { Portability.deleteArray(local); }
if (Portability.lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( TreeBuilder.QUIRKY_PUBLIC_IDS[i], publicIdentifier)) { return true; if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3o//dtd w3 html strict 3.0//en//", publicIdentifier) || Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-/w3c/dtd html 4.0 transitional/en", publicIdentifier) || Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "html", publicIdentifier)) { return true; if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 transitional//en", publicIdentifier)) { return true; } else if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 frameset//en", publicIdentifier)) { return true; } else if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd", systemIdentifier)) {
doctypeName = null; } else { doctypeName = Portability.newLocalFromLocal(other.doctypeName, interner); Portability.releaseString(systemIdentifier); if (other.systemIdentifier == null) { systemIdentifier = null; } else { systemIdentifier = Portability.newStringFromString(other.systemIdentifier); Portability.releaseString(publicIdentifier); if (other.publicIdentifier == null) { publicIdentifier = null; } else { publicIdentifier = Portability.newStringFromString(other.publicIdentifier); nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner) Portability.delete(attributes); if (other.attributes == null) { attributes = null;
String emptyString = Portability.newEmptyString(); appendDoctypeToDocument(name == null ? "" : name, publicIdentifier == null ? emptyString systemIdentifier == null ? emptyString : systemIdentifier); Portability.releaseString(emptyString); if ((Portability.literalEqualsString( "-//W3C//DTD HTML 4.0//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString( "http://www.w3.org/TR/REC-html40/strict.dtd", systemIdentifier))) || (Portability.literalEqualsString( "-//W3C//DTD HTML 4.01//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString( "http://www.w3.org/TR/html4/strict.dtd", systemIdentifier))) || (Portability.literalEqualsString( "-//W3C//DTD XHTML 1.0 Strict//EN", publicIdentifier) && Portability.literalEqualsString( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", systemIdentifier)) || (Portability.literalEqualsString( "-//W3C//DTD XHTML 1.1//EN", publicIdentifier) && Portability.literalEqualsString( "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", systemIdentifier)) } else if (!((systemIdentifier == null || Portability.literalEqualsString(
static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) { int hash = ElementName.bufToHash(buf, length); int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash); if (index < 0) { return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner)); } else { ElementName elementName = ElementName.ELEMENT_NAMES[index]; @Local String name = elementName.name; if (!Portability.localEqualsBuffer(name, buf, offset, length)) { return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner)); } return elementName; } }
break starttagloop; case INPUT: if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "hidden", attributes.getValue(AttributeName.TYPE))) { case SELECT: if (mode == FRAMESET_OK && !(group == INPUT && Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "hidden", attributes.getValue(AttributeName.TYPE)))) { int promptIndex = attributes.getIndex(AttributeName.PROMPT); if (promptIndex > -1) { @Auto char[] prompt = Portability.newCharArrayFromString(attributes.getValue(promptIndex)); appendCharacters(stack[currentPtr].node, prompt, 0, prompt.length); inputAttributes.addAttribute( AttributeName.NAME, Portability.newStringFromLiteral("isindex") Portability.delete(attributes);
private void checkMetaCharset(HtmlAttributes attributes) throws SAXException { String charset = attributes.getValue(AttributeName.CHARSET); if (charset != null) { if (tokenizer.internalEncodingDeclaration(charset)) { requestSuspension(); return; } return; } if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-type", attributes.getValue(AttributeName.HTTP_EQUIV))) { return; } String content = attributes.getValue(AttributeName.CONTENT); if (content != null) { String extract = TreeBuilder.extractCharsetFromContent(content); // remember not to return early without releasing the string if (extract != null) { if (tokenizer.internalEncodingDeclaration(extract)) { requestSuspension(); } } Portability.releaseString(extract); } }
int start = -1; int end = -1; @Auto char[] buffer = Portability.newCharArrayFromString(attributeValue); end = buffer.length; charset = Portability.newStringFromBuffer(buffer, start, end - start);
private boolean isAlmostStandards(String publicIdentifier, String systemIdentifier) { if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) { return true; } if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd xhtml 1.0 frameset//en", publicIdentifier)) { return true; } if (systemIdentifier != null) { if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 transitional//en", publicIdentifier)) { return true; } if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 frameset//en", publicIdentifier)) { return true; } } return false; }
@Inline static ElementName elementNameByBuffer(@NoLength char[] buf, int length, Interner interner) { @Unsigned int hash = ElementName.bufToHash(buf, length); int[] hashes; hashes = ElementName.ELEMENT_HASHES; int index = levelOrderBinarySearch(hashes, hash); if (index < 0) { return null; } else { ElementName elementName = ElementName.ELEMENT_NAMES[index]; @Local String name = elementName.name; if (!Portability.localEqualsBuffer(name, buf, length)) { return null; } return elementName; } }
/** * Sets the tokenizer state and the associated element name. This should * only ever used to put the tokenizer into one of the states that have * a special end tag expectation. * * @param specialTokenizerState * the tokenizer state to set * @param endTagExpectation * the expected end tag for transitioning back to normal */ public void setStateAndEndTagExpectation(int specialTokenizerState, @Local String endTagExpectation) { this.stateSave = specialTokenizerState; if (specialTokenizerState == Tokenizer.DATA) { return; } @Auto char[] asArray = Portability.newCharArrayFromLocal(endTagExpectation); this.endTagExpectation = ElementName.elementNameByBuffer(asArray, asArray.length, interner); assert this.endTagExpectation != null; endTagExpectationToArray(); }
private void addAttributeWithoutValue() throws SAXException { noteAttributeWithoutValue(); // [NOCPP[ if (metaBoundaryPassed && AttributeName.CHARSET == attributeName && ElementName.META == tagName) { err("A \u201Ccharset\u201D attribute on a \u201Cmeta\u201D element found after the first 1024 bytes."); } // ]NOCPP] if (attributeName != null) { // [NOCPP[ if (AttributeName.SRC == attributeName || AttributeName.HREF == attributeName) { warn("Attribute \u201C" + attributeName.getLocal(AttributeName.HTML) + "\u201D without an explicit value seen. The attribute may be dropped by IE7."); } // ]NOCPP] attributes.addAttribute(attributeName, Portability.newEmptyString() // [NOCPP[ , xmlnsPolicy // ]NOCPP] // CPPONLY: , attributeLine ); attributeName = null; } else { clearStrBufAfterUse(); } }
doctypeName = null; } else { doctypeName = Portability.newLocalFromLocal(other.doctypeName, interner);
String emptyString = Portability.newEmptyString(); appendDoctypeToDocument(name == null ? "" : name, publicIdentifier == null ? emptyString systemIdentifier == null ? emptyString : systemIdentifier); Portability.releaseString(emptyString); if ((Portability.literalEqualsString( "-//W3C//DTD HTML 4.0//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString( "http://www.w3.org/TR/REC-html40/strict.dtd", systemIdentifier))) || (Portability.literalEqualsString( "-//W3C//DTD HTML 4.01//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString( "http://www.w3.org/TR/html4/strict.dtd", systemIdentifier))) || (Portability.literalEqualsString( "-//W3C//DTD XHTML 1.0 Strict//EN", publicIdentifier) && Portability.literalEqualsString( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", systemIdentifier)) || (Portability.literalEqualsString( "-//W3C//DTD XHTML 1.1//EN", publicIdentifier) && Portability.literalEqualsString( "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", systemIdentifier)) } else if (!((systemIdentifier == null || Portability.literalEqualsString(
private void strBufToElementNameString() { if (containsHyphen) { // We've got a custom element or annotation-xml. @Local String annotationName = ElementName.ANNOTATION_XML.getName(); if (Portability.localEqualsBuffer(annotationName, strBuf, strBufLen)) { tagName = ElementName.ANNOTATION_XML; } else { nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner) // CPPONLY: , true ); tagName = nonInternedTagName; } } else { tagName = ElementName.elementNameByBuffer(strBuf, strBufLen, interner); if (tagName == null) { nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner) // CPPONLY: , false ); tagName = nonInternedTagName; } } containsHyphen = false; clearStrBufAfterUse(); }
private void checkMetaCharset(HtmlAttributes attributes) throws SAXException { String charset = attributes.getValue(AttributeName.CHARSET); if (charset != null) { if (tokenizer.internalEncodingDeclaration(charset)) { requestSuspension(); return; } return; } if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-type", attributes.getValue(AttributeName.HTTP_EQUIV))) { return; } String content = attributes.getValue(AttributeName.CONTENT); if (content != null) { String extract = TreeBuilder.extractCharsetFromContent(content // CPPONLY: , this ); // remember not to return early without releasing the string if (extract != null) { if (tokenizer.internalEncodingDeclaration(extract)) { requestSuspension(); } } Portability.releaseString(extract); } }
int start = -1; int end = -1; @Auto char[] buffer = Portability.newCharArrayFromString(attributeValue); end = buffer.length; charset = Portability.newStringFromBuffer(buffer, start, end - start
private boolean isAlmostStandards(String publicIdentifier, String systemIdentifier) { if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) { return true; } if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd xhtml 1.0 frameset//en", publicIdentifier)) { return true; } if (systemIdentifier != null) { if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 transitional//en", publicIdentifier)) { return true; } if (Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "-//w3c//dtd html 4.01 frameset//en", publicIdentifier)) { return true; } } return false; }
@Inline static ElementName elementNameByBuffer(@NoLength char[] buf, int length, Interner interner) { @Unsigned int hash = ElementName.bufToHash(buf, length); int[] hashes; hashes = ElementName.ELEMENT_HASHES; int index = levelOrderBinarySearch(hashes, hash); if (index < 0) { return null; } else { ElementName elementName = ElementName.ELEMENT_NAMES[index]; @Local String name = elementName.name; if (!Portability.localEqualsBuffer(name, buf, length)) { return null; } return elementName; } }