/** * Gets the number of characters needed to represent * this binary data in the base64 encoding. */ public int length() { // for each 3 bytes you use 4 chars // if the remainder is 1 or 2 there will be 4 more get(); // fill in the buffer if necessary return ((dataLen + 2) / 3) * 4; }
@Override public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException { if (needsSeparatingWhitespace) fiout.writeLowLevelText(" "); /* * Check if the CharSequence is from a base64Binary data type */ if (!(value instanceof Base64Data)) { final int len = value.length(); if(len <buf.length) { value.writeTo(buf, 0); fiout.writeLowLevelText(buf, len); } else { fiout.writeLowLevelText(value.toString()); } } else { final Base64Data dataValue = (Base64Data)value; // Write out the octets using the base64 encoding algorithm fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen()); } }
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException { if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) { Base64Data b64d = (Base64Data) value; String cid; if(b64d.hasData()) cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName); else cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.getDataHandler(),nsUri,localName); if(cid!=null) { nsContext.getCurrent().push(); int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false); beginStartTag(prefix,"Include"); attribute(-1,"href",cid); endStartTag(); endTag(prefix,"Include"); nsContext.getCurrent().pop(); return; } } next.text(value, needsSeparatingWhitespace); } }
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException { if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) { Base64Data b64d = (Base64Data) value; String cid; if(b64d.hasData()) cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName); else cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.getDataHandler(),nsUri,localName); if(cid!=null) { nsContext.getCurrent().push(); int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false); beginStartTag(prefix,"Include"); attribute(-1,"href",cid); endStartTag(); endTag(prefix,"Include"); nsContext.getCurrent().pop(); return; } } next.text(value, needsSeparatingWhitespace); } }
/** * Gets the byte[] of the exact length. */ public byte[] getExact() { get(); if (dataLen != data.length) { byte[] buf = new byte[dataLen]; System.arraycopy(data, 0, buf, 0, dataLen); data = buf; } return data; }
@Override public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException { if (needsSeparatingWhitespace) fiout.writeLowLevelText(" "); /* * Check if the CharSequence is from a base64Binary data type */ if (!(value instanceof Base64Data)) { final int len = value.length(); if(len <buf.length) { value.writeTo(buf, 0); fiout.writeLowLevelText(buf, len); } else { fiout.writeLowLevelText(value.toString()); } } else { final Base64Data dataValue = (Base64Data)value; // Write out the octets using the base64 encoding algorithm fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen()); } }
/** * Returns the base64 encoded string of this data. */ public String toString() { get(); // fill in the buffer return DatatypeConverterImpl._printBase64Binary(data, 0, dataLen); }
public void writeTo(UTF8XmlOutput output) throws IOException { // TODO: this is inefficient if the data source is note byte[] but DataHandler get(); output.text(data, dataLen); }
/** * Internally this is only used to split a text to a list, * which doesn't happen that much for base64. * So this method should be smaller than faster. */ public CharSequence subSequence(int start, int end) { StringBuilder buf = new StringBuilder(); get(); // fill in the buffer if we haven't done so for (int i = start; i < end; i++) { buf.append(charAt(i)); } return buf; }
@Override public void writeTo(char[] buf, int start) { get(); DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, buf, start); }
public void writeTo(XMLStreamWriter output) throws IOException, XMLStreamException { get(); DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, output); }
/** * Gets the number of characters needed to represent * this binary data in the base64 encoding. */ public int length() { // for each 3 bytes you use 4 chars // if the remainder is 1 or 2 there will be 4 more get(); // fill in the buffer if necessary return ((dataLen + 2) / 3) * 4; }
/** * Gets the byte[] of the exact length. */ public byte[] getExact() { get(); if (dataLen != data.length) { byte[] buf = new byte[dataLen]; System.arraycopy(data, 0, buf, 0, dataLen); data = buf; } return data; }
/** * Returns the base64 encoded string of this data. */ public String toString() { get(); // fill in the buffer return DatatypeConverterImpl._printBase64Binary(data, 0, dataLen); }
public void writeTo(UTF8XmlOutput output) throws IOException { // TODO: this is inefficient if the data source is note byte[] but DataHandler get(); output.text(data, dataLen); }
/** * Internally this is only used to split a text to a list, * which doesn't happen that much for base64. * So this method should be smaller than faster. */ public CharSequence subSequence(int start, int end) { StringBuilder buf = new StringBuilder(); get(); // fill in the buffer if we haven't done so for (int i = start; i < end; i++) { buf.append(charAt(i)); } return buf; }
public void writeTo(XMLStreamWriter output) throws IOException, XMLStreamException { get(); DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, output); }
@Override public void writeTo(char[] buf, int start) { get(); DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, buf, start); }
/** * Returns the base64 encoded string of this data. */ public String toString() { get(); // fill in the buffer return DatatypeConverterImpl._printBase64Binary(data, 0, dataLen); }
@Override public void writeTo(char[] buf, int start) { get(); DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, buf, start); }