예제 #1
0
 // Implements ContentHandler
 public void startElement(
     CharArray namespaceURI,
     CharArray localName,
     CharArray qName,
     _templates.javolution.xml.sax.Attributes atts)
     throws SAXException {
   _attributes = atts;
   _sax2Handler.startElement(
       namespaceURI.toString(), localName.toString(), qName.toString(), this);
 }
예제 #2
0
 CharArray getPrefix(CharSequence uri, int count) {
   for (int i = count; --i >= 0; ) {
     CharArray prefix = _prefixes[i];
     CharArray namespace = _namespaces[i];
     if (namespace.equals(uri)) { // Find matching uri.
       // Checks that the prefix has not been overwriten after being set.
       boolean isPrefixOverwritten = false;
       for (int j = i + 1; j < count; j++) {
         if (prefix.equals(_prefixes[j])) {
           isPrefixOverwritten = true;
           break;
         }
       }
       if (!isPrefixOverwritten) return prefix;
     }
   }
   return null; // Not bound.
 }
예제 #3
0
 // Null values are not allowed.
 void setPrefix(CharArray prefix, CharArray uri) {
   int index = _namespacesCount[_nesting];
   _prefixes[index] = prefix;
   _namespaces[index] = uri;
   if (prefix.length() == 0) { // The default namespace is set.
     _defaultNamespaceIndex = index;
     _defaultNamespace = uri;
   }
   if (++_namespacesCount[_nesting] >= _prefixes.length) resizePrefixStack();
 }
예제 #4
0
  // Used only by XMLStreamWriter (converts CharSequence to CharArray).
  // Null values are not allowed.
  void setPrefix(final CharSequence prefix, CharSequence uri, boolean isWritten) {
    final int index = _namespacesCount[_nesting];
    _prefixesWritten[index] = isWritten;
    final int prefixLength = prefix.length();
    CharArray prefixTmp = _prefixesTmp[index];
    if ((prefixTmp == null) || (prefixTmp.array().length < prefixLength)) {
      MemoryArea.getMemoryArea(this)
          .executeInArea(
              new Runnable() {
                public void run() {
                  _prefixesTmp[index] = new CharArray().setArray(new char[prefixLength + 32], 0, 0);
                }
              });
      prefixTmp = _prefixesTmp[index];
    }
    for (int i = 0; i < prefixLength; i++) {
      prefixTmp.array()[i] = prefix.charAt(i);
    }
    prefixTmp.setArray(prefixTmp.array(), 0, prefixLength);

    final int uriLength = uri.length();
    CharArray namespaceTmp = _namespacesTmp[index];
    if ((namespaceTmp == null) || (namespaceTmp.array().length < uriLength)) {
      MemoryArea.getMemoryArea(this)
          .executeInArea(
              new Runnable() {
                public void run() {
                  _namespacesTmp[index] = new CharArray().setArray(new char[uriLength + 32], 0, 0);
                }
              });
      namespaceTmp = _namespacesTmp[index];
    }
    for (int i = 0; i < uriLength; i++) {
      namespaceTmp.array()[i] = uri.charAt(i);
    }
    namespaceTmp.setArray(namespaceTmp.array(), 0, uriLength);

    // Sets the prefix using CharArray instances.
    setPrefix(prefixTmp, namespaceTmp);
  }
예제 #5
0
 // Implements ContentHandler
 public void skippedEntity(CharArray name) throws SAXException {
   _sax2Handler.skippedEntity(name.toString());
 }
예제 #6
0
 // Implements ContentHandler
 public void processingInstruction(CharArray target, CharArray data) throws SAXException {
   _sax2Handler.processingInstruction(target.toString(), data.toString());
 }
예제 #7
0
 // Implements ContentHandler
 public void endElement(CharArray namespaceURI, CharArray localName, CharArray qName)
     throws SAXException {
   _sax2Handler.endElement(namespaceURI.toString(), localName.toString(), qName.toString());
 }
예제 #8
0
 // Implements ContentHandler
 public void endPrefixMapping(CharArray prefix) throws SAXException {
   _sax2Handler.endPrefixMapping(prefix.toString());
 }
예제 #9
0
 // Implements ContentHandler
 public void startPrefixMapping(CharArray prefix, CharArray uri) throws SAXException {
   _sax2Handler.startPrefixMapping(prefix.toString(), uri.toString());
 }
예제 #10
0
 // Implements NamespaceContext
 public CharArray getPrefix(CharSequence uri) {
   if (uri == null) throw new IllegalArgumentException("null namespace URI not allowed");
   return _defaultNamespace.equals(uri)
       ? _defaultNsPrefix
       : getPrefix(uri, _namespacesCount[_nesting]);
 }