Example #1
0
 public byte[] serialize() {
   if (nodeName.getLocalName() == null) throw new RuntimeException("Local name is null");
   final short id = getBroker().getSymbols().getSymbol(this);
   final byte idSizeType = Signatures.getSizeType(id);
   int prefixLen = 0;
   if (nodeName.needsNamespaceDecl()) {
     if (nodeName.getPrefix() != null && nodeName.getPrefix().length() > 0)
       prefixLen = UTF8.encoded(nodeName.getPrefix());
   }
   final int nodeIdLen = nodeId.size();
   final byte[] data =
       ByteArrayPool.getByteArray(
           LENGTH_SIGNATURE_LENGTH
               + NodeId.LENGTH_NODE_ID_UNITS
               + nodeIdLen
               + Signatures.getLength(idSizeType)
               + (nodeName.needsNamespaceDecl()
                   ? LENGTH_NS_ID + LENGTH_PREFIX_LENGTH + prefixLen
                   : 0)
               + value.UTF8Size());
   int pos = 0;
   data[pos] = (byte) (Signatures.Attr << 0x5);
   data[pos] |= idSizeType;
   data[pos] |= (byte) (attributeType << 0x2);
   if (nodeName.needsNamespaceDecl()) data[pos] |= 0x10;
   pos += StoredNode.LENGTH_SIGNATURE_LENGTH;
   ByteConversion.shortToByte((short) nodeId.units(), data, pos);
   pos += NodeId.LENGTH_NODE_ID_UNITS;
   nodeId.serialize(data, pos);
   pos += nodeIdLen;
   Signatures.write(idSizeType, id, data, pos);
   pos += Signatures.getLength(idSizeType);
   if (nodeName.needsNamespaceDecl()) {
     final short nsId = getBroker().getSymbols().getNSSymbol(nodeName.getNamespaceURI());
     ByteConversion.shortToByte(nsId, data, pos);
     pos += LENGTH_NS_ID;
     ByteConversion.shortToByte((short) prefixLen, data, pos);
     pos += LENGTH_PREFIX_LENGTH;
     if (nodeName.getPrefix() != null && nodeName.getPrefix().length() > 0)
       UTF8.encode(nodeName.getPrefix(), data, pos);
     pos += prefixLen;
   }
   value.UTF8Encode(data, pos);
   return data;
 }
 public void insertData(int offset, String arg) throws DOMException {
   if (cdata == null) cdata = new XMLString(arg.toCharArray());
   else cdata.insert(offset, arg);
 }
 public String getNodeValue() {
   return cdata.toString();
 }
 public int getLength() {
   return cdata.length();
 }
 public String getLowerCaseData() throws DOMException {
   if (cdata == null) return null;
   else return cdata.toString().toLowerCase();
 }
 public void deleteData(int offset, int count) throws DOMException {
   if (cdata != null) cdata.delete(offset, count);
 }
 public void appendData(char[] data, int start, int howmany) throws DOMException {
   if (cdata == null) cdata = new XMLString(data, start, howmany);
   else cdata.append(data, start, howmany);
 }
 public void appendData(String arg) throws DOMException {
   if (cdata == null) cdata = new XMLString(arg.toCharArray());
   else cdata.append(arg);
 }
 public void clear() {
   super.clear();
   cdata.reset();
 }
 /** Release all resources hold by this object. */
 public void release() {
   cdata.release();
   super.release();
 }
 public String toString() {
   if (cdata == null) return null;
   else return cdata.toString();
 }
 public String substringData(int offset, int count) throws DOMException {
   if (cdata == null)
     throw new DOMException(DOMException.DOMSTRING_SIZE_ERR, "string index out of bounds");
   return cdata.substring(offset, count);
 }
 public void setData(String data) throws DOMException {
   if (cdata == null) cdata = new XMLString(data.toCharArray());
   else cdata.setData(data.toCharArray(), 0, data.length());
 }
 public void replaceData(int offset, int count, String arg) throws DOMException {
   if (cdata == null)
     throw new DOMException(DOMException.DOMSTRING_SIZE_ERR, "string index out of bounds");
   cdata.replace(offset, count, arg);
 }
Example #15
0
 public String getNodeValue() {
   return value.toString();
 }