Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: Ikasan.java 130 2009-06-05 17:01:24Z karianna $
   * $URL: https://ikasaneip.svn.sourceforge.net/svnroot/ikasaneip/tags/ikasan-0.7.3/common/src/main/java/org/ikasan/common/configuration/Ikasan.java $
   * 
   * ====================================================================
   * Ikasan Enterprise Integration Platform
   * Copyright (c) 2003-2008 Mizuho International plc. and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the 
  * Free Software Foundation Europe e.V. Talstrasse 110, 40217 Dusseldorf, Germany 
  * or see the FSF site: http://www.fsfeurope.org/.
  * ====================================================================
  */
 package org.ikasan.common.configuration;
 
 
Java representation of the Ikasan XML configuration file.

Author(s):
Ikasan Development Team
 
 public class Ikasan
     extends AbstractIkasan
 {

    
Default constructor
 
     public Ikasan()
     {
         // Do Nothing
     }

    
Constructor: creates new Ikasan instance

Parameters:
noNamespaceSchemaLocation
 
     public Ikasan(String noNamespaceSchemaLocation)
     {
         this. = noNamespaceSchemaLocation;
     }

    
Returns a string representation of this object.
 
     @Override
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
         sb.append("Ikasan [");
 
         // String values of each entry
         StringBuilder sbEntries = new StringBuilder();
         for(Entry entry : this.getEntries())
             sbEntries.append(entry.toString());
 
         sb.append(sbEntries);
         sb.append("].");
         return sb.toString();
     }

    
Equality test

Parameters:
ikasan
Returns:
boolean
 
     public boolean equals(final Ikasan ikasan)
     {
         if (this.getEntries() == null && ikasan.getEntries() == null)
         {
             // compare each entry with each entry in the incoming entries
             for(int x=0; x < ikasan.getEntries().size(); x++)
             {
                 // return false if any do not match
                 if( !(this..get(x).equals(ikasan.getEntries().get(x))) )
                     return false;
             }
 
            // if we're here they must all match
            return true;
        }
        // something was null and therefore no match
        return false;
    }

    
Converts the object to an XML string

Returns:
resulting XML string
    public String toXML()
    {
        XStream xstream = new XStream(new XppDriver(new XmlFriendlyReplacer(
            "$""_")));
        setXstreamProps(xstream);
        return xstream.toXML(this);
    }

    
Converts an incoming XML string to an object

Parameters:
xml XML string
Returns:
the Ikasan instance
    public static Ikasan fromXML(final String xml)
    {
        XStream xstream = new XStream(new DomDriver());
        setXstreamProps(xstream);
        return (Ikasanxstream.fromXML(xml);
    }

    
Converts an incoming XML string to an object

Parameters:
xml XML input stream
Returns:
the Ikasan instance
    public static Ikasan fromXML(final InputStream xml)
    {
        XStream xstream = new XStream(new DomDriver());
        setXstreamProps(xstream);
        return (Ikasanxstream.fromXML(xml);
    }

    
Sets the common properties for the toXML/fromXML XStream object

Parameters:
xstream
    private static void setXstreamProps(XStream xstream)
    {
        xstream.registerConverter(new IkasanConverter());
        xstream.alias(Ikasan.class.getSimpleName(), Ikasan.class);
        xstream.registerConverter(new EntryConverter());
        xstream.alias(Entry.class.getSimpleName(), Entry.class);
    }
New to GrepCode? Check out our FAQ X