jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/FastInfosetDataContentHandler.java
changeset 43852 93a527059d8a
parent 28326 2b9860c0d68a
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, 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
    45 
    45 
    46     public FastInfosetDataContentHandler() {
    46     public FastInfosetDataContentHandler() {
    47     }
    47     }
    48 
    48 
    49     /**
    49     /**
    50      * return the DataFlavors for this <code>DataContentHandler</code>
    50      * Return the DataFlavors for this <code>DataContentHandler</code>
    51      * @return The DataFlavors.
    51      * @return The DataFlavors.
    52      */
    52      */
       
    53     @Override
    53     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    54     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    54         DataFlavor flavors[] = new DataFlavor[1];
    55         DataFlavor flavors[] = new DataFlavor[1];
    55         flavors[0] = new ActivationDataFlavor(
    56         flavors[0] = new ActivationDataFlavor(
    56                 FastInfosetReflection.getFastInfosetSource_class(),
    57                 FastInfosetReflection.getFastInfosetSource_class(),
    57                 "application/fastinfoset", "Fast Infoset");
    58                 "application/fastinfoset", "Fast Infoset");
    58         return flavors;
    59         return flavors;
    59     }
    60     }
    60 
    61 
    61     /**
    62     /**
    62      * return the Transfer Data of type DataFlavor from InputStream
    63      * Return the Transfer Data of type DataFlavor from InputStream
    63      * @param df The DataFlavor.
    64      * @param flavor The DataFlavor.
    64      * @param ins The InputStream corresponding to the data.
    65      * @param dataSource DataSource.
    65      * @return The constructed Object.
    66      * @return The constructed Object.
       
    67      * @exception IOException in case of an I/O error
    66      */
    68      */
       
    69     @Override
    67     public Object getTransferData(DataFlavor flavor, DataSource dataSource)
    70     public Object getTransferData(DataFlavor flavor, DataSource dataSource)
    68         throws IOException
    71         throws IOException
    69     {
    72     {
    70         if (flavor.getMimeType().startsWith("application/fastinfoset")) {
    73         if (flavor.getMimeType().startsWith("application/fastinfoset")) {
    71             try {
    74             try {
    79             }
    82             }
    80         }
    83         }
    81         return null;
    84         return null;
    82     }
    85     }
    83 
    86 
       
    87     @Override
    84     public Object getContent(DataSource dataSource) throws IOException {
    88     public Object getContent(DataSource dataSource) throws IOException {
    85         try {
    89         try {
    86             return FastInfosetReflection.FastInfosetSource_new(
    90             return FastInfosetReflection.FastInfosetSource_new(
    87                 dataSource.getInputStream());
    91                 dataSource.getInputStream());
    88         }
    92         }
    90             throw new IOException(e.getMessage());
    94             throw new IOException(e.getMessage());
    91         }
    95         }
    92     }
    96     }
    93 
    97 
    94     /**
    98     /**
    95      * construct an object from a byte stream
    99      * Construct an object from a byte stream
    96      * (similar semantically to previous method, we are deciding
   100      * (similar semantically to previous method, we are deciding
    97      *  which one to support)
   101      *  which one to support)
    98      */
   102      */
       
   103     @Override
    99     public void writeTo(Object obj, String mimeType, OutputStream os)
   104     public void writeTo(Object obj, String mimeType, OutputStream os)
   100         throws IOException
   105         throws IOException
   101     {
   106     {
   102         if (!mimeType.equals("application/fastinfoset")) {
   107         if (!mimeType.equals("application/fastinfoset")) {
   103             throw new IOException("Invalid content type \"" + mimeType
   108             throw new IOException("Invalid content type \"" + mimeType