Package java.beans

Examples of java.beans.XMLDecoder.readObject()


  @SuppressWarnings("unchecked")
  public static <T> T deserializeObject(InputStream in) {
    XMLDecoder d = null;
    try {
      d = new XMLDecoder(in, null, null);
      return (T) d.readObject();
    } finally {
      if (null != d) {
        d.close();
      }
    }
View Full Code Here


        }

        public void putAdaptedBeansToMap(Map<String, Object> elementsMap) {
            XMLDecoder d = createDecoder();
            for (String id : idList) {
                elementsMap.put(id, d.readObject());
            }
            d.close();

        }
    }
View Full Code Here

            final InputStream inputStream = getInputStream( key );

            try
            {
                final XMLDecoder decoder = new XMLDecoder( inputStream );
                final Object object = decoder.readObject();
                if( DEBUG )
                {
                    monitor.returningKey(XMLFilePersistentObjectRepository.class, key);
                }
                return object;
View Full Code Here

            final ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader( classLoader );
            try
            {
                final XMLDecoder decoder = new XMLDecoder( inputStream );
                final Object object = decoder.readObject();
                if( DEBUG )
                {
                    monitor.returningObjectForKey(XMLFilePersistentObjectRepository.class, object, key);
                }
                return object;
View Full Code Here

    }

    public void load(String fileName) throws FileNotFoundException {
  FileInputStream in = new FileInputStream(fileName);
  XMLDecoder xmlDecoder = new XMLDecoder(in);
  playerList = (List<Player>) xmlDecoder.readObject();
  xmlDecoder.close();
    }
}
View Full Code Here

    {
        try
        {
            Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
            XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( ( new FileInputStream( filename ) ) ) );
            Object object = decoder.readObject();
            decoder.close();
            return object;
        }
        catch ( IOException ioe )
        {
View Full Code Here

            // if loading failed, try with temp file
            String tempFilename = filename + "-temp";
            try
            {
                XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( ( new FileInputStream( tempFilename ) ) ) );
                Object object = decoder.readObject();
                decoder.close();
                return object;
            }
            catch ( IOException ioe2 )
            {
View Full Code Here

    public static Object deserialize( String s )
    {
        Thread.currentThread().setContextClassLoader( Utils.class.getClassLoader() );
        ByteArrayInputStream bais = new ByteArrayInputStream( LdifUtils.utf8encode( s ) );
        XMLDecoder decoder = new XMLDecoder( bais );
        Object o = decoder.readObject();
        decoder.close();
        return o;
    }

View Full Code Here

        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(ConnectionSettings.class.getClassLoader());
        try {

            XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml.getBytes()));
            ConnectionSettings newSettings = (ConnectionSettings) dec.readObject();
            return newSettings;
        } finally{
            Thread.currentThread().setContextClassLoader(oldLoader);
        }
    }
View Full Code Here

      throw new RuntimeException("UTF-8 support required", ex);
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    XMLDecoder decoder = new XMLDecoder(bais, null, null, conf.getClassLoader());
    try {
      ExprNodeDesc expr = (ExprNodeDesc) decoder.readObject();
      return expr;
    } finally {
      decoder.close();
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.