src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/staxex/Base64Data.java

Print this page
rev 447 : 8029237: Update copyright year to match last edit in jdk8 jaxws repository (2013)
Summary: Fixing Copyrights for year 2013
Reviewed-by: chegar
rev 472 : 8036030: Update JAX-WS RI integration to latest version
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  45 //import java.io.FileWriter;
  46 //import javax.activation.FileDataSource;
  47 
  48 /**
  49  * Binary data represented as base64-encoded string
  50  * in XML.
  51  *
  52  * <p>
  53  * Used in conjunction with {@link XMLStreamReaderEx}
  54  * and {@link XMLStreamWriterEx}.
  55  *
  56  * @author Kohsuke Kawaguchi, Martin Grebac
  57  */
  58 public class Base64Data implements CharSequence, Cloneable {
  59 
  60     // either dataHandler or (data,dataLen,mimeType?) must be present
  61     // (note that having both is allowed)
  62 
  63     private DataHandler dataHandler;
  64     private byte[] data;

  65 
  66     /**
  67      * Length of the valid data in {@link #data}.
  68      */
  69     private int dataLen;
  70     /**
  71      * True if {@link #data} can be cloned by reference
  72      * if Base64Data instance is cloned.
  73      */
  74     private boolean dataCloneByRef;
  75     /**
  76      * Optional MIME type of {@link #data}.
  77      *
  78      * Unused when {@link #dataHandler} is set.
  79      * Use {@link DataHandler#getContentType()} in that case.
  80      */
  81     private String mimeType;
  82 
  83     /**
  84      * Default constructor


 514         }
 515     }
 516 
 517 //    public static void main(String[] args) throws FileNotFoundException, IOException, XMLStreamException {
 518 //        Base64Data data = new Base64Data();
 519 //
 520 //        File f = new File("/Users/snajper/work/builds/weblogic/wls1211_dev.zip");
 521 //        FileDataSource fds = new FileDataSource(f);
 522 //        DataHandler dh = new DataHandler(fds);
 523 //        data.set(dh);
 524 //
 525 //        FileWriter fw = new FileWriter(new File("/Users/snajper/Desktop/b.txt"));
 526 //        XMLStreamWriterImpl wi = new XMLStreamWriterImpl(fw, null);
 527 //
 528 //        data.writeTo(wi);
 529 //        wi.flush();fw.flush();
 530 //        //System.out.println("SW: " + sw.toString());
 531 //
 532 //    }
 533 












 534 }
   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  45 //import java.io.FileWriter;
  46 //import javax.activation.FileDataSource;
  47 
  48 /**
  49  * Binary data represented as base64-encoded string
  50  * in XML.
  51  *
  52  * <p>
  53  * Used in conjunction with {@link XMLStreamReaderEx}
  54  * and {@link XMLStreamWriterEx}.
  55  *
  56  * @author Kohsuke Kawaguchi, Martin Grebac
  57  */
  58 public class Base64Data implements CharSequence, Cloneable {
  59 
  60     // either dataHandler or (data,dataLen,mimeType?) must be present
  61     // (note that having both is allowed)
  62 
  63     private DataHandler dataHandler;
  64     private byte[] data;
  65     private String hrefCid;
  66 
  67     /**
  68      * Length of the valid data in {@link #data}.
  69      */
  70     private int dataLen;
  71     /**
  72      * True if {@link #data} can be cloned by reference
  73      * if Base64Data instance is cloned.
  74      */
  75     private boolean dataCloneByRef;
  76     /**
  77      * Optional MIME type of {@link #data}.
  78      *
  79      * Unused when {@link #dataHandler} is set.
  80      * Use {@link DataHandler#getContentType()} in that case.
  81      */
  82     private String mimeType;
  83 
  84     /**
  85      * Default constructor


 515         }
 516     }
 517 
 518 //    public static void main(String[] args) throws FileNotFoundException, IOException, XMLStreamException {
 519 //        Base64Data data = new Base64Data();
 520 //
 521 //        File f = new File("/Users/snajper/work/builds/weblogic/wls1211_dev.zip");
 522 //        FileDataSource fds = new FileDataSource(f);
 523 //        DataHandler dh = new DataHandler(fds);
 524 //        data.set(dh);
 525 //
 526 //        FileWriter fw = new FileWriter(new File("/Users/snajper/Desktop/b.txt"));
 527 //        XMLStreamWriterImpl wi = new XMLStreamWriterImpl(fw, null);
 528 //
 529 //        data.writeTo(wi);
 530 //        wi.flush();fw.flush();
 531 //        //System.out.println("SW: " + sw.toString());
 532 //
 533 //    }
 534 
 535     public String getHrefCid() {
 536         if (hrefCid == null && dataHandler != null && dataHandler instanceof StreamingDataHandler) {
 537             hrefCid = ((StreamingDataHandler)dataHandler).getHrefCid();
 538         }
 539         return hrefCid;
 540     }
 541 
 542     public void setHrefCid(final String cid) {
 543         this.hrefCid = cid;
 544         if (dataHandler != null && dataHandler instanceof StreamingDataHandler) ((StreamingDataHandler)dataHandler).setHrefCid(cid);
 545     }
 546 
 547 }