Package java.beans

Examples of java.beans.XMLEncoder


  {
    UserManagerConfig config = new UserManagerConfig();
    List users = new ArrayList( usersMap.values() );
    config.setUsers(users);
   
    XMLEncoder encoder = new XMLEncoder( new BufferedOutputStream( out ) );
    encoder.writeObject(config);
    encoder.close();
  }
View Full Code Here


   * @return an XML String containing all the EventDAta items.
   */
  public static String toXML(Map<String, Object> map) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      XMLEncoder encoder = new XMLEncoder(baos);
      encoder.setExceptionListener(new ExceptionListener() {
        public void exceptionThrown(Exception exception) {
          exception.printStackTrace();
        }
      });
      encoder.writeObject(map);
      encoder.close();
      return baos.toString();
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

    // the OutputMunger strips off the XMLEncoder header
    OutputMunger bos = new OutputMunger( out);
    PrintWriter pw = new PrintWriter( bos);

    XMLEncoder beanEncoder = new XMLEncoder( bos);
    beanEncoder.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception exception) {
        System.out.println("XMLStore.save() got Exception: abort saving the preferences!");
        exception.printStackTrace();
        outputExceptionMessage = exception.getMessage();
      }
View Full Code Here

   /**
    * @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChannelXmlBean, java.lang.String)
    */
   public void write(ChannelXmlBean channelBean, String filename)
         throws FileNotFoundException {
      XMLEncoder os = getXmlEncoder(filename);
      os.writeObject(channelBean);
      os.close();
   }
View Full Code Here

   /**
    * @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChangeListXmlBean, java.lang.String)
    */
   public void write(ChangeListXmlBean changeBean, String filename)
         throws FileNotFoundException {
      XMLEncoder os = getXmlEncoder(filename);
      os.writeObject(changeBean);
      os.close();
   }
View Full Code Here

   /**
    * @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChangeListXmlBean, net.sourceforge.squirrel_sql.fw.util.FileWrapper)
    */
   public void write(ChangeListXmlBean changeBean, FileWrapper file)
         throws FileNotFoundException {
      XMLEncoder os = getXmlEncoder(file.getAbsolutePath());
      os.writeObject(changeBean);
      os.close();
   }
View Full Code Here

      return (ChangeListXmlBean) result;     
   }
  
   private XMLEncoder getXmlEncoder(String filename)
         throws FileNotFoundException {
      XMLEncoder result = null;
      BufferedOutputStream os =
         new BufferedOutputStream(new FileOutputStream(filename));
      result = new XMLEncoder(os);
      result.setPersistenceDelegate(ArtifactAction.class, enumDelegate);
      return result;
   }
View Full Code Here

     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        XMLEncoder encoder = new XMLEncoder( out );
        encoder.setExceptionListener( this );
       
        try
        {
            // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4426674
            encoder.setPersistenceDelegate( BigInteger.class, encoder.getPersistenceDelegate( Integer.class ) );
            encoder.setPersistenceDelegate( BigDecimal.class, encoder.getPersistenceDelegate( Integer.class ) );

            encoder.writeObject( obj );
        }
        finally
        {
            encoder.close();
        }
    }
View Full Code Here

    protected abstract String getPersistedFileName();

    private void save(){
        try {
            XMLEncoder encoder = new XMLEncoder(
                    new BufferedOutputStream(
                            new FileOutputStream(getPersistedFileName())));
            Map<String, AlertInfo> persistedAlerts = new HashMap<String, AlertInfo>();
            persistedAlerts.putAll(alerts);
            encoder.writeObject(persistedAlerts);
            encoder.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

                                          ActionForward resultForward)
        throws IOException {

        if("true".equals(request.getParameter("debug.xml"))){
            response.setContentType("text/xml");
            XMLEncoder encoder = new XMLEncoder(response.getOutputStream());
            for(Enumeration en=request.getAttributeNames();
                en.hasMoreElements();){
                String attribute = (String)en.nextElement();
                Object attrValue = request.getAttribute(attribute);
                encoder.writeObject(attribute);
                encoder.writeObject(attrValue);
            }

            encoder.writeObject(request);
            encoder.close();
            resultForward = null;
        }
        return resultForward;
    }
View Full Code Here

TOP

Related Classes of java.beans.XMLEncoder

Copyright © 2018 www.massapicom. 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.