![]() |
![]() |
ws-commons-util-1.0.216:54:42.417 INFO jd.cli.Main - Decompiling ws-commons-util-1.0.2.jar package org.apache.ws.commons.serialize; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import org.xml.sax.SAXException; public class CharSetXMLWriter extends XMLWriterImpl { private CharsetEncoder charsetEncoder; public void startDocument() throws SAXException { String enc = getEncoding(); if (enc == null) { enc = "UTF-8"; } Charset charSet = Charset.forName(enc); if (charSet.canEncode()) { charsetEncoder = charSet.newEncoder(); } super.startDocument(); } public boolean canEncode(char c) { return charsetEncoder == null ? super.canEncode(c) : charsetEncoder.canEncode(c); } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.CharSetXMLWriter * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; public class DOMBuilder implements ContentHandler { private Document document; private Node target; private Node currentNode; private Locator locator; private boolean prefixMappingIsAttribute; private List prefixes; public boolean isPrefixMappingIsAttribute() { return prefixMappingIsAttribute; } public void setPrefixMappingIsAttribute(boolean pPrefixMappingIsAttribute) { prefixMappingIsAttribute = pPrefixMappingIsAttribute; } public void setDocument(Document pDocument) { document = pDocument; } public Document getDocument() { return document; } public void setDocumentLocator(Locator pLocator) { locator = pLocator; } public Locator getDocumentLocator() { return locator; } public void setTarget(Node pNode) { target = pNode; currentNode = pNode; if (getDocument() == null) { setDocument(pNode.getNodeType() == 9 ? (Document)pNode : pNode.getOwnerDocument()); } } public Node getTarget() { return target; } public void startDocument() throws SAXException {} public void endDocument() throws SAXException {} public void startPrefixMapping(String prefix, String uri) throws SAXException { if (isPrefixMappingIsAttribute()) { if (prefixes == null) { prefixes = new ArrayList(); } prefixes.add(prefix); prefixes.add(uri); } } public void endPrefixMapping(String prefix) throws SAXException {} public void startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttr) throws SAXException { Document doc = getDocument(); Element element; Element element; if ((pNamespaceURI == null) || (pNamespaceURI.length() == 0)) { element = doc.createElement(pQName); } else { element = doc.createElementNS(pNamespaceURI, pQName); } if (pAttr != null) { for (int i = 0; i < pAttr.getLength(); i++) { String uri = pAttr.getURI(i); String qName = pAttr.getQName(i); String value = pAttr.getValue(i); if ((uri == null) || (uri.length() == 0)) { element.setAttribute(qName, value); } else { element.setAttributeNS(uri, qName, value); } } } if (prefixes != null) { for (int i = 0; i < prefixes.size(); i += 2) { String prefix = (String)prefixes.get(i); String uri = (String)prefixes.get(i + 1); if ((prefix == null) || ("".equals(prefix))) { element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", uri); } else { element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, uri); } } prefixes.clear(); } currentNode.appendChild(element); currentNode = element; } public void endElement(String namespaceURI, String localName, String qName) throws SAXException { currentNode = currentNode.getParentNode(); } public void characters(char[] ch, int start, int length) throws SAXException { Node node = currentNode.getLastChild(); String s = new String(ch, start, length); if ((node != null) && (node.getNodeType() == 3)) { ((Text)node).appendData(s); } else { Text text = getDocument().createTextNode(s); currentNode.appendChild(text); } } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { characters(ch, start, length); } public void processingInstruction(String pTarget, String pData) throws SAXException { ProcessingInstruction pi = getDocument().createProcessingInstruction(pTarget, pData); currentNode.appendChild(pi); } public void skippedEntity(String pName) throws SAXException { EntityReference entity = getDocument().createEntityReference(pName); currentNode.appendChild(entity); } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.DOMBuilder * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.AttributesImpl; public class DOMSerializer { private boolean namespaceDeclarationAttribute; private boolean parentsNamespaceDeclarationDisabled; private boolean startingDocument = true; public void setNamespaceDeclarationAttribute(boolean pXmlDeclarationAttribute) { namespaceDeclarationAttribute = pXmlDeclarationAttribute; } public boolean isNamespaceDeclarationAttribute() { return namespaceDeclarationAttribute; } public void setParentsNamespaceDeclarationDisabled(boolean pParentsXmlDeclarationDisabled) { parentsNamespaceDeclarationDisabled = pParentsXmlDeclarationDisabled; } public boolean isParentsNamespaceDeclarationDisabled() { return parentsNamespaceDeclarationDisabled; } public boolean isStartingDocument() { return startingDocument; } public void setStartingDocument(boolean pStartingDocument) { startingDocument = pStartingDocument; } protected void doSerializeChilds(Node pNode, ContentHandler pHandler) throws SAXException { for (Node child = pNode.getFirstChild(); child != null; child = child.getNextSibling()) { doSerialize(child, pHandler); } } private void parentsStartPrefixMappingEvents(Node pNode, ContentHandler pHandler) throws SAXException { if (pNode != null) { parentsStartPrefixMappingEvents(pNode.getParentNode(), pHandler); if (pNode.getNodeType() == 1) { startPrefixMappingEvents(pNode, pHandler); } } } private void parentsEndPrefixMappingEvents(Node pNode, ContentHandler pHandler) throws SAXException { if (pNode != null) { if (pNode.getNodeType() == 1) { endPrefixMappingEvents(pNode, pHandler); } parentsEndPrefixMappingEvents(pNode.getParentNode(), pHandler); } } private void startPrefixMappingEvents(Node pNode, ContentHandler pHandler) throws SAXException { NamedNodeMap nnm = pNode.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Node attr = nnm.item(i); if ("http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())) { String prefix; if ("xmlns".equals(attr.getPrefix())) { prefix = attr.getLocalName(); } else { String prefix; if ("xmlns".equals(attr.getNodeName())) { prefix = ""; } else { throw new IllegalStateException("Unable to parse namespace declaration: " + attr.getNodeName()); } } String prefix; String uri = attr.getNodeValue(); if (uri == null) { uri = ""; } pHandler.startPrefixMapping(prefix, uri); } } } } private void endPrefixMappingEvents(Node pNode, ContentHandler pHandler) throws SAXException { NamedNodeMap nnm = pNode.getAttributes(); if (nnm != null) { for (int i = nnm.getLength() - 1; i >= 0; i--) { Node attr = nnm.item(i); if ("http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())) { String prefix = attr.getLocalName(); pHandler.endPrefixMapping(prefix); } } } } private void characters(ContentHandler pHandler, String pValue, boolean pCdata) throws SAXException { LexicalHandler lh; LexicalHandler lh; if (pCdata) { lh = (pHandler instanceof LexicalHandler) ? (LexicalHandler)pHandler : null; } else { lh = null; } if (lh != null) { lh.startCDATA(); } pHandler.characters(pValue.toCharArray(), 0, pValue.length()); if (lh != null) { lh.endCDATA(); } } public void serialize(Node pNode, ContentHandler pHandler) throws SAXException { if ((!isNamespaceDeclarationAttribute()) && (!isParentsNamespaceDeclarationDisabled())) { parentsStartPrefixMappingEvents(pNode.getParentNode(), pHandler); } doSerialize(pNode, pHandler); if ((!isNamespaceDeclarationAttribute()) && (!isParentsNamespaceDeclarationDisabled())) { parentsEndPrefixMappingEvents(pNode.getParentNode(), pHandler); } } protected void doSerialize(Node pNode, ContentHandler pHandler) throws SAXException { switch (pNode.getNodeType()) { case 9: boolean startDocumentEvent = isStartingDocument(); if (startDocumentEvent) { pHandler.startDocument(); } doSerializeChilds(pNode, pHandler); if (startDocumentEvent) { pHandler.endDocument(); } break; case 11: doSerializeChilds(pNode, pHandler); break; case 1: AttributesImpl attr = new AttributesImpl(); boolean isNamespaceDeclarationAttribute = isNamespaceDeclarationAttribute(); if (!isNamespaceDeclarationAttribute) { startPrefixMappingEvents(pNode, pHandler); } NamedNodeMap nnm = pNode.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Node a = nnm.item(i); if ((isNamespaceDeclarationAttribute) || (!"http://www.w3.org/2000/xmlns/".equals(a.getNamespaceURI()))) { String aUri = a.getNamespaceURI(); String aLocalName = a.getLocalName(); String aNodeName = a.getNodeName(); if (aLocalName == null) { if ((aUri == null) || (aUri.length() == 0)) { aLocalName = aNodeName; } else { throw new IllegalStateException("aLocalName is null"); } } attr.addAttribute(aUri == null ? "" : aUri, aNodeName, aLocalName, "CDATA", a.getNodeValue()); } } } String nUri = pNode.getNamespaceURI(); if (nUri == null) { nUri = ""; } pHandler.startElement(nUri, pNode.getLocalName(), pNode.getNodeName(), attr); doSerializeChilds(pNode, pHandler); pHandler.endElement(nUri, pNode.getLocalName(), pNode.getNodeName()); if (!isNamespaceDeclarationAttribute) { endPrefixMappingEvents(pNode, pHandler); } break; case 3: characters(pHandler, pNode.getNodeValue(), false); break; case 4: characters(pHandler, pNode.getNodeValue(), true); break; case 7: pHandler.processingInstruction(pNode.getNodeName(), pNode.getNodeValue()); break; case 5: pHandler.skippedEntity(pNode.getNodeName()); break; case 8: if ((pHandler instanceof LexicalHandler)) { String s = pNode.getNodeValue(); ((LexicalHandler)pHandler).comment(s.toCharArray(), 0, s.length()); } break; case 2: case 6: case 10: default: throw new IllegalStateException("Unknown node type: " + pNode.getNodeType()); } } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.DOMSerializer * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import java.util.Comparator; import org.xml.sax.Attributes; final class OrderedAttributeXMLWriter$1 implements Comparator { private final Attributes val$pAttrs; private final OrderedAttributeXMLWriter this$0; OrderedAttributeXMLWriter$1(OrderedAttributeXMLWriter paramOrderedAttributeXMLWriter, Attributes paramAttributes) { this$0 = paramOrderedAttributeXMLWriter;val$pAttrs = paramAttributes; } public int compare(Object pNum1, Object pNum2) { int i1 = ((Integer)pNum1).intValue(); int i2 = ((Integer)pNum2).intValue(); String uri1 = val$pAttrs.getURI(i1); if (uri1 == null) { uri1 = ""; } String uri2 = val$pAttrs.getURI(i2); if (uri2 == null) { uri2 = ""; } int result = uri1.compareTo(uri2); if (result == 0) { result = val$pAttrs.getLocalName(i1).compareTo(val$pAttrs.getLocalName(i2)); } return result; } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.OrderedAttributeXMLWriter.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import java.util.Arrays; import java.util.Comparator; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; public class OrderedAttributeXMLWriter extends XMLWriterImpl { public void startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { Integer[] attributeNumbers = new Integer[pAttrs.getLength()]; for (int i = 0; i < attributeNumbers.length; i++) { attributeNumbers[i] = new Integer(i); } Arrays.sort(attributeNumbers, new Comparator() { private final Attributes val$pAttrs; public int compare(Object pNum1, Object pNum2) { int i1 = ((Integer)pNum1).intValue(); int i2 = ((Integer)pNum2).intValue(); String uri1 = val$pAttrs.getURI(i1); if (uri1 == null) { uri1 = ""; } String uri2 = val$pAttrs.getURI(i2); if (uri2 == null) { uri2 = ""; } int result = uri1.compareTo(uri2); if (result == 0) { result = val$pAttrs.getLocalName(i1).compareTo(val$pAttrs.getLocalName(i2)); } return result; } }); AttributesImpl orderedAttributes = new AttributesImpl(); for (int i = 0; i < attributeNumbers.length; i++) { int num = attributeNumbers[i].intValue(); orderedAttributes.addAttribute(pAttrs.getURI(num), pAttrs.getLocalName(num), pAttrs.getQName(num), pAttrs.getType(num), pAttrs.getValue(num)); } super.startElement(pNamespaceURI, pLocalName, pQName, orderedAttributes); } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.OrderedAttributeXMLWriter * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; public class PassThroughXMLWriter extends XMLWriterImpl { public boolean canEncode(char c) { return true; } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.PassThroughXMLWriter * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import java.io.Writer; import org.xml.sax.ContentHandler; public abstract interface XMLWriter extends ContentHandler { public abstract void setEncoding(String paramString); public abstract String getEncoding(); public abstract void setDeclarating(boolean paramBoolean); public abstract boolean isDeclarating(); public abstract void setWriter(Writer paramWriter); public abstract Writer getWriter(); public abstract boolean canEncode(char paramChar); public abstract void setIndenting(boolean paramBoolean); public abstract boolean isIndenting(); public abstract void setIndentString(String paramString); public abstract String getIndentString(); public abstract void setLineFeed(String paramString); public abstract String getLineFeed(); public abstract void setFlushing(boolean paramBoolean); public abstract boolean isFlushing(); } /* Location: * Qualified Name: org.apache.ws.commons.serialize.XMLWriter * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.serialize; import java.io.IOException; import java.io.Writer; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; public class XMLWriterImpl implements XMLWriter { private static final int STATE_OUTSIDE = 0; private static final int STATE_IN_START_ELEMENT = 1; private static final int STATE_IN_ELEMENT = 2; private String encoding; private String indentString; private String lineFeed; private Writer w; private Locator l; private Map delayedPrefixes; int curIndent = 0; private int state; private boolean declarating; private boolean indenting; private boolean flushing; public void setEncoding(String pEncoding) { encoding = pEncoding; } public String getEncoding() { return encoding; } public void setDeclarating(boolean pDeclarating) { declarating = pDeclarating; } public boolean isDeclarating() { return declarating; } public void setIndenting(boolean pIndenting) { indenting = pIndenting; } public boolean isIndenting() { return indenting; } public void setIndentString(String pIndentString) { indentString = pIndentString; } public String getIndentString() { return indentString; } public void setLineFeed(String pLineFeed) { lineFeed = pLineFeed; } public String getLineFeed() { return lineFeed; } public void setFlushing(boolean pFlushing) { flushing = pFlushing; } public boolean isFlushing() { return flushing; } public void setWriter(Writer pWriter) { w = pWriter; } public Writer getWriter() { return w; } public void setDocumentLocator(Locator pLocator) { l = pLocator; } public Locator getDocumentLocator() { return l; } public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException { if (delayedPrefixes == null) { delayedPrefixes = new HashMap(); } if ("".equals(prefix)) { if (namespaceURI.equals(prefix)) { return; } prefix = "xmlns"; } else { prefix = "xmlns:" + prefix; } delayedPrefixes.put(prefix, namespaceURI); } public void endPrefixMapping(String prefix) throws SAXException { if (delayedPrefixes != null) { if ("".equals(prefix)) { prefix = "xmlns"; } else { prefix = "xmlns:" + prefix; } delayedPrefixes.remove(prefix); } } public void startDocument() throws SAXException { if (delayedPrefixes != null) { delayedPrefixes.clear(); } state = 0; curIndent = 0; if ((isDeclarating()) && (w != null)) { try { w.write("<?xml version=\"1.0\""); String enc = getEncoding(); if (enc != null) { w.write(" encoding=\""); w.write(enc); w.write("\""); } w.write("?>"); if (isIndenting()) { String lf = getLineFeed(); if (lf != null) { w.write(lf); } } } catch (IOException e) { throw new SAXException("Failed to write XML declaration: " + e.getMessage(), e); } } } public void endDocument() throws SAXException { if ((isFlushing()) && (w != null)) { try { w.flush(); } catch (IOException e) { throw new SAXException("Failed to flush target writer: " + e.getMessage(), e); } } } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { characters(ch, start, length); } private void stopTerminator() throws IOException { if (state == 1) { if (w != null) { w.write(62); } state = 2; } } public void characters(char[] ch, int start, int length) throws SAXException { try { stopTerminator(); if (w == null) { return; } int end = start + length; for (int i = start; i < end; i++) { char c = ch[i]; switch (c) { case '&': w.write("&"); break; case '<': w.write("<"); break; case '>': w.write(">"); break; case '\t': case '\n': case '\r': w.write(c); break; default: if (canEncode(c)) { w.write(c); } else { w.write("&#"); w.write(Integer.toString(c)); w.write(";"); } break; } } } catch (IOException e) { throw new SAXException(e); } } public boolean canEncode(char c) { return (c == '\n') || ((c >= ' ') && (c < '')); } public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (isIndenting()) { curIndent -= 1; } if (w != null) { try { if (state == 1) { w.write("/>"); state = 0; } else { if (state == 0) { indentMe(); } w.write("</"); w.write(qName); w.write(62); } state = 0; } catch (IOException e) { throw new SAXException(e); } } } private void indentMe() throws IOException { if ((w != null) && (isIndenting())) { String s = getLineFeed(); if (s != null) { w.write(s); } s = getIndentString(); if (s != null) { for (int i = 0; i < curIndent; i++) { w.write(s); } } } } private void writeCData(String v) throws IOException { int len = v.length(); for (int j = 0; j < len; j++) { char c = v.charAt(j); switch (c) { case '&': w.write("&"); break; case '<': w.write("<"); break; case '>': w.write(">"); break; case '\'': w.write("'"); break; case '"': w.write("""); break; default: if (canEncode(c)) { w.write(c); } else { w.write("&#"); w.write(Integer.toString(c)); w.write(59); } break; } } } public void startElement(String namespaceURI, String localName, String qName, Attributes attr) throws SAXException { try { stopTerminator(); if (isIndenting()) { if (curIndent > 0) { indentMe(); } curIndent += 1; } if (w != null) { w.write(60); w.write(qName); int i; if (attr != null) { for (i = attr.getLength(); i > 0;) { w.write(32); String name = attr.getQName(--i); w.write(name); if (delayedPrefixes != null) { delayedPrefixes.remove(name); } w.write("=\""); writeCData(attr.getValue(i)); w.write(34); } } if ((delayedPrefixes != null) && (delayedPrefixes.size() > 0)) { Iterator iter = delayedPrefixes.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); w.write(32); w.write((String)entry.getKey()); w.write("=\""); w.write((String)entry.getValue()); w.write(34); } delayedPrefixes.clear(); } } state = 1; } catch (IOException e) { throw new SAXException(e); } } public void skippedEntity(String ent) throws SAXException { throw new SAXException("Don't know how to skip entities"); } public void processingInstruction(String target, String data) throws SAXException { try { stopTerminator(); if (w != null) { w.write("<?"); w.write(target); w.write(32); w.write(data); w.write("?>"); } } catch (IOException e) { throw new SAXException(e); } } } /* Location: * Qualified Name: org.apache.ws.commons.serialize.XMLWriterImpl * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import java.io.Writer; final class Base64$1 extends Base64.Encoder { private final Writer val$pWriter; Base64$1(char[] x0, int x1, String x2, Writer paramWriter) { super(x0, x1, x2);val$pWriter = paramWriter; } protected void writeBuffer(char[] pBuffer, int pOffset, int pLen) throws IOException { val$pWriter.write(pBuffer, pOffset, pLen); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import java.io.OutputStream; final class Base64$2$1 extends Base64.Decoder { private final Base64.2 this$0; Base64$2$1(Base64.2 param2, int x0) { super(x0);this$0 = param2; } protected void writeBuffer(byte[] pBytes, int pOffset, int pLen) throws IOException { Base64.2.access$200(this$0).write(pBytes, pOffset, pLen); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.2.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; final class Base64$2 extends Writer { private final Base64.Decoder decoder; private final OutputStream val$pStream; Base64$2(OutputStream paramOutputStream) { val$pStream = paramOutputStream; decoder = new Base64.Decoder(1024) { protected void writeBuffer(byte[] pBytes, int pOffset, int pLen) throws IOException { val$pStream.write(pBytes, pOffset, pLen); } }; } public void close() throws IOException { flush(); } public void flush() throws IOException { decoder.flush(); val$pStream.flush(); } public void write(char[] cbuf, int off, int len) throws IOException { decoder.write(cbuf, off, len); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.2 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.ByteArrayOutputStream; import java.io.IOException; final class Base64$3 extends Base64.Decoder { private final ByteArrayOutputStream val$baos; Base64$3(int x0, ByteArrayOutputStream paramByteArrayOutputStream) { super(x0);val$baos = paramByteArrayOutputStream; } protected void writeBuffer(byte[] pBuf, int pOff, int pLen) throws IOException { val$baos.write(pBuf, pOff, pLen); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.3 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; public abstract class Base64$Decoder { private final byte[] byteBuffer; private int byteBufferOffset; private int num; private int numBytes; private int eofBytes; protected Base64$Decoder(int pBufLen) { byteBuffer = new byte[pBufLen]; } protected abstract void writeBuffer(byte[] paramArrayOfByte, int paramInt1, int paramInt2) throws IOException; public void write(char[] pData, int pOffset, int pLen) throws IOException { for (int i = 0; i < pLen; i++) { char c = pData[(pOffset++)]; if (!Character.isWhitespace(c)) { if (c == '=') { eofBytes += 1; num <<= 6; switch (++numBytes) { case 1: case 2: throw new Base64.DecodingException("Unexpected end of stream character (=)"); case 3: break; case 4: byteBuffer[(byteBufferOffset++)] = ((byte)(num >> 16)); if (eofBytes == 1) { byteBuffer[(byteBufferOffset++)] = ((byte)(num >> 8)); } writeBuffer(byteBuffer, 0, byteBufferOffset); byteBufferOffset = 0; break; case 5: throw new Base64.DecodingException("Trailing garbage detected"); default: throw new IllegalStateException("Invalid value for numBytes"); } } else { if (eofBytes > 0) { throw new Base64.DecodingException("Base64 characters after end of stream character (=) detected."); } if ((c >= 0) && (c < Base64.access$100().length)) { int result = Base64.access$100()[c]; if (result >= 0) { num = ((num << 6) + result); if (++numBytes != 4) { continue; } byteBuffer[(byteBufferOffset++)] = ((byte)(num >> 16)); byteBuffer[(byteBufferOffset++)] = ((byte)(num >> 8 & 0xFF)); byteBuffer[(byteBufferOffset++)] = ((byte)(num & 0xFF)); if (byteBufferOffset + 3 > byteBuffer.length) { writeBuffer(byteBuffer, 0, byteBufferOffset); byteBufferOffset = 0; } num = 0; numBytes = 0; continue; } } if (!Character.isWhitespace(c)) { throw new Base64.DecodingException("Invalid Base64 character: " + c); } } } } } public void flush() throws IOException { if ((numBytes != 0) && (numBytes != 4)) { throw new Base64.DecodingException("Unexpected end of file"); } if (byteBufferOffset > 0) { writeBuffer(byteBuffer, 0, byteBufferOffset); byteBufferOffset = 0; } } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.Decoder * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; public class Base64$DecodingException extends IOException { private static final long serialVersionUID = 3257006574836135478L; Base64$DecodingException(String pMessage) { super(pMessage); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.DecodingException * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; public abstract class Base64$Encoder { private int num; private int numBytes; private final char[] charBuffer; private int charOffset; private final int wrapSize; private final int skipChars; private final String sep; private int lineChars = 0; protected Base64$Encoder(char[] pBuffer, int pWrapSize, String pSep) { charBuffer = pBuffer; sep = (pSep == null ? null : "\n"); skipChars = (pWrapSize == 0 ? 4 : 4 + sep.length()); wrapSize = (skipChars == 4 ? 0 : pWrapSize); if ((wrapSize < 0) || (wrapSize % 4 > 0)) { throw new IllegalArgumentException("Illegal argument for wrap size: " + pWrapSize + "(Expected nonnegative multiple of 4)"); } if (pBuffer.length < skipChars) { throw new IllegalArgumentException("The buffer must contain at least " + skipChars + " characters, but has " + pBuffer.length); } } protected abstract void writeBuffer(char[] paramArrayOfChar, int paramInt1, int paramInt2) throws IOException; private void wrap() { for (int j = 0; j < sep.length(); j++) { charBuffer[(charOffset++)] = sep.charAt(j); } lineChars = 0; } public void write(byte[] pBuffer, int pOffset, int pLen) throws IOException { for (int i = 0; i < pLen; i++) { int b = pBuffer[(pOffset++)]; if (b < 0) { b += 256; } num = ((num << 8) + b); if (++numBytes == 3) { charBuffer[(charOffset++)] = Base64.access$000()[(num >> 18)]; charBuffer[(charOffset++)] = Base64.access$000()[(num >> 12 & 0x3F)]; charBuffer[(charOffset++)] = Base64.access$000()[(num >> 6 & 0x3F)]; charBuffer[(charOffset++)] = Base64.access$000()[(num & 0x3F)]; if (wrapSize > 0) { lineChars += 4; if (lineChars >= wrapSize) { wrap(); } } num = 0; numBytes = 0; if (charOffset + skipChars > charBuffer.length) { writeBuffer(charBuffer, 0, charOffset); charOffset = 0; } } } } public void flush() throws IOException { if (numBytes > 0) { if (numBytes == 1) { charBuffer[(charOffset++)] = Base64.access$000()[(num >> 2)]; charBuffer[(charOffset++)] = Base64.access$000()[(num << 4 & 0x3F)]; charBuffer[(charOffset++)] = '='; charBuffer[(charOffset++)] = '='; } else { charBuffer[(charOffset++)] = Base64.access$000()[(num >> 10)]; charBuffer[(charOffset++)] = Base64.access$000()[(num >> 4 & 0x3F)]; charBuffer[(charOffset++)] = Base64.access$000()[(num << 2 & 0x3F)]; charBuffer[(charOffset++)] = '='; } lineChars += 4; num = 0; numBytes = 0; } if ((wrapSize > 0) && (lineChars > 0)) { wrap(); } if (charOffset > 0) { writeBuffer(charBuffer, 0, charOffset); charOffset = 0; } } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.Encoder * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import java.io.OutputStream; public class Base64$EncoderOutputStream extends OutputStream { private final Base64.Encoder encoder; public Base64$EncoderOutputStream(Base64.Encoder pEncoder) { encoder = pEncoder; } private final byte[] oneByte = new byte[1]; public void write(int b) throws IOException { oneByte[0] = ((byte)b); encoder.write(oneByte, 0, 1); } public void write(byte[] pBuffer, int pOffset, int pLen) throws IOException { encoder.write(pBuffer, pOffset, pLen); } public void close() throws IOException { encoder.flush(); } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.EncoderOutputStream * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; public class Base64$SAXEncoder extends Base64.Encoder { private final ContentHandler handler; public Base64$SAXEncoder(char[] pBuffer, int pWrapSize, String pSep, ContentHandler pHandler) { super(pBuffer, pWrapSize, pSep); handler = pHandler; } protected void writeBuffer(char[] pChars, int pOffset, int pLen) throws IOException { try { handler.characters(pChars, pOffset, pLen); } catch (SAXException e) { throw new Base64.SAXIOException(e); } } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.SAXEncoder * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.IOException; import org.xml.sax.SAXException; public class Base64$SAXIOException extends IOException { private static final long serialVersionUID = 3258131345216451895L; final SAXException saxException; Base64$SAXIOException(SAXException e) { saxException = e; } public SAXException getSAXException() { return saxException; } } /* Location: * Qualified Name: org.apache.ws.commons.util.Base64.SAXIOException * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.apache.ws.commons.util; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.UndeclaredThrowableException; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; public class Base64 { public static final String LINE_SEPARATOR = "\n"; public static final int LINE_SIZE = 76; public static class DecodingException extends IOException { private static final long serialVersionUID = 3257006574836135478L; DecodingException(String pMessage) { super(); } } public static class SAXIOException extends IOException { private static final long serialVersionUID = 3258131345216451895L; final SAXException saxException; SAXIOException(SAXException e) { saxException = e; } public SAXException getSAXException() { return saxException; } } private static final char[] intToBase64 = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; private static final byte[] base64ToInt = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 }; public static abstract class Encoder { private int num; private int numBytes; private final char[] charBuffer; private int charOffset; private final int wrapSize; private final int skipChars; private final String sep; private int lineChars = 0; protected Encoder(char[] pBuffer, int pWrapSize, String pSep) { charBuffer = pBuffer; sep = (pSep == null ? null : "\n"); skipChars = (pWrapSize == 0 ? 4 : 4 + sep.length()); wrapSize = (skipChars == 4 ? 0 : pWrapSize); if ((wrapSize < 0) || (wrapSize % 4 > 0)) { throw new IllegalArgumentException("Illegal argument for wrap size: " + pWrapSize + "(Expected nonnegative multiple of 4)"); } if (pBuffer.length < skipChars) { throw new IllegalArgument Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|