jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/XmlDataContentHandler.java
changeset 43852 93a527059d8a
parent 33547 e4c76ac38b12
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    54 
    54 
    55     /**
    55     /**
    56      * return the DataFlavors for this <code>DataContentHandler</code>
    56      * return the DataFlavors for this <code>DataContentHandler</code>
    57      * @return The DataFlavors.
    57      * @return The DataFlavors.
    58      */
    58      */
       
    59     @Override
    59     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    60     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    60         DataFlavor flavors[] = new DataFlavor[2];
    61         DataFlavor flavors[] = new DataFlavor[2];
    61 
    62 
    62         flavors[0] =
    63         flavors[0] =
    63             new ActivationDataFlavor(streamSourceClass, "text/xml", "XML");
    64             new ActivationDataFlavor(streamSourceClass, "text/xml", "XML");
    67         return flavors;
    68         return flavors;
    68     }
    69     }
    69 
    70 
    70     /**
    71     /**
    71      * return the Transfer Data of type DataFlavor from InputStream
    72      * return the Transfer Data of type DataFlavor from InputStream
    72      * @param df The DataFlavor.
    73      * @param flavor The DataFlavor.
    73      * @param ins The InputStream corresponding to the data.
    74      * @param dataSource The DataSource.
    74      * @return The constructed Object.
    75      * @return The constructed Object.
    75      */
    76      */
       
    77     @Override
    76     public Object getTransferData(DataFlavor flavor, DataSource dataSource)
    78     public Object getTransferData(DataFlavor flavor, DataSource dataSource)
    77         throws IOException {
    79         throws IOException {
    78         if (flavor.getMimeType().startsWith("text/xml") ||
    80         if (flavor.getMimeType().startsWith("text/xml") ||
    79                 flavor.getMimeType().startsWith("application/xml")) {
    81                 flavor.getMimeType().startsWith("application/xml")) {
    80             if (flavor.getRepresentationClass().getName().equals(STR_SRC)) {
    82             if (flavor.getRepresentationClass().getName().equals(STR_SRC)) {
    85     }
    87     }
    86 
    88 
    87     /**
    89     /**
    88      *
    90      *
    89      */
    91      */
       
    92     @Override
    90     public Object getContent(DataSource dataSource) throws IOException {
    93     public Object getContent(DataSource dataSource) throws IOException {
    91         return new StreamSource(dataSource.getInputStream());
    94         return new StreamSource(dataSource.getInputStream());
    92     }
    95     }
    93 
    96 
    94     /**
    97     /**
    95      * construct an object from a byte stream
    98      * construct an object from a byte stream
    96      * (similar semantically to previous method, we are deciding
    99      * (similar semantically to previous method, we are deciding
    97      *  which one to support)
   100      *  which one to support)
    98      */
   101      */
       
   102     @Override
    99     public void writeTo(Object obj, String mimeType, OutputStream os)
   103     public void writeTo(Object obj, String mimeType, OutputStream os)
   100         throws IOException {
   104         throws IOException {
   101         if (!mimeType.startsWith("text/xml") && !mimeType.startsWith("application/xml"))
   105         if (!mimeType.startsWith("text/xml") && !mimeType.startsWith("application/xml"))
   102             throw new IOException(
   106             throw new IOException(
   103                 "Invalid content type \"" + mimeType + "\" for XmlDCH");
   107                 "Invalid content type \"" + mimeType + "\" for XmlDCH");