pom.xml0000644000175000017500000000510011335256514012602 0ustar giovannigiovanni global org.freehep 8 4.0.0 org.freehep freehep-xml 2.1.2 FreeHEP XML FreeHEP XML Library freehep-maven Maven FreeHEP http://java.freehep.org/maven2 GUI gui exec-maven-plugin org.codehaus.mojo 0.4-SNAPSHOT GUI package exec java -classpath org.freehep.xml.menus.test.Test org.freehep freehep-io 2.0.2 org.freehep freehep-util 2.0.2 org.freehep freehep-swing 2.0.3 jdom jdom junit junit scm:svn:svn://svn.freehep.org/svn/freehep/tags/freehep-xml-2.1.2 scm:svn:svn://svn.freehep.org/svn/freehep/tags/freehep-xml-2.1.2 src/0000755000175000017500000000000011335255452012060 5ustar giovannigiovannisrc/test/0000755000175000017500000000000011335255452013037 5ustar giovannigiovannisrc/test/java/0000755000175000017500000000000011335255452013760 5ustar giovannigiovannisrc/test/java/org/0000755000175000017500000000000011335255452014547 5ustar giovannigiovannisrc/test/java/org/freehep/0000755000175000017500000000000011335255452016165 5ustar giovannigiovannisrc/test/java/org/freehep/xml/0000755000175000017500000000000011335255452016765 5ustar giovannigiovannisrc/test/java/org/freehep/xml/io/0000755000175000017500000000000011335255452017374 5ustar giovannigiovannisrc/test/java/org/freehep/xml/io/test/0000755000175000017500000000000011335255452020353 5ustar giovannigiovannisrc/test/java/org/freehep/xml/io/test/testXMLIO.java0000644000175000017500000000707111335255452023013 0ustar giovannigiovanni/* * testXMLIO.java * JUnit based test * * Created on July 15, 2002, 11:16 AM */ package org.freehep.xml.io.test; import junit.framework.*; import java.util.*; import org.freehep.xml.io.*; import org.jdom.*; /** * * @author turri */ public class testXMLIO extends TestCase { protected XMLIOManager xmlioManager = new XMLIOManager("testXMLIO.xml"); private Vector saveVect = new Vector(); private Vector restoreVect = new Vector(); private Vector createdVect = new Vector(); private Random r; private int nAvailableObjs = 6; private int maxNumberObjs = 10; private int maxNDaughters = 7; public testXMLIO(java.lang.String testName) { super(testName); xmlioManager.setClassId( ObjA.class, "arbor"); xmlioManager.getXMLIORegistry().register( new ObjAFactory() ); xmlioManager.getXMLIORegistry().register( new ObjBCDEFactory() ); xmlioManager.getXMLIORegistry().register( new ObjDProxy() ); xmlioManager.getXMLIORegistry().register( (XMLIOProxy) new ObjEFProxyFFactory() ); r = new Random(); xmlioManager.setClassId( ObjD.class, "dusk"); } public static void main(java.lang.String[] args) { for ( int i = 0; i < 30; i++ ) junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite(testXMLIO.class); return suite; } public void testSaveRestore() { int startObjs = r.nextInt(maxNumberObjs) + 1; for ( int i = 0; i < startObjs; i++ ) { Object obj = createObject(r.nextInt(nAvailableObjs), r.nextInt(), 0); saveVect.add( obj ); } Element saveEl = new Element("testXMLIO"); xmlioManager.saveToXML( saveVect.toArray(), saveEl ); Object[] objs = xmlioManager.restoreFromXML(); for ( int i = 0; i < objs.length; i++ ) restoreVect.add(objs[i]); assertEquals(saveVect.size(), startObjs); assertEquals(saveVect.size(), restoreVect.size()); for ( int i = 0; i < startObjs; i++ ) { assertTrue( ((AbstractObj)saveVect.get(i)).equalsObj( restoreVect.get(i) ) ); } } private Object createObject( int index, int status, int treeLevel ) { Object obj; int nCreatedObjs = createdVect.size(); if ( r.nextDouble() < .2 && nCreatedObjs > 0 ) obj = createdVect.get( r.nextInt( nCreatedObjs ) ); else { switch ( index ) { case 0 : obj = new ObjA(status); break; case 1 : obj = new ObjB(status); break; case 2 : obj = new ObjC(status); break; case 3 : obj = new ObjD(status); break; case 4 : obj = new ObjE(status); break; case 5 : obj = new ObjF(status); break; default : throw new RuntimeException("Wrong index for object creation"); } createdVect.add( obj ); int daus = r.nextInt(maxNDaughters-treeLevel); for ( int j = 0; j"); writer.openTag("Section"); writer.setAttribute("Useless", true); writer.setAttribute("Unicode", "\u45B0"); writer.printTag("Paragraph"); writer.closeTag(); writer.println("Some Text in the middle of nowhere..."); writer.println(" & some extra lines,"); writer.println(" \nwritten my Donszelmann"); writer.println(" and some unicode \u03A8 "); try { writer.printTag("Illegal Tag"); } catch (RuntimeException invalidName) { try { writer.closeDoc(); } catch (RuntimeException openTagException) { writer.close(); System.exit(0); } throw new RuntimeException("Should have thrown a Exception for closing the document too early..."); } throw new RuntimeException("Should have thrown an Exception for an illegal tag..."); } throw new RuntimeException("Should have thrown a Exception for an illegal comment..."); } } src/test/java/org/freehep/xml/util/test/package.html0000644000175000017500000000005211335255452023177 0ustar giovannigiovanni Test for the XML utilities. src/main/0000755000175000017500000000000011335255452013004 5ustar giovannigiovannisrc/main/java/0000755000175000017500000000000011335255452013725 5ustar giovannigiovannisrc/main/java/org/0000755000175000017500000000000011335255452014514 5ustar giovannigiovannisrc/main/java/org/freehep/0000755000175000017500000000000011335255452016132 5ustar giovannigiovannisrc/main/java/org/freehep/xml/0000755000175000017500000000000011335255452016732 5ustar giovannigiovannisrc/main/java/org/freehep/xml/io/0000755000175000017500000000000011335255452017341 5ustar giovannigiovannisrc/main/java/org/freehep/xml/io/XMLIOFactory.java0000644000175000017500000000215011335255452022422 0ustar giovannigiovanni/* * XMLIOFactory.java */ package org.freehep.xml.io; /** * Interface for object factories. The XMLIOFactories are meant to * create objects in a minimal configuration. These objects will * be then restored either by invoking their restore() method * (if they implement the XMLIO interface) or by invoking the * restore method on the XMLIOProxy responsible to save/restore * the given object. * * @author turri * @version 1.0 */ public interface XMLIOFactory { /** * Create a given object in a minimal state. * @param objClass The Class of the object to be created. * @return The corresponding object. * @throws An IllegalArgumentException if an object of the given Class * cannot be created. * */ Object createObject(Class objClass) throws IllegalArgumentException; /** * Returns an array of Classes of the objects that the factory is * able to create. * @return An array containing the Classes of the objects that * this factory in able to create. * */ Class[] XMLIOFactoryClasses(); } src/main/java/org/freehep/xml/io/XMLIORegistry.java0000644000175000017500000000470111335255452022627 0ustar giovannigiovanni/* * XMLIORegistry.java */ package org.freehep.xml.io; /** * Interface of an XMLIORegistry. The XMLIOFactories used * in the restore procedure of an object and the XMLIOProxyes * should be register to an XMLIORegistry that should be set * in the XMLIOManager passed to the restore method. * * @author turri * @version 1.0 */ public interface XMLIORegistry { /** * Register an XMLIOFactory or an XMLIOProxy to this Registry. * @param obj Either an XMLIOFactory or an XMLIOProxy to be registered. * @throws An IllegalArgumentException if the object does not implement * either XMLIOFactory or XMLIOProxy. * */ void register( Object obj ) throws IllegalArgumentException; /** * Get the appropriate XMLIOFactory to create the object * that wrote the xml node. The XMLIOFactory identification string * is attached to the node's attribute xmlioFactory<\code>. * If this attribute is not present, the node name is taken as * the identification string. The identification string is * assigned by the XMLIOManager by using the object's final * part of the Class name. * @param objClass The Class of the object to be created. * @return The corresponding XMLIOFactory. * @throws IllegalArgumentException if the XMLIOFactory does not exist. * */ XMLIOFactory getXMLIOFactory( Class objClass ) throws IllegalArgumentException; /** * Get the appropriate XMLIOProxy to restore the object * that wrote the xml node. The XMLIOProxy identification string * is the node name. The identification string is * assigned by the XMLIOManager by using the object's final * part of the Class name. * @param objClass The Class of the object to be restored. * @return The corresponding XMLIOProxy. * @throws IllegalArgumentException if the XMLIOProxy does not exist. * */ XMLIOProxy getXMLIOProxy( Class objClass ) throws IllegalArgumentException; /** * Get the identification string corresponding to a Class. * @param clName The Class. * @return The identification String. * */ String getClassId( Class clName ); /** * Get the Class corresponding to an identification String. * @param objName The object's identification String. * @return The corresponding Class. * */ Class getIdClass( String objName ); } src/main/java/org/freehep/xml/io/XMLIOFileManager.java0000644000175000017500000000535211335255452023174 0ustar giovannigiovanni/* * XMLIOFileManager.java * * Created on October 16, 2001, 8:03 AM */ package org.freehep.xml.io; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.jdom.DocType; import org.jdom.Element; import org.jdom.JDOMException; /** * Class XMLIOFileManager deals with xml files. * * @author turri * @version 1.0 * */ public class XMLIOFileManager extends XMLIOStreamManager { private File xmlFile; private boolean isZipped = false; public XMLIOFileManager( String fileName ) { xmlFile = new File(fileName); } /** * After opening the input file, converts the text in xml format * and returns the main root Element * @return the jdom main Element or null if something * went wrong in the text to xml conversion (the trace is * printed). * @exception JDOMException from XMLIOStreamManager * @see XMLIOStreamManager#getRootElement() * @exception IOException from XMLIOStreamManager * @see XMLIOStreamManager#getRootElement() * */ public Element getRootElement() throws JDOMException, IOException { InputStream inputStream = null; try { inputStream = new GZIPInputStream( new FileInputStream( xmlFile ) ); } catch ( IOException ioe ) { if ( inputStream != null ) inputStream.close(); inputStream = new FileInputStream( xmlFile ); } super.setXMLInputStream( inputStream, "file:"+xmlFile.getAbsolutePath()); return super.getRootElement(); } /** * Write the output file performing an xml to text conversion * @param rootEl is the root Element that gets converted * to text and dumped in the output file. * @exception IOException from XMLIOStreamManager * @see XMLIOStreamManager#saveRootElement( Element ) * */ public void saveRootElement( Element rootEl, String docName, String sysId ) throws IOException { if ( isXMLFileZipped() ) super.setXMLOutputStream( new GZIPOutputStream( new FileOutputStream( xmlFile ) ) ); else super.setXMLOutputStream( new FileOutputStream( xmlFile )); if ( ! docName.equals("") && ! sysId.equals("") ) super.saveRootElement( rootEl, new DocType(docName, sysId) ); else super.saveRootElement( rootEl ); } public void saveRootElement( Element rootEl ) throws IOException { saveRootElement(rootEl,"",""); } public boolean isXMLFileZipped() { return isZipped; } public void setXMLFileZipped( boolean isZipped ) { this.isZipped = isZipped; } } src/main/java/org/freehep/xml/io/XMLIO.java0000644000175000017500000000311011335255452021067 0ustar giovannigiovanni/** * XMLIO.java */ package org.freehep.xml.io; import org.jdom.Element; /** * Interface to for objects that can be save/restore to/from xml. * * @author turri * @version 1.0 * */ public interface XMLIO { /** * Save the current configuration of an object. * @param xmlioManager The objects ID manager. * @param nodeEl The jdom node containing the object's configuration info. * This node is created by the XMLIOManager. Its name is, * by default, the final part of the object's class. * The node contains the attribute "objId", i.e. the unique id * assigned to this object by the XMLIOManager. This id is * used internally by the XMLIOManager for cross references * to this object. The user has to append to this node all * the attributes and other Elements required to save the * object's configuration. Any other object, either XMLIO or Proxy-XMLIO, * that needs to be saved has to be passed to the XMLIOManager through its save(Object) method. * @see XMLIOManager#save(Object obj). * */ void save( XMLIOManager xmlioManager, Element nodeEl ); /** * Restore the object configuration. * @param xmlioManager The objects ID manager. * @param nodeEl The jdom node containing the object's configuration info. * */ void restore( XMLIOManager xmlioManager, Element nodeEl ); } src/main/java/org/freehep/xml/io/XMLIOStreamManager.java0000644000175000017500000000605311335255452023547 0ustar giovannigiovanni/* * XMLIOStreamManager.java * * Created on October 16, 2001, 8:03 AM * */ package org.freehep.xml.io; import java.io.*; import java.lang.String; import org.jdom.input.SAXBuilder; import org.jdom.output.XMLOutputter; import org.jdom.output.Format; import org.jdom.*; /** * Class XMLIOStreamManager deals with xml files. * * @author turri * @version 1.0 * */ public class XMLIOStreamManager { private InputStream xmlInputStream; private OutputStream xmlOutputStream; private String systemId; private SAXBuilder xmlBuilder = new SAXBuilder(false); private XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); /** * The main constructor * */ public XMLIOStreamManager() { } /** * The main constructor * @param xmlInputStream the input Stream * @param xmlOutputStream the output Stream * */ public XMLIOStreamManager( InputStream xmlInputStream, OutputStream xmlOutputStream ) { setXMLInputStream( xmlInputStream ); setXMLOutputStream( xmlOutputStream ); } public SAXBuilder getBuilder() { return xmlBuilder; } /** * Set the input Stream * @param xmlInputStream the input Stream * */ public void setXMLInputStream( InputStream xmlInputStream ) { this.xmlInputStream = xmlInputStream; } public void setXMLInputStream( InputStream xmlInputStream, String systemId ) { this.xmlInputStream = xmlInputStream; this.systemId = systemId; } /** * Set the output Stream * @param xmlOutputStream the output Stream * */ public void setXMLOutputStream( OutputStream xmlOutputStream ) { this.xmlOutputStream = xmlOutputStream; } /** * From the input Stream convert the text in xml format * and return the main root Element * @return the jdom main Element * @exception JDOMException from the build method of SAXBuilder * @see org.jdom.input.SAXBuilder#build( InputStream ) * @exception IOMException for the specific implementations of InputStream * */ public Element getRootElement() throws JDOMException, IOException { Document outputDoc = xmlBuilder.build(xmlInputStream, systemId); return outputDoc.getRootElement(); } /** * Write to the output Stream performing an xml to text conversion * @param rootEl is the root Element that gets converted * to text and dumped in the output file. * @exception IOException from the output method of XMLOutputter * @see org.jdom.output.XMLOutputter#output( Document, OutputStream ) * */ public void saveRootElement( Element rootEl ) throws IOException { saveRootElement(rootEl,null); } public void saveRootElement( Element rootEl, DocType docType ) throws IOException { Document inputDoc = docType != null ? new Document(rootEl, docType) : new Document(rootEl); xmlOutputter.output( inputDoc, xmlOutputStream ); xmlOutputStream.close(); } } src/main/java/org/freehep/xml/io/XMLIOFile.java0000644000175000017500000000153511335255452021700 0ustar giovannigiovanni/* * XMLIOFile.java */ package org.freehep.xml.io; import org.jdom.Element; import java.lang.String; /** * This is a dummy class. It saves the name of a file, * and restores it registering it with the XMLIOManager * * @author turri * @version 1.0 */ public class XMLIOFile implements XMLIO { private String fileName; /** * The default constructor does nothing */ public XMLIOFile() {} /** * The constructor only loads the name of the file * @param fileName the name of the file */ public XMLIOFile( String fileName ) { this.fileName = fileName; } public void save(XMLIOManager xmlioManager, Element el) { el.setAttribute( "fName", fileName ); } public void restore(XMLIOManager xmlioManager, Element nodeEl) { fileName = (String) nodeEl.getAttributeValue( "fName" ); } } src/main/java/org/freehep/xml/io/XMLIOUtils.java0000644000175000017500000000327111335255452022120 0ustar giovannigiovanni/* * XMLIOUtils.java * * Created on October 19, 2001, 4:34 PM */ package org.freehep.xml.io; import java.util.*; import java.awt.*; /** * XMLIOUtils. This class is static and contains utilities. * @author turri * @version $Id: XMLIOUtils.java 8584 2006-08-10 23:06:37Z duns $ */ public abstract class XMLIOUtils { /** * Get the Components implementing the interface XMLIO * contained in the object obj<\obj>. * Only the first level Components are returned. * @param obj the root Container * @return the list of XMLIO Components. * */ public static java.util.List getXMLIOComponents( Object obj ) { java.util.List xmlioList = new ArrayList(); Component[] comp = ((Container)obj).getComponents(); for ( int ii = 0; ii < comp.length; ii++ ) { Component c = comp[ii]; if ( c instanceof XMLIO ) { xmlioList.add( c ); } else if ( c instanceof Container ) { xmlioList.addAll( getXMLIOComponents( c ) ); } } return xmlioList; } /** * Get the Components implementing the interface XMLIO * contained in the object obj<\obj>. * All level Components are returned. * @param obj the root Container * @return the list of XMLIO Components. * */ public static java.util.List getXMLIOComponentsAll( Object obj ) { java.util.List xmlioList = new ArrayList(); Component[] comp = ((Container)obj).getComponents(); for ( int ii = 0; ii < comp.length; ii++ ) { Component c = comp[ii]; if ( c instanceof XMLIO ) { xmlioList.add( c ); } if ( c instanceof Container ) { xmlioList.addAll( getXMLIOComponentsAll( c ) ); } } return xmlioList; } } src/main/java/org/freehep/xml/io/DefaultXMLIORegistry.java0000644000175000017500000000604611335255452024140 0ustar giovannigiovanni/* * DefaultXMLIORegistry.java */ package org.freehep.xml.io; import java.util.Hashtable; /** * Default XMLIORegistry. * @see XMLIORegistry * @author turri * @version 1.0 */ public class DefaultXMLIORegistry implements XMLIORegistry { private Hashtable factoryHash = new Hashtable(); private Hashtable proxyHash = new Hashtable(); private Hashtable classIds = new Hashtable(); private Hashtable idClasses = new Hashtable(); /** * Register an XMLIOFactory or an XMLIOProxy. * param xmlioFactory the XMLIOFactory being registered * param factoryId the identification String. * */ public void register( Object obj ) { if ( !(obj instanceof XMLIOFactory) && !(obj instanceof XMLIOProxy) ) throw new IllegalArgumentException("Cannot register object "+obj+"."+ "Only XMLIOFactories and XMLIOProxies can be registered!"); if ( obj instanceof XMLIOFactory ) { XMLIOFactory xmlioFactory = (XMLIOFactory)obj; Class[] classes = xmlioFactory.XMLIOFactoryClasses(); for ( int i = 0; i < classes.length; i++ ) { if ( factoryHash.containsKey( classes[i] ) ) throw new IllegalArgumentException("Identifier "+classes[i]+" has already been registered!!"); factoryHash.put( classes[i], xmlioFactory ); addClassId( classes[i] ); } } if ( obj instanceof XMLIOProxy ) { XMLIOProxy xmlioProxy = (XMLIOProxy)obj; Class[] classes = xmlioProxy.XMLIOProxyClasses(); for ( int i = 0; i < classes.length; i++ ) { if ( proxyHash.containsKey( classes[i] ) ) throw new IllegalArgumentException("Class "+classes[i]+" has already been registered!!"); proxyHash.put( classes[i], xmlioProxy ); } } } private void addClassId( Class clazz ) { String objClassString = clazz.toString(); String classId = objClassString.substring( objClassString.lastIndexOf(".")+1 ); classId = classId.replace('$','-'); if ( classIds.containsValue(classId) ) throw new RuntimeException("Already registered ClassId in the registry!!! "+classId); classIds.put(clazz,classId); idClasses.put(classId,clazz); } /** * Get the XMLIOFactory corresponding to the identification * string factoryId<\code> * param factoryId the identification String * @return the XMLIOFactory corresponding to factoryId<\code> * */ public XMLIOFactory getXMLIOFactory(Class objClass) { return (XMLIOFactory) factoryHash.get( objClass ); } public XMLIOProxy getXMLIOProxy(Class objClass) { return (XMLIOProxy) proxyHash.get( objClass ); } public String getClassId( Class clName ) { if ( ! classIds.containsKey(clName ) ) addClassId(clName); return (String) classIds.get( clName ); } public Class getIdClass(String objName) { return (Class) idClasses.get(objName); } } src/main/java/org/freehep/xml/io/package.html0000644000175000017500000000056511335255452021630 0ustar giovannigiovanni

The XMLIO package is a set of interfaces and classes to save and restore objects using XML.

@status Under Development. src/main/java/org/freehep/xml/io/XMLIOFileFactory.java0000644000175000017500000000140411335255452023223 0ustar giovannigiovanni/* * XMLIOFileFactory.java * * Created on October 18, 2001, 3:39 PM */ package org.freehep.xml.io; /** * @author turri * @version $Id: XMLIOFileFactory.java 8584 2006-08-10 23:06:37Z duns $ */ public class XMLIOFileFactory implements XMLIOFactory { private Class[] classes; /** * Creates a new instance of XMLIOFileFactory */ public XMLIOFileFactory() { classes = new Class[1]; classes[0] = XMLIOFile.class; } public Object createObject(Class objClass) { if ( objClass == XMLIOFile.class ) return new XMLIOFile(); else throw new IllegalArgumentException("XMLIOFileFactory cannot create object of class "+objClass); } public Class[] XMLIOFactoryClasses() { return classes; } } src/main/java/org/freehep/xml/io/XMLIOProxy.java0000644000175000017500000000271011335255452022136 0ustar giovannigiovanni/* * XMLIOProxy.java */ package org.freehep.xml.io; import org.jdom.Element; /** * Interface for proxyes that can save and restore objects to/from xml. * * @author turri * */ public interface XMLIOProxy { /** * Save the current configuration of an object. * @param obj The object to be saved to xml. * @param xmlioManager The objects ID manager. * @return Element A jdom node containing the object's * configuration info. * @throws An IllegalArgumentException if the object * is not saveble by this proxy. * */ void save(Object obj, XMLIOManager xmlioManager, Element nodeEl) throws IllegalArgumentException; /** * Restore the configuration of an object. * @param obj The object to be restored. * @param xmlioManager The objects ID manager. * @param nodeEl Is the jdom node containing the * object's configuration info * @throws An IllegalArgumentException if the object * cannot be restored by this proxy. * */ void restore(Object obj, XMLIOManager xmlioManager, Element nodeEl) throws IllegalArgumentException; /** * Returns the array containing the Class of the objects that the proxy is * able to save and restore. * @return The classes. * */ Class[] XMLIOProxyClasses(); } src/main/java/org/freehep/xml/io/XMLIOManager.java0000644000175000017500000002721711335255452022400 0ustar giovannigiovanni/* * XMLIOManager.java * * Created on October 16, 2001, 8:03 AM */ package org.freehep.xml.io; import java.util.*; import org.jdom.*; /** * The XMLIOManager is in charge of saving and restoring any object * configuration through XML. It internally assigns objects and unique * identification string used for cross-reference among xml nodes. * * @author turri * @version 1.0 * */ public class XMLIOManager { private Hashtable objIdHash = new Hashtable(); private Hashtable idHash = new Hashtable(); private Hashtable nodeHash = new Hashtable(); private Hashtable classHash = new Hashtable(); private Hashtable refTable = new Hashtable(); private XMLIORegistry xmlioRegistry; private XMLIOStreamManager xmlioStreamManager; private boolean useId = true; /** * The basic constructor. * @param xmlioRegistry The XMLIORegistry from which the XMLIOManager * gets the XMLIOFactories and the XMLIOProxies to * save and restore objects. * @param xmlioStreamManager The xmlioStreamManager that deals with the input/output file. * */ /* MD: never used private XMLIOManager() { this( new DefaultXMLIORegistry(), new XMLIOFileManager("defaultXMLIOFile.xml"), true); } */ public XMLIOManager(String fileName) { this( new DefaultXMLIORegistry(), new XMLIOFileManager(fileName), true); } /* MD: never used private XMLIOManager( boolean useId ) { this( new DefaultXMLIORegistry(), new XMLIOFileManager("defaultXMLIOFile.xml"), useId); } */ /* MD: never used private XMLIOManager( XMLIORegistry xmlioRegistry, XMLIOStreamManager xmlioFileManager ) { this( xmlioRegistry, xmlioFileManager, true); } */ private XMLIOManager( XMLIORegistry xmlioRegistry, XMLIOStreamManager xmlioFileManager, boolean useId ) { setXMLIORegistry( xmlioRegistry ); setXMLIOStreamManager( xmlioFileManager ); this.useId = useId; } protected void setXMLIORegistry( XMLIORegistry xmlioRegistry ) { this.xmlioRegistry = xmlioRegistry; } /** * Get the XMLIORegistry. * @return the XMLIORegistry * */ public XMLIORegistry getXMLIORegistry() { return xmlioRegistry; } public void setXMLIOStreamManager( XMLIOStreamManager xmlioStreamManager ) { this.xmlioStreamManager = xmlioStreamManager; } public XMLIOStreamManager getXMLIOStreamManager() { return xmlioStreamManager; } /** * Restore an object from an xml node. * @param nodeEl The node containing the object's information. * This method should be used by the user to restore * nested objects within the restore method of an object * implementing the XMLIO interface. * @return The restored object. The object is first created by * invoking the create method on the corresponding XMLIOFactory. * Once created the restore method is invoked either on the object * itself (if it implements the XMLIO interface) or on the appropriate * XMLIOProxy. * */ public Object restore( Object obj, Element nodeEl ) { String objIdRef = (String) nodeEl.getAttributeValue( "objIdRef" ); if ( objIdRef != null ) if ( useId ) if ( isObjIdRegistered( objIdRef ) ) return getObj( objIdRef ); else return restore(obj, (Element) refTable.get(objIdRef) ); String objId = (String) nodeEl.getAttributeValue( "objId" ); if ( useId && isObjIdRegistered( objId ) ) return getObj( objId ); Class objClass; if ( classHash.containsKey( nodeEl.getName() ) ) objClass = (Class) classHash.get( nodeEl.getName() ); else objClass = xmlioRegistry.getIdClass(nodeEl.getName()); if ( obj == null ) obj = getXMLIOFactory( objClass ).createObject( objClass ); if ( useId ) registerObj( obj, objId ); if ( obj instanceof XMLIO ) ((XMLIO)obj).restore( this, nodeEl ); else getXMLIOProxy( objClass ).restore( obj, this, nodeEl); return obj; } public Object restore( Element nodeEl ) { return restore(null, nodeEl); } /** * Save an object to an XML node. * @param obj The object to be saved. * @return The jdom Element containing the object's unique * identification string (in the attribute "objId") and * whose name is the object's identifier. The user will have * to append to this node all the attributes and other * jdom elemets required to save the object's configuration. * */ public Element saveAs( Object obj, Class clazz ) { String nodeName; if ( nodeHash.containsKey( clazz ) ) nodeName = (String) nodeHash.get(clazz); else nodeName = (String) xmlioRegistry.getClassId( clazz ); Element el = new Element( nodeName ); if ( isObjRegistered( obj ) ) el.setAttribute( "objIdRef", getObjId( obj ) ); else { if ( useId ) el.setAttribute( "objId", registerObj( obj ) ); if ( obj instanceof XMLIO ) ((XMLIO)obj).save( this, el ); else getXMLIOProxy( clazz ).save( obj, this, el ); } return el; } public Element save( Object obj ) { return saveAs( obj, obj.getClass() ); } /** * The main method to save an array of objects to XML. * @param objs The array of objects to be saved. * */ public void saveToXML( Object[] objs, Element nodeEl ) { resetObjId(); for ( int i = 0; i < objs.length; i++ ) { nodeEl.addContent( save( objs[i] ) ); } try { xmlioStreamManager.saveRootElement( nodeEl ); } catch ( java.io.IOException ioe ) { System.out.println(" Problem with file "+ioe.getMessage()); } } /** * The main method to restore from xml. * @return The array of the restored objects. * */ public Object[] restoreFromXML() { resetObjId(); Object[] objs = null; try { Element restoreElement = xmlioStreamManager.getRootElement(); //Create the list of references here. List children = restoreElement.getChildren(); for (Iterator it = children.iterator(); it.hasNext(); ) loadRefTable( (Element) it.next() ); objs = new Object[ children.size() ]; int child = 0; for (Iterator it = children.iterator(); it.hasNext(); ) objs[ child++ ] = restore( (Element) it.next() ); } catch ( JDOMException je ) { System.out.println(" Problem with restoring "+je.getMessage()); } catch ( java.io.IOException ioe ) { System.out.println(" Problem with file "+ioe.getMessage()); } return objs; } /** * Assign to a Class a string identifier. * @param clName The Class. * @param id The new identifier for the class. * */ public void setClassId(Class clName, String id) { nodeHash.put(clName, id); classHash.put(id, clName); } protected void loadRefTable(Element el) { String objId = el.getAttributeValue("objId"); if ( objId != null ) refTable.put( objId, el ); List children = el.getChildren(); for (Iterator it = children.iterator(); it.hasNext(); ) loadRefTable( (Element) it.next() ); } /** * Down here are only private and protected methods. * */ /** * Create the object's unique Id for cross-reference among xml nodes * @param obj the object. * @return the object's unique Id. */ private String makeObjId( Object obj ) { String clName = obj.getClass().getName(); String pkgName = obj.getClass().getPackage().getName(); String idName = clName.substring( pkgName.length()+1, clName.length() ).trim(); while ( idName.indexOf('$') != -1 ) idName = idName.substring( idName.indexOf('$')+1, idName.length() ).trim(); int i = 1; if ( idHash.containsKey( idName ) ) i = ( (Integer)( idHash.get( idName ) ) ).intValue() + 1; idHash.put( idName, new Integer( i ) ); String objId = idName+i; return objId; } /** * Register object assigning an unique Id for cross-reference among xml nodes * @param obj the object to be registered. * @return the object's unique Id. */ private String registerObj( Object obj ) { if ( objIdHash.contains( obj ) ) return getObjId( obj ); String objId = makeObjId( obj ); objIdHash.put( objId, obj ); return objId; } /** * Register object with a pre-assigned Id for cross-reference among xml nodes * @param obj the object to be registered * @param objId the object's Id */ private void registerObj( Object obj, String objId ) { if ( objIdHash.containsKey( objId ) ) return; objIdHash.put( objId, obj); } /** * Get the object's unique Id for cross-reference among xml nodes * @param obj the object whose unique id we are looking for * @return the unique String Id of object obj * if no string is found the object itself is returned */ private String getObjId( Object obj ) { for ( Enumeration keys = objIdHash.keys(); keys.hasMoreElements(); ) { String key = (String) ( keys.nextElement() ); if ( objIdHash.get( key ).equals( obj ) ) return key; } return (String)obj; } /** * Get the object corresponding to unique Id for cross-reference among xml nodes * @param objId the object's unique String Id * @return the object corrisponding to unique Id objId * if the object is registered or the string objId * if the object is not registered * */ private Object getObj( String objId ) { if ( objIdHash.containsKey( objId ) ) return objIdHash.get( objId ); return objId; } /** * Check if an object is registered * @param obj the object to be checked * @return true if the object is registered * false otherwise * */ private boolean isObjRegistered( Object obj ) { if ( objIdHash.contains( obj ) ) return true; return false; } /** * Check if an unique Id is registered * @param objId the unique Id to be checked * @return true if the unique Id is registered * false otherwise * */ private boolean isObjIdRegistered( String objId ) { if ( objIdHash.containsKey( objId ) ) return true; return false; } /** * Reset the stored ids */ public void resetObjId() { objIdHash.clear(); idHash.clear(); refTable.clear(); } /** * Get the XMLIOFactory to restore the xml node * param nodeEl the node to be restored * @return the XMLIOFactory * */ protected XMLIOFactory getXMLIOFactory( Class objClass ) { return xmlioRegistry.getXMLIOFactory( objClass ); } protected XMLIOProxy getXMLIOProxy( Class objClass ) { return xmlioRegistry.getXMLIOProxy( objClass ); } } src/main/java/org/freehep/xml/util/0000755000175000017500000000000011341744246017710 5ustar giovannigiovannisrc/main/java/org/freehep/xml/util/SAXErrorHandler.java0000644000175000017500000000465711335255452023531 0ustar giovannigiovanni/* * SAXErrorHandler.java * * Created on February 14, 2001, 4:38 PM */ package org.freehep.xml.util; import org.xml.sax.*; /** * A simple SAXErrorHandler. Reports errors to System.err and keeps track * of the most severe error. Can be configured to throw exceptions when errors * more severe than a certain LEVEL are encountered * @author tonyj * @version $Id: SAXErrorHandler.java 8584 2006-08-10 23:06:37Z duns $ */ public class SAXErrorHandler implements ErrorHandler { public final static int LEVEL_SUCCESS = 0; public final static int LEVEL_WARNING = 1; public final static int LEVEL_ERROR = 2; public final static int LEVEL_FATAL = 3; /** * Create a SAXErrorHandler which will throw exceptions for all errors (but not warnings) */ public SAXErrorHandler() { this(LEVEL_ERROR); } /** * Create a SAXErrorHandler * @param minLevelForException The minimum error level for which exceptions will be thrown */ public SAXErrorHandler(int minLevelForException) { this.minLevel = minLevelForException; } public void warning(SAXParseException exception) throws org.xml.sax.SAXException { handle(exception,LEVEL_WARNING,"Warning"); } public void error(SAXParseException exception) throws org.xml.sax.SAXException { handle(exception,LEVEL_ERROR,"Error"); } public void fatalError(SAXParseException exception) throws SAXException { handle(exception,LEVEL_FATAL,"Fatal"); } private void handle(SAXParseException exception, int level, String levelName) throws SAXException { StringBuffer message = new StringBuffer(levelName); String fileName = exception.getPublicId(); if (fileName == null) fileName = exception.getSystemId(); if (fileName != null) message.append(" at "+fileName); message.append(" line "+exception.getLineNumber()); if (level > maxLevel) maxLevel = level; if (level >= minLevel) throw new BadXMLException(message.toString(),exception); else { message.append(": "+exception); System.err.println(message); } } /** * Get the level of the most severe error. * @return one of LEVEL_SUCCESS, LEVEL_WARNING, LEVEL_ERROR, LEVEL_FATAL */ public int getErrorLevel() { return maxLevel; } private int maxLevel = 0; private int minLevel; } src/main/java/org/freehep/xml/util/XMLWriter.java0000644000175000017500000003323411335255452022414 0ustar giovannigiovanni// Copyright 2002-2007, FreeHEP. package org.freehep.xml.util; import java.awt.Color; import java.io.IOException; import java.io.Writer; import java.util.Enumeration; import java.util.Hashtable; import java.util.Stack; import org.freehep.util.io.IndentPrintWriter; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * A class that makes it easy to write XML documents. * * @author Tony Johnson * @author Mark Donszelmann * @version $Id: XMLWriter.java 10527 2007-02-13 17:49:08Z duns $ */ public class XMLWriter implements XMLTagWriter { public XMLWriter(Writer w, String indentString, String defaultNameSpace) { writer = new IndentPrintWriter(w); writer.setIndentString(indentString); this.defaultNameSpace = defaultNameSpace; } public XMLWriter(Writer w, String indentString) { this(w, indentString, ""); } public XMLWriter(Writer w) { this(w, " "); // By popular demand of Babar } /** * closes the writer */ public void close() throws IOException { closeDoc(); writer.close(); } /** * Opens the document with an xml header */ public void openDoc() { openDoc("1.0", "", false); } /** * Opens the document with an xml header */ public void openDoc(String version, String encoding, boolean standalone) { String indentString = writer.getIndentString(); writer.setIndentString(indentString); closed = false; if (!XMLCharacterProperties.validVersionNum(version)) throw new RuntimeException("Invalid version number: "+version); writer.print(""); writer.setIndentString(indentString); } /** * Writes a reference to a DTD */ public void referToDTD(String name, String pid, String ref) { if (dtdName != null) { throw new RuntimeException("ReferToDTD cannot be called twice"); } dtdName = name; writer.println(""); } /** * Writes a reference to a DTD */ public void referToDTD(String name, String system) { if (dtdName != null) { throw new RuntimeException("ReferToDTD cannot be called twice"); } dtdName = name; writer.println(""); } /** * Closes the document, and checks if you closed all the tags */ public void closeDoc() { if (!closed) { if (!openTags.isEmpty()) { StringBuffer sb = new StringBuffer("Not all tags were closed before closing XML document:\n"); while (!openTags.isEmpty()) { sb.append(" \n"); } throw new RuntimeException(sb.toString()); } closed = true; } writer.flush(); } /** * Print a comment */ public void printComment(String comment) { if (comment.indexOf("--") >= 0) throw new RuntimeException("'--' sequence not allowed in comment"); writer.print(""); } /** * Prints character data, while escaping < and > */ public void print(String text) { writer.print(normalizeText(text)); } /** * Prints character data, while escaping < and > */ public void println(String text) { print(text); writer.println(); } /** * Prints a new XML tag and increases the identation level */ public void openTag(String namespace, String name) { if (namespace.equals(defaultNameSpace)) { openTag(name); } else { openTag(namespace+":"+name); } } /** * Prints a new XML tag and increases the identation level */ public void openTag(String name) { checkNameValid(name); if (openTags.isEmpty() && dtdName != null && !dtdName.equals(name)) { throw new RuntimeException("First tag: '"+name+"' not equal to DTD id: '"+dtdName+"'"); } writer.print("<"+name); printAttributes(name.length()); writer.println(">"); writer.indent(); openTags.push(name); } /** * Closes the current XML tag and decreases the indentation level */ public void closeTag() { if (openTags.isEmpty()) { writer.close(); throw new RuntimeException("No open tags"); } Object name = openTags.pop(); writer.outdent(); writer.print(""); } /** * Prints an empty XML tag. */ public void printTag(String namespace, String name) { if (namespace.equals(defaultNameSpace)) { printTag(name); } else { printTag(namespace+":"+name); } } /** * Prints an empty XML tag. */ public void printTag(String name) { checkNameValid(name); writer.print("<"+name); printAttributes(name.length()); writer.println("/>"); } /** * Sets an attribute which will be included in the next tag * printed by openTag or printTag */ public void setAttribute(String name, String value) { if ((name != null) && (value != null)) { attributes.put(name,value); } } public void setAttribute(String namespace, String name, String value) { if ((namespace != null) && (name != null)) { attributes.put(namespace+":"+name, value); } } public void setAttribute(String name, byte value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, char value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, long value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, int value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, short value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, boolean value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, float value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, double value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String name, Color value) { setAttribute(name, String.valueOf(value)); } public void setAttribute(String ns, String name, byte value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, char value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, long value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, int value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, short value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, boolean value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, float value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, double value) { setAttribute(ns+":"+name, String.valueOf(value)); } public void setAttribute(String ns, String name, Color value) { setAttribute(ns+":"+name, String.valueOf(value)); } protected void printAttributes(int tagLength) { int width = tagLength + 1; boolean extraIndent = false; Enumeration e = attributes.keys(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); checkNameValid(key); String value = normalize(attributes.get(key).toString()); int length = key.length() + value.length() + 3; if (width > 0 && width + length + 2*writer.getIndent() > 60) { width = 0; writer.println(); if (!extraIndent) { writer.indent(); extraIndent = true; } } else { width += length; writer.print(' '); } writer.print(key); writer.print("=\""); writer.print(value); writer.print("\""); } attributes.clear(); if (extraIndent) writer.outdent(); } /** * Prints a DOM node, recursively. * No support for a document node */ public void print(Node node) { if ( node == null ) return; int type = node.getNodeType(); switch ( type ) { // print document case Node.DOCUMENT_NODE: throw new RuntimeException("No support for printing nodes of type Document"); // print element with attributes case Node.ELEMENT_NODE: NamedNodeMap attributes = node.getAttributes(); for ( int i = 0; i < attributes.getLength(); i++ ) { Node attr = attributes.item(i); setAttribute(attr.getNodeName(), attr.getNodeValue()); } NodeList children = node.getChildNodes(); if ( children == null ) { printTag(node.getNodeName()); } else { openTag(node.getNodeName()); int len = children.getLength(); for ( int i = 0; i < len; i++ ) { print(children.item(i)); } closeTag(); } break; // handle entity reference nodes case Node.ENTITY_REFERENCE_NODE: writer.print('&'); writer.print(node.getNodeName()); writer.print(';'); break; // print cdata sections case Node.CDATA_SECTION_NODE: writer.print(""); break; // print text case Node.TEXT_NODE: print(node.getNodeValue()); break; // print processing instruction case Node.PROCESSING_INSTRUCTION_NODE: writer.print(" 0 ) { writer.print(' '); writer.print(data); } writer.print("?>"); break; } } // print(Node) /** Normalizes the given string for an Attribute value*/ public static String normalize(String s) { StringBuffer str = new StringBuffer(); int len = (s != null) ? s.length() : 0; for (int i = 0; i < len; i++) { char ch = s.charAt(i); switch (ch) { case '<': { str.append("<"); break; } case '>': { str.append(">"); break; } case '&': { str.append("&"); break; } case '"': { str.append("""); break; } case '\r': case '\n': { str.append("&#"); str.append(Integer.toString(ch)); str.append(';'); break; } default: { if (ch > 0x00FF) { String hex = "0000"+Integer.toHexString(ch); str.append("&#x"); str.append(hex.substring(hex.length()-4)); str.append(';'); } else { str.append(ch); } } } } return str.toString(); } // normalize(String):String /** Normalizes the given string for Text */ public static String normalizeText(String s) { StringBuffer str = new StringBuffer(); int len = (s != null) ? s.length() : 0; for (int i = 0; i < len; i++) { char ch = s.charAt(i); switch (ch) { case '<': { str.append("<"); break; } case '>': { str.append(">"); break; } case '&': { str.append("&"); break; } default: { if (ch > 0x007f) { String hex = "0000"+Integer.toHexString(ch); str.append("&#x"); str.append(hex.substring(hex.length()-4)); str.append(';'); } else { str.append(ch); } } } } return str.toString(); } protected void checkNameValid(String s) { if (!XMLCharacterProperties.validName(s)) throw new RuntimeException("Invalid name: "+s); } protected boolean closed = true; private String dtdName = null; private Hashtable attributes = new Hashtable(); private Stack openTags = new Stack(); protected IndentPrintWriter writer; protected String defaultNameSpace; } src/main/java/org/freehep/xml/util/XMLNodeTraverser.java0000644000175000017500000001201511335255452023715 0ustar giovannigiovanni// Copyright 2000, SLAC, Stanford, California, U.S.A. package org.freehep.xml.util; import org.w3c.dom.*; /** * Utility class for traversing XML DOM trees. * This is an abstract class that has methods which are * called as different elements are located in a DOM tree. * It is designed to be extended for each nore in a specific * DOM tree, with its methods overriden to handle specific * elements and attributes of the tree. * * @deprecated The design of this class is misguided, it is better to use SAX, and SAXTraverser. Will be removed from future FreeHEP releases * @author Tony Johnson (tonyj@slac.stanford.edu) * @version $Id: XMLNodeTraverser.java 8584 2006-08-10 23:06:37Z duns $ */ public abstract class XMLNodeTraverser { /** * Traverse a node * @param node The node to traverse */ public void traverse(Node node) throws BadXMLException { if (node instanceof Element) { attrs = ((Element) node).getAttributes(); handleElementAttributes(attrs); } for (Node n = node.getFirstChild(); n != null; n = n.getNextSibling()) { handleSubNode(n,n.getNodeName()); } attrs = null; // for efficiency, dont hold on to attributes } /** * Called to handle a subnode of the node being traversed. * The default implementation calls handleElement, handleTextNode * or handleOtherNode as appropriate. * @param node The subnode being handled * @param name The name of the subnode */ protected void handleSubNode(Node node, String name) throws BadXMLException { int type = node.getNodeType(); switch (type) { case Node.ELEMENT_NODE: handleElement((Element) node,name); break; case Node.TEXT_NODE: handleTextNode((Text) node,name); break; default: handleOtherNode(node,name); } } /** * Called to handle the attributes associated with the * element being traversed. The default implementation calls * handleAttributeNode for each attribute * @param nnm The attrinbutes being handled */ protected void handleElementAttributes(NamedNodeMap nnm) throws BadXMLException { for (int i=0; i XML Utilities to add in reading and writing XML.

@Status Stable.

src/main/java/org/freehep/xml/util/BadXMLException.java0000644000175000017500000000104611335255452023501 0ustar giovannigiovannipackage org.freehep.xml.util; import org.xml.sax.SAXException; /** * A SAXException with an optional nested exception * @author tonyj * @version $Id: BadXMLException.java 8584 2006-08-10 23:06:37Z duns $ */ public class BadXMLException extends SAXException { /** * */ private static final long serialVersionUID = 1493961676061071756L; public BadXMLException(String message) { super(message); } public BadXMLException(String message, Throwable detail) { super(message); initCause(detail); } } src/main/java/org/freehep/xml/util/ClassPathEntityResolver.java0000644000175000017500000000377311335255452025365 0ustar giovannigiovanni// Copyright 2000-2003, SLAC, Stanford, California, U.S.A. package org.freehep.xml.util; import java.io.InputStream; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * An implementation of an EntityResolver which can be used to locate * DTD files located on the current java class path * * @author Tony Johnson (tonyj@slac.stanford.edu) * @version $Id: ClassPathEntityResolver.java 8584 2006-08-10 23:06:37Z duns $ */ public class ClassPathEntityResolver implements EntityResolver { private Class root; private String name; private String prefix; /** * Create a ClassPathEntityResolver that will handle a single DTD. * @param DTDName The DTDName to resolve (e.g. myStuff.dtd) * @param root A class in the same package as the DTD */ public ClassPathEntityResolver(String DTDName, Class root) { this.name = DTDName; this.root = root; } /** * Create a ClassPathEntityResolver that can handle a collection of DTD's * @param root A class in the package to be used as the root of the DTD path * @param DTDPrefix A string containing the prefix for the DTD to match */ public ClassPathEntityResolver(Class root, String DTDPrefix) { this.prefix = DTDPrefix; this.root = root; } /* * Implementation of resolveEntity method */ public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (name != null && systemId.endsWith(name)) { InputStream in = root.getResourceAsStream(name); if (in == null) throw new SAXException(systemId+" not found"); return new InputSource(in); } if (prefix != null && systemId.startsWith(prefix)) { String postfix = systemId.substring(prefix.length()); InputStream in = root.getResourceAsStream(postfix); if (in == null) throw new SAXException(systemId+" not found"); return new InputSource(in); } return null; } } src/main/java/org/freehep/xml/util/SAXTraverser.java0000644000175000017500000001101611335255452023102 0ustar giovannigiovanni/* * SAXTraverser.java * * Created on February 9, 2001, 3:02 PM */ package org.freehep.xml.util; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; /** * A utility for working with SAX parsers. A heirarchy of SAXTraversers can be * used to maintain state while parsing an XML file. * @author tonyj * @version $Id: SAXTraverser.java 8584 2006-08-10 23:06:37Z duns $ */ public class SAXTraverser extends DefaultHandler { /** * Attach an XMLReader to this traverser. Registers this SAXTraverser as the * content handler for the reader. */ public void setReader(XMLReader reader) { this.parser = reader; reader.setContentHandler(this); } public void startElement(String namespaceURI,String localName,String qName,Attributes attrs) throws SAXException { qName = qName.intern(); SAXTraverser newHandler = handleElement(qName,attrs); if (newHandler != this) { newHandler.handleElementAttributes(attrs); newHandler.previous = this; newHandler.parser = parser; parser.setContentHandler(newHandler); } else stack++; } public void endElement(String namespaceURI,String localName,String qName) throws SAXException { if (stack == 0) { handleEndElement(localName); previous.handleSubElement(this); parser.setContentHandler(previous); } else stack--; } /** * Override to handle node attributes */ protected void handleElementAttributes(Attributes atts) throws SAXException { } /** * Override this to handle the end of an element */ protected void handleEndElement(String name) throws SAXException { } /** * Override this to be notified of sub nodes of the current node */ protected void handleSubElement(SAXTraverser sub) throws SAXException { } /** * Override this to handle the start of new sub elements * Return the SAXTraverser to be used for the sub node, or this to continue * using the current traverser. * @return The SAXTraverser to be used as the content handler for the sub node */ protected SAXTraverser handleElement(String name, Attributes attrs) throws SAXException { throw new BadXMLException("Unhandled element "+name); } /** * Utility routine to convert a String to a boolean */ public boolean toBoolean(String value) throws BadXMLException { if (value.equalsIgnoreCase("true")) return true; else if (value.equalsIgnoreCase("false")) return false; else throw new BadXMLException("Bad boolean value "+value); } /** * Utility routine to convert a String to a double */ public double toDouble(String value) throws SAXException { try { return new Double(value).doubleValue(); } catch (Throwable x) { throw new BadXMLException("Bad double value "+value); } } /** * Utility routine to convert a String to a float */ public float toFloat(String value) throws SAXException { try { return Float.parseFloat(value); } catch (Throwable x) { throw new BadXMLException("Bad float value "+value); } } /** * Utility routine to convert a String to an int */ public int toInt(String value) throws SAXException { try { return Integer.parseInt(value); } catch (Throwable x) { throw new BadXMLException("Bad integer value "+value); } } /** * Utility routine to convert a String to a short */ public short toShort(String value) throws SAXException { try { return Short.parseShort(value); } catch (Throwable x) { throw new BadXMLException("Bad short value "+value); } } /** * Utility routine to convert a String to a long */ public long toLong(String value) throws SAXException { try { return Long.parseLong(value); } catch (Throwable x) { throw new BadXMLException("Bad long value "+value); } } /** * Utility routine to convert a String to a byte */ public byte toByte(String value) throws SAXException { try { return Byte.parseByte(value); } catch (Throwable x) { throw new BadXMLException("Bad byte value "+value); } } private SAXTraverser previous; private XMLReader parser; private int stack = 0; } src/main/java/org/freehep/xml/util/XHTMLWriter.java0000644000175000017500000000405011335255452022642 0ustar giovannigiovannipackage org.freehep.xml.util; import java.io.Writer; /** * A class that makes it easy to write XHTML documents. * * @author Mark Donszelmann * @version $Id: XHTMLWriter.java 8584 2006-08-10 23:06:37Z duns $ */ public class XHTMLWriter extends XMLWriter { /** * @param type [strict, transitional, frameset] */ public XHTMLWriter(Writer w, String indentString, String type) { super(w, indentString, "xhtml"); openDoc("1.0", "UTF-8", false); if (type.equals("strict")) { referToDTD("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://wwww.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); } else if (type.equals("transitional")) { referToDTD("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://wwww.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); } else if (type.equals("frameset")) { referToDTD("html", "-//W3C//DTD XHTML 1.0 Frameset//EN", "http://wwww.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"); } else { System.err.println("XHTMLWriter: unknown type: "+type+", allowed are: strict, transitional, frameset"); } setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); if (!type.equals("strict")) { setAttribute("xml", "lang", "en"); } setAttribute("lang", "en"); openTag("html"); } public XHTMLWriter(Writer w) { this(w, " ", "strict"); } public void closeDoc() { if (!closed) { closeTag(); } super.closeDoc(); } public void printTag(String name) { checkNameValid(name); writer.print("<"+name); printAttributes(name.length()); writer.println(" />"); } public void setAttribute(String name, boolean value) { if (value) { setAttribute(name, name); } } /** * Prints text as is (no escaping of anything) */ public void printPlain(String text) { writer.print(text); } } src/main/java/org/freehep/xml/util/XMLTagWriter.java0000644000175000017500000001403411335255452023045 0ustar giovannigiovanni// Copyright 2005-2007, FreeHEP. package org.freehep.xml.util; import java.awt.Color; import java.io.IOException; /** * XMLTagWriter Interface. Attributes need to be set before tags are written. * * @author Mark Donszelmann * @version $Id: XMLTagWriter.java 8584 2006-08-10 23:06:37Z duns $ */ public interface XMLTagWriter { /** * Write an xml open tag * @param ns namespace * @param name tagname * @throws IOException if stream cannot be written */ public void openTag(String ns, String name) throws IOException; /** * Write empty tag * @param ns namespace * @param name tagname * @throws IOException if stream cannot be written */ public void printTag(String ns, String name) throws IOException; /** * Close writer * @throws IOException if stream cannot be written */ public void close() throws IOException; /** * Open XML doc with standard parameters * @throws IOException if stream cannot be written */ public void openDoc() throws IOException; /** * Open XML doc * @param version version string * @param encoding encoding * @param standalone if XML is standalone * @throws IOException if stream cannot be written */ public void openDoc(String version, String encoding, boolean standalone) throws IOException; /** * Close XML doc * @throws IOException if stream cannot be written */ public void closeDoc() throws IOException; public void referToDTD(String name, String system); public void referToDTD(String name, String pid, String ref); /** * Write an xml open tag * @param name tagname * @throws IOException if stream cannot be written */ public void openTag(String name) throws IOException; /** * Close nearest tag * @throws IOException if stream cannot be written */ public void closeTag() throws IOException; /** * Write empty tag * @param name tagname * @throws IOException if stream cannot be written */ public void printTag(String name) throws IOException; public void printComment(String comment) throws IOException; public void print(String text) throws IOException; /** * Set String attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, String value); /** * Set Color attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, Color value); /** * Set byte attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, byte value); /** * Set char attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, char value); /** * Set long attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, long value); /** * Set int attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, int value); /** * Set short attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, short value); /** * Set boolean attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, boolean value); /** * Set float attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, float value); /** * Set double attribute * @param name attribute name * @param value attribute value */ public void setAttribute(String name, double value); /** * Set String attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, String value); /** * Set Color attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, Color value); /** * Set byte attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, byte value); /** * Set char attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, char value); /** * Set long attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, long value); /** * Set int attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, int value); /** * Set short attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, short value); /** * Set boolean attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, boolean value); /** * Set float attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, float value); /** * Set double attribute * @param ns namespace * @param name attribute name * @param value attribute value */ public void setAttribute(String ns, String name, double value); } src/main/java/org/freehep/xml/menus/0000755000175000017500000000000011335255452020061 5ustar giovannigiovannisrc/main/java/org/freehep/xml/menus/XMLMenuBuilder.java0000644000175000017500000007026511335255452023532 0ustar giovannigiovanni// Copyright 2000, SLAC, Stanford, California, U.S.A. package org.freehep.xml.menus; import java.awt.Component; import java.util.Enumeration; import java.util.Hashtable; import javax.swing.JToolBar.Separator; import javax.xml.parsers.SAXParserFactory; import org.freehep.util.images.ImageHandler; import org.freehep.xml.util.BadXMLException; import org.freehep.xml.util.ClassPathEntityResolver; import org.freehep.xml.util.SAXErrorHandler; import org.freehep.xml.util.SAXTraverser; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; import java.net.MalformedURLException; import java.net.URL; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; import java.awt.Event; import java.awt.Insets; import javax.swing.AbstractButton; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JRadioButtonMenuItem; import javax.swing.JSeparator; import javax.swing.JToggleButton; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.UIManager; /** * Create a set of menus by reading an XML file. * * @author Tony Johnson (tonyj@slac.stanford.edu) * @author Peter Armstrong * @version $Id: XMLMenuBuilder.java 8584 2006-08-10 23:06:37Z duns $ */ public class XMLMenuBuilder { public static final String LOCATION_PROPERTY = "Location"; private static ClassLoader defaultLoader; /** * Create an (empty) XMLMenuBuilder */ public XMLMenuBuilder() { // Make sure to change Look and feel of unparented menus UIManager.addPropertyChangeListener(new UIListener(this)); } /** * Build an XMLMenuSystem using the default SAX parser. * @param xml The URL from which to read the XML */ public void build(URL xml) throws SAXException, IOException { XMLReader reader; try { reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); } catch (SecurityException x) // JAXP doesn't work if downloaded into webstart { try { String parser = System.getProperty("org.xml.sax.driver"); if (parser == null) System.getProperties().setProperty("org.xml.sax.driver","org.apache.xerces.parsers.SAXParser"); } catch (SecurityException xx) {} reader = XMLReaderFactory.createXMLReader(); } catch (Exception x) { throw new RuntimeException("Error creating XML Parser",x); } build(xml,reader); } /** * Build an XMLMenuSystem * @param xml The URL from which to read the XML * @param reader The XMLReader to use to parse the XML */ public void build(URL xml, XMLReader reader) throws SAXException, IOException { reader.setFeature("http://xml.org/sax/features/validation", true); reader.setEntityResolver(new ClassPathEntityResolver(XMLMenuBuilder.class,"http://java.freehep.org/schemas/menus/")); MenuSystemTraverser t = new MenuSystemTraverser(); t.setReader(reader); reader.setErrorHandler(new SAXErrorHandler()); baseURL = xml; InputStream in = new BufferedInputStream(xml.openStream()); try { InputSource input = new InputSource(in); input.setSystemId(xml.toString()); input.setPublicId(xml.getFile()); reader.parse(input); } finally { in.close(); } } /* * sets the default class for menubars * @param klass the new default class, must be a subclass of JMenuBar */ public void setDefaultMenuBarClass(Class klass) throws IllegalDefaultClassException { defaultMenuBarClass = setDefaultClass(JMenuBar.class, klass); } /** * sets the default class of menus to be klass * @param klass the new default class, must be a subclass of JMenu */ public void setDefaultMenuClass(Class klass) throws IllegalDefaultClassException { defaultMenuClass = setDefaultClass(JMenu.class, klass); } /** * sets the default class of menu items to be klass * @param klass the new default class, must be a subclass of JMenuItem */ public void setDefaultMenuItemClass(Class klass) throws IllegalDefaultClassException { defaultMenuItemClass = setDefaultClass(JMenuItem.class, klass); } /** * sets the default class of radio menu items to be klass * @param klass the new default class, must be a subclass of JMenuItem */ public void setDefaultRadioMenuItemClass(Class klass) throws IllegalDefaultClassException { defaultRadioButtonMenuItemClass = setDefaultClass(JMenuItem.class, klass); } /** * sets the default class of checkbox menu items to be klass * @param klass the new default class, must be a subclass of JMenuItem */ public void setDefaultCheckBoxMenuItemClass(Class klass) throws IllegalDefaultClassException { defaultCheckBoxMenuItemClass = setDefaultClass(JMenuItem.class, klass); } /** * sets the default class of popup menus to be klass * @param klass the new default class, must be a subclass of JPopupMenu */ public void setDefaultPopupMenuClass(Class klass) throws IllegalDefaultClassException { defaultPopupMenuClass = setDefaultClass(JPopupMenu.class, klass); } /** * sets the default class of toolbars to be klass * @param klass the new default class, must be a subclass of JToolBar */ public void setDefaultToolBarClass(Class klass) throws IllegalDefaultClassException { defaultToolBarClass = setDefaultClass(JToolBar.class, klass); } /** * sets the default class of menu items to be klass * @param klass the new default class, must be a subclass of JButton */ public void setDefaultToolBarItemClass(Class klass) throws IllegalDefaultClassException { defaultToolBarButtonClass = setDefaultClass(JButton.class, klass); } /** * Override this method to create your own subclass of JMenuBar */ protected JMenuBar createMenuBar(String className) throws SAXException { Class klass; if (className == null) klass = defaultMenuBarClass; else klass = findClass(className); return (JMenuBar) createObject(klass, JMenuBar.class); } /** * Override this method to create your own subclass of JMenu */ protected JMenu createMenu(String className) throws SAXException { Class klass; if (className == null) klass = defaultMenuClass; else klass = findClass(className); return (JMenu) createObject(klass, JMenu.class); } /** * Override this method to create your own subclass of JMenuItem */ protected JMenuItem createMenuItem(String className, String name, String type, String command) throws SAXException { Class klass; if (className == null) { if (type.equals("checkbox")) klass = defaultCheckBoxMenuItemClass; else if (type.equals("radio")) klass = defaultRadioButtonMenuItemClass; else klass = defaultMenuItemClass; } else klass = findClass(className); JMenuItem result = (JMenuItem) createObject(klass, JMenuItem.class); result.setText(name); if (command != null) result.setActionCommand(command); return result; } /** * Override this method to create your own subclass of JPopupMenu */ protected JPopupMenu createPopupMenu(String className) throws SAXException { Class klass; if (className == null) klass = defaultPopupMenuClass; else klass = findClass(className); return (JPopupMenu) createObject(klass, JPopupMenu.class); } /** * Override this method to create your own subclass of JToolBar */ protected JToolBar createToolBar(String className) throws SAXException { Class klass; if (className == null) klass = defaultToolBarClass; else klass = findClass(className); return (JToolBar) createObject(klass, JToolBar.class); } /** * Override this method to create your own subclass of JButton */ protected AbstractButton createToolBarItem(String className, String name, String type, String command) throws SAXException { Class klass; if (className == null) klass = defaultToolBarButtonClass; else klass = findClass(className); if (type.equals("checkbox")) klass = JToggleButton.class; else klass = JButton.class; AbstractButton result = (AbstractButton) createObject(klass, AbstractButton.class); result.setMargin(new Insets(0,0,0,0)); if (command != null) result.setActionCommand(command); return result; } /** * Override this method for customized icon creation. * The default implementation treats the argument as a relative or absolute URL. * If relative it is interpreted relative to the URL of the menu file being read. * If the icon cannot be found a "broken" icon is substituted. */ protected Icon createIcon(String name) throws SAXException { try { URL url = null; if (name.startsWith("/")) url = getClass().getResource(name); if (url == null) url = new URL(baseURL,name); return ImageHandler.getIcon(url); } catch (MalformedURLException x) { throw new BadXMLException("Could not load image: "+name,x); } } private void merge(JComponent oldMenu, JComponent newMenu) { // Loop over each element of the new Menu, // and if it is not already in the old menu insert it as appropriate if (newMenu instanceof JMenu) newMenu = ((JMenu) newMenu).getPopupMenu(); if (oldMenu instanceof JMenu) oldMenu = ((JMenu) oldMenu).getPopupMenu(); outer: for (int i=0; i 0) { oldMenu.add(comp,j); i--; continue outer; } } } } } } oldMenu.add(c); i--; } } /** * Get the menu bar with ID id */ public JMenuBar getMenuBar(String id) { return (JMenuBar) menuBarHash.get(id); } /** * Get the tool bar with ID id */ public JToolBar getToolBar(String id) { return (JToolBar) toolBarHash.get(id); } /** * Get the popup menu with ID id */ public JPopupMenu getPopupMenu(String id) { return (JPopupMenu) popupMenuHash.get(id); } /** * Merge the popup menu with ID id onto the end of an existing menu * @param id The id of the popup menu * @param menu The menu to be merged */ public JPopupMenu mergePopupMenu(String id, JPopupMenu menu) { try { JPopupMenu merge = getPopupMenu(id); if (menu == null) return merge; Component[] c = merge.getComponents(); for (int i=0; i

Package for building menus in Java using XML setup files.

@status Stable.

src/main/java/org/freehep/xml/menus/test/0000755000175000017500000000000011335255452021040 5ustar giovannigiovannisrc/main/java/org/freehep/xml/menus/test/Test.java0000644000175000017500000000633611335255452022632 0ustar giovannigiovanni// Copyright 2000, SLAC, Stanford, California, U.S.A. package org.freehep.xml.menus.test; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JToolBar; import org.freehep.xml.menus.XMLMenuBuilder; import org.xml.sax.SAXException; /** * A simple example of how to use the XML menu system. For xml menu * system can also be combined with the command dispatch system. * * @see org.freehep.util.commanddispatcher * @see org.freehep.util.commanddispatcher.test.Test * * @author Tony Johnson (tonyj@slac.stanford.edu) * @version $Id: Test.java 8584 2006-08-10 23:06:37Z duns $ */ public class Test extends org.freehep.swing.test.TestFrame implements ActionListener { private class MyXMLMenuBuilder extends XMLMenuBuilder { protected JMenuItem createMenuItem(String className, String name, String type, String command) throws SAXException { JMenuItem result = super.createMenuItem(className, name, type, command); result.addActionListener(Test.this); return result; } protected AbstractButton createToolBarItem(String className, String name, String type, String command) throws SAXException { AbstractButton result = super.createToolBarItem(className, name, type, command); result.addActionListener(Test.this); return result; } } protected JComponent createComponent() { JPanel main = new JPanel(new BorderLayout()); try { java.net.URL xml = getClass().getResource("menus.xml"); final XMLMenuBuilder menus = new MyXMLMenuBuilder(); menus.build(xml); JMenuBar b = menus.getMenuBar("mainMenu"); main.add(b,BorderLayout.NORTH); JPanel p = new JPanel(); main.add(p,BorderLayout.CENTER); p.setLayout(new BorderLayout()); JToolBar t = menus.getToolBar("applicationToolBar"); p.add(t,BorderLayout.NORTH); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) showPopup(e); super.mousePressed(e); } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) showPopup(e); super.mouseReleased(e); } private void showPopup(MouseEvent e) { JPopupMenu popup = menus.getPopupMenu("toolbarPopupMenu"); popup.show(Test.this,e.getX(),e.getY()); } }); } catch (Exception x) { x.printStackTrace(); System.exit(0); } main.setPreferredSize(new Dimension(400,200)); return main; } public static void main(String[] argv) throws Exception { new Test(); } public void actionPerformed(ActionEvent e) { System.out.println("Command="+e.getActionCommand()); } } src/main/java/org/freehep/xml/menus/test/package.html0000644000175000017500000000001711335255452023317 0ustar giovannigiovanni src/main/java/org/freehep/wbxml/0000755000175000017500000000000011335255452017263 5ustar giovannigiovannisrc/main/java/org/freehep/wbxml/AttributesImpl.java0000644000175000017500000003341611335255452023105 0ustar giovannigiovanni// Copyright FreeHEP, 2007 package org.freehep.wbxml; import java.util.List; /** * * @author Mark Donszelmann * @version $Id$ */ public class AttributesImpl implements MutableAttributes { // FIXME! private static final int MAX = 64; private int nIdx = 0; private int[] type = new int[MAX]; private int[] idx = new int[MAX]; private int[] tags = new int[MAX]; private int nObject; private List[] listValue = new List[MAX]; private int nDoubleValue, nLongValue, nStringValue; private long[] longValue = new long[MAX]; private double[] doubleValue = new double[MAX]; private String[] stringValue = new String[MAX]; private int nObjectArray; private Object[] objectArray = new Object[MAX]; public AttributesImpl() { } public AttributesImpl(Attributes atts) { // make a deep copy of atts this(); int[] tags = atts.getTags(); for (int i = 0; i < tags.length; i++) { int tag = tags[i]; int type = atts.getType(tag); // FIXME, arrays are not copied switch (type) { case BYTE: set(tag, atts.getByteValue(tag)); break; case BOOLEAN: set(tag, atts.getBooleanValue(tag)); break; case CHAR: set(tag, atts.getCharValue(tag)); break; case DOUBLE: set(tag, atts.getDoubleValue(tag)); break; case FLOAT: set(tag, atts.getFloatValue(tag)); break; case INT: set(tag, atts.getIntValue(tag)); break; case LONG: set(tag, atts.getLongValue(tag)); break; case SHORT: set(tag, atts.getShortValue(tag)); break; case STRING: set(tag, atts.getStringValue(tag)); break; default: throw new RuntimeException("Copy of Attributes for type: "+type+" of tag: "+tag+" not handled."); } } } public void clear() { nIdx = 0; nObject = 0; nDoubleValue = 0; nLongValue = 0; nStringValue = 0; nObjectArray = 0; } public void set(int tag, boolean value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = BOOLEAN; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != BOOLEAN) throw new NumberFormatException(); } longValue[idx[index]] = value ? 1 : 0; } public void set(int tag, boolean[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = BOOLEAN_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != BOOLEAN_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, byte value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = BYTE; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != BYTE) throw new NumberFormatException(); } longValue[idx[index]] = value; } public void set(int tag, byte[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = BYTE_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != BYTE_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, char value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = CHAR; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != CHAR) throw new NumberFormatException(); } longValue[idx[index]] = value; } public void set(int tag, char[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = CHAR_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != CHAR_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, double value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = DOUBLE; idx[index] = nDoubleValue; nDoubleValue++; nIdx++; } else { if (type[index] != DOUBLE) throw new NumberFormatException(); } doubleValue[idx[index]] = value; } public void set(int tag, double[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = DOUBLE_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != DOUBLE_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, float value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = FLOAT; idx[index] = nDoubleValue; nDoubleValue++; nIdx++; } else { if (type[index] != FLOAT) throw new NumberFormatException(); } doubleValue[idx[index]] = value; } public void set(int tag, float[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = FLOAT_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != FLOAT_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, int value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = INT; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != INT) throw new NumberFormatException(); } longValue[idx[index]] = value; } public void set(int tag, int[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = INT_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != INT_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, long value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = LONG; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != LONG) throw new NumberFormatException(); } longValue[idx[index]] = value; } public void set(int tag, long[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = LONG_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != LONG_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, short value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = SHORT; idx[index] = nLongValue; nLongValue++; nIdx++; } else { if (type[index] != SHORT) throw new NumberFormatException(); } longValue[idx[index]] = value; } public void set(int tag, short[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = SHORT_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != SHORT_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, String value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = STRING; idx[index] = nStringValue; nStringValue++; nIdx++; } else { if (type[index] != STRING) throw new NumberFormatException( "Found String while expecting: " + getTypeName(type[index])); } stringValue[idx[index]] = value; } public void set(int tag, String[] array) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = STRING_ARRAY; idx[index] = nObjectArray; nObjectArray++; nIdx++; } else { if (type[index] != STRING_ARRAY) throw new NumberFormatException(); } objectArray[idx[index]] = array; } public void set(int tag, List value) { int index = getIndex(tag); if (index < 0) { index = nIdx; tags[index] = tag; type[index] = OBJECT; idx[index] = nObject; nStringValue++; nIdx++; } else { if (type[index] != OBJECT) throw new NumberFormatException(); } listValue[idx[index]] = value; } private int getIndex(int tag) { for (int i = 0; i < nIdx; i++) { if (tag == tags[i]) { return i; } } return -1; } public int getType(int tag) { int index = getIndex(tag); return index < 0 ? -1 : type[index]; } public int[] getTags() { int[] result = new int[nIdx]; System.arraycopy(tags, 0, result, 0, result.length); return result; } public boolean getBooleanValue(int tag, boolean def) { int index = getIndex(tag); return index < 0 ? def : type[index] == BOOLEAN ? longValue[idx[index]] != 0 : def; } public boolean getBooleanValue(int tag) { int index = getIndex(tag); if (type[index] != BOOLEAN) throw new NumberFormatException(); return longValue[idx[index]] != 0; } public boolean[] getBooleanArray(int tag) { int index = getIndex(tag); if (type[index] != BOOLEAN_ARRAY) throw new NumberFormatException(); return (boolean[]) objectArray[idx[index]]; } public byte getByteValue(int tag, byte def) { int index = getIndex(tag); return index < 0 ? def : type[index] == BYTE ? (byte) longValue[idx[index]] : def; } public byte getByteValue(int tag) { int index = getIndex(tag); if (type[index] != BYTE) throw new NumberFormatException(); return (byte) longValue[idx[index]]; } public byte[] getByteArray(int tag) { int index = getIndex(tag); if (type[index] != BYTE_ARRAY) throw new NumberFormatException(); return (byte[]) objectArray[idx[index]]; } public char getCharValue(int tag, char def) { int index = getIndex(tag); return index < 0 ? def : type[index] == CHAR ? (char) longValue[idx[index]] : def; } public char getCharValue(int tag) { int index = getIndex(tag); if (type[index] != CHAR) throw new NumberFormatException(); return (char) longValue[idx[index]]; } public char[] getCharArray(int tag) { int index = getIndex(tag); if (type[index] != CHAR_ARRAY) throw new NumberFormatException(); return (char[]) objectArray[idx[index]]; } public double getDoubleValue(int tag, double def) { int index = getIndex(tag); return index < 0 ? def : type[index] == DOUBLE ? doubleValue[idx[index]] : def; } public double getDoubleValue(int tag) { int index = getIndex(tag); if (type[index] != DOUBLE) throw new NumberFormatException(); return doubleValue[idx[index]]; } public double[] getDoubleArray(int tag) { int index = getIndex(tag); if (type[index] != DOUBLE_ARRAY) throw new NumberFormatException(); return (double[]) objectArray[idx[index]]; } public float getFloatValue(int tag, float def) { int index = getIndex(tag); return index < 0 ? def : type[index] == FLOAT ? (float) doubleValue[idx[index]] : def; } public float getFloatValue(int tag) { int index = getIndex(tag); if (type[index] != FLOAT) throw new NumberFormatException(); return (float) doubleValue[idx[index]]; } public float[] getFloatArray(int tag) { int index = getIndex(tag); if (type[index] != FLOAT_ARRAY) throw new NumberFormatException(); return (float[]) objectArray[idx[index]]; } public int getIntValue(int tag, int def) { int index = getIndex(tag); return index < 0 ? def : type[index] == INT ? (int) longValue[idx[index]] : def; } public int getIntValue(int tag) { int index = getIndex(tag); if (type[index] != INT) throw new NumberFormatException(); return (int) longValue[idx[index]]; } public int[] getIntArray(int tag) { int index = getIndex(tag); if (type[index] != INT_ARRAY) throw new NumberFormatException(); return (int[]) objectArray[idx[index]]; } public long getLongValue(int tag, long def) { int index = getIndex(tag); return index < 0 ? def : type[index] == LONG ? longValue[idx[index]] : def; } public long getLongValue(int tag) { int index = getIndex(tag); if (type[index] != LONG) throw new NumberFormatException(); return longValue[idx[index]]; } public long[] getLongArray(int tag) { int index = getIndex(tag); if (type[index] != LONG_ARRAY) throw new NumberFormatException(); return (long[]) objectArray[idx[index]]; } public short getShortValue(int tag, short def) { int index = getIndex(tag); return index < 0 ? def : type[index] == SHORT ? (short) longValue[idx[index]] : def; } public short getShortValue(int tag) { int index = getIndex(tag); if (type[index] != SHORT) throw new NumberFormatException(); return (short) longValue[idx[index]]; } public short[] getShortArray(int tag) { int index = getIndex(tag); if (type[index] != SHORT_ARRAY) throw new NumberFormatException(); return (short[]) objectArray[idx[index]]; } public String getStringValue(int tag, String def) { int index = getIndex(tag); return index < 0 ? def : type[index] == STRING ? stringValue[idx[index]] : def; } public String getStringValue(int tag) { int index = getIndex(tag); // NOTE: exceptional, we return null if not found if (index < 0) return null; if (type[index] != STRING) throw new NumberFormatException(); return stringValue[idx[index]]; } public String[] getStringArray(int tag) { int index = getIndex(tag); if (type[index] != STRING_ARRAY) throw new NumberFormatException(); return (String[]) objectArray[idx[index]]; } private String getTypeName(int type) { switch (type) { case BOOLEAN: return "boolean"; case BYTE: return "byte"; case CHAR: return "char"; case COLOR: return "Color"; case DOUBLE: return "double"; case FLOAT: return "float"; case INT: return "int"; case LONG: return "long"; case OBJECT: return "Object"; case SHORT: return "short"; case STRING: return "String"; default: return "Unknown"; } } } src/main/java/org/freehep/wbxml/DefaultExtensionHandler.java0000644000175000017500000001065411335255452024713 0ustar giovannigiovanni// Copyright FreeHEP, 2007 package org.freehep.wbxml; import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.xml.sax.SAXException; public class DefaultExtensionHandler implements ExtensionHandler { private List strings = new ArrayList(); public void ext(int i, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException { throw new SAXException("Unknown extension: Ext " + i + " tagID: " + tagID + " attributeID: " + attributeID); } public void extI(int i, String s, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException { if (i==0) { atts.set(attributeID, s); strings.add(s); } else { throw new SAXException("Unknown extension: ExtI " + i + " " + s + " tagID: " + tagID + " attributeID: " + attributeID); } } public void extT(int i, int index, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException { if (i==0) { atts.set(attributeID, (String)strings.get(index)); } else { throw new SAXException("Unknown extension: ExtT " + i + " " + index + " tagID: " + tagID + " attributeID: " + attributeID); } } public void opaque(int len, DataInputStream in, int tagID, int attributeID, MutableAttributes atts, List value) throws IOException, SAXException { int type = in.readByte(); len--; switch(type) { case Attributes.BOOLEAN: if (len == 1) { atts.set(attributeID, in.readByte() != 0); len--; } else { boolean[] array = new boolean[len]; for (int i=0; i 0) { String s = in.readUTF(); in.readByte(); // skip NULL termination strings.add(s); // len (short) + null (byte) len -= WBXMLParser.stringUTFLength(s) + 2 + 1; } if (strings.size() == 1) { atts.set(attributeID, (String)strings.get(0)); } else { String[] array = new String[strings.size()]; array = (String[])strings.toArray(array); atts.set(attributeID, array); } break; default: System.err.println("Unknown extension: Opaque " + len + " tagID: " + tagID + " attributeID: " + attributeID); } if (len > 0) { System.err.println("Skipping "+len+" unused OPAQUE bytes..."); while (len > 0) { in.readByte(); len--; } } } } src/main/java/org/freehep/wbxml/ContentHandler.java0000644000175000017500000000102411335255452023033 0ustar giovannigiovanni// Copyright FreeHEP, 2007. package org.freehep.wbxml; import org.xml.sax.SAXException; /** * * @author Mark Donszelmann * @version $Id$ */ public interface ContentHandler { public void startDocument() throws SAXException; public void endDocument() throws SAXException; public void startElement(int tagID, Attributes attr, boolean empty) throws SAXException; public void endElement(int tagID) throws SAXException; public void characters(char[] chars, int start, int len) throws SAXException; } src/main/java/org/freehep/wbxml/WBXMLTagWriter.java0000644000175000017500000001440011335255452022647 0ustar giovannigiovanni// Copyright 2007, FreeHEP. package org.freehep.wbxml; import java.awt.Color; import java.io.IOException; /** * WBXMLTagWriter Interface. Attributes need to be set before tags are written. * * @author Mark Donszelmann * @version $Id: XMLTagWriter.java 8584 2006-08-10 23:06:37Z duns $ */ public interface WBXMLTagWriter { /** * Close writer * @throws IOException if stream cannot be written */ public void close() throws IOException; /** * Open XML doc with standard parameters * @throws IOException if stream cannot be written */ public void openDoc() throws IOException; /** * Open XML doc * @param version version string * @param encoding encoding * @param standalone if XML is standalone * @throws IOException if stream cannot be written */ public void openDoc(String version, String encoding, boolean standalone) throws IOException; /** * Close XML doc * @throws IOException if stream cannot be written */ public void closeDoc() throws IOException; public void referToDTD(String name, String system); public void referToDTD(String name, String pid, String ref); /** * Write an xml open tag * @param name tagname * @throws IOException if stream cannot be written */ public void openTag(int tag) throws IOException; /** * Close nearest tag * @throws IOException if stream cannot be written */ public void closeTag() throws IOException; /** * Write empty tag * @param name tagname * @throws IOException if stream cannot be written */ public void printTag(int tag) throws IOException; public void printComment(String comment) throws IOException; public void print(String text) throws IOException; /** * Set String attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, String value); /** * Set String attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, String[] value, int offset, int length); /** * Set Color attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, Color value); /** * Set Color attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, Color[] value, int offset, int length); /** * Set byte attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, byte value); /** * Set byte attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, byte[] value, int offset, int length); /** * Set char attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, char value); /** * Set char attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, char[] value, int offset, int length); /** * Set long attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, long value); /** * Set long attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, long[] value, int offset, int length); /** * Set int attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, int value); /** * Set int attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, int[] value, int offset, int length); /** * Set short attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, short value); /** * Set short attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, short[] value, int offset, int length); /** * Set boolean attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, boolean value); /** * Set boolean attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, boolean[] value, int offset, int length); /** * Set float attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, float value); /** * Set float attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, float[] value, int offset, int length); /** * Set double attribute * @param tag attributeID * @param value attribute value */ public void setAttribute(int tag, double value); /** * Set double attribute * @param tag attributeID * @param value attribute value * @param offset start index in array * @param length number of primitives/object to write */ public void setAttribute(int tag, double[] value, int offset, int length); } src/main/java/org/freehep/wbxml/WBXMLParser.java0000644000175000017500000002114011335255452022172 0ustar giovannigiovanni// Copyright FreeHEP, 2007 package org.freehep.wbxml; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Stack; import org.xml.sax.SAXException; /** * SAX-like Binary XML Parser. There is NO support form namespaces, attrPrefixValues or attrValues. * Code pages are handled internally. Both attribute and tag code indexes start at 0 and run up. * * @author Mark Donszelmann * @version $Id: WbxmlParser.java 8584 2006-08-10 23:06:37Z duns $ */ public class WBXMLParser implements WBXML { private DataInputStream in; private ContentHandler contentHandler; private ExtensionHandler extensionHandler; private Map/**/ stringTable; private int version; private int publicIdentifierId; private int charSet; private int tagPage; private int attributePage; private Stack stack = new Stack(); private EntityResolver resolver; public WBXMLParser(ContentHandler contentHandler) { this(contentHandler, new DefaultExtensionHandler()); } public WBXMLParser(ContentHandler contentHandler, ExtensionHandler extensionHandler) { this.contentHandler = contentHandler; this.extensionHandler = extensionHandler; } public void setEntityResolver(EntityResolver resolver) { this.resolver = resolver; } public int getCharSet() { return charSet; } public int getVersion() { return version; } public void parse(InputStream in) throws SAXException, IOException { this.in = in instanceof DataInputStream ? (DataInputStream) in : new DataInputStream(in); char entityBuf[] = new char[1]; tagPage = 0; attributePage = 0; version = readByte(); publicIdentifierId = readInt(); int dtdIndex = 0; if (publicIdentifierId == 0) { dtdIndex = readInt(); } charSet = readInt(); stringTable = new HashMap(); int len = readInt(); int offset = 0; while (offset < len) { String s = this.in.readUTF(); int sLen = stringUTFLength(s); stringTable.put(new Integer(offset), s); in.read(); // skip NULL termination // len (short) + null (byte) offset += sLen + 2 + 1; } contentHandler.startDocument(); if (publicIdentifierId == 0) { String[] dtdPair = ((String)stringTable.get(new Integer(dtdIndex))).split(" ", 2); if (resolver != null) { // FIXME, use the resolver stream resolver.resolveEntity(dtdPair[0], null, dtdPair[1]); } } while (true) { int id = in.read(); if (id == -1) { break; } switch (id) { case SWITCH_PAGE: tagPage = readByte(); break; case END: contentHandler.endElement(((Integer) stack.pop()).intValue()); break; case ENTITY: entityBuf[0] = (char) readInt(); contentHandler.characters(entityBuf, 0, 1); break; case STR_I: String s = readStrI(); contentHandler.characters(s.toCharArray(), 0, s.length()); break; case EXT_I_0: case EXT_I_1: case EXT_I_2: case EXT_T_0: case EXT_T_1: case EXT_T_2: case EXT_0: case EXT_1: case EXT_2: case OPAQUE: int tagID = ((Integer) stack.peek()).intValue(); handleExtensions(id, tagID, -1, null, null); break; case PI: throw new SAXException("PI Not Supported"); case STR_T: String str = readStrT(); contentHandler.characters(str.toCharArray(), 0, str.length()); break; default: readElement(id); } } if (stack.size() != 0) { throw new SAXException("unclosed elements: " + stack); } contentHandler.endDocument(); } private void handleExtensions(int id, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException, IOException { switch (id) { case EXT_I_0: case EXT_I_1: case EXT_I_2: extensionHandler.extI(id - EXT_I_0, readStrI(), tagID, attributeID, atts, value); break; case EXT_T_0: case EXT_T_1: case EXT_T_2: extensionHandler.extT(id - EXT_T_0, readInt(), tagID, attributeID, atts, value); break; case EXT_0: case EXT_1: case EXT_2: extensionHandler.ext(id - EXT_0, tagID, attributeID, atts, value); break; case OPAQUE: int len = readInt(); extensionHandler.opaque(len, in, tagID, attributeID, atts, value); break; } } private Attributes readAttr(int tagID) throws SAXException, IOException { AttributesImpl result = new AttributesImpl(); int id = readByte(); int attributeID = -1; while (id != END) { // attribute start while (id == SWITCH_PAGE) { attributePage = readByte(); id = readByte(); } attributeID = getAttributeId(id); List value = new ArrayList(); // attribute value(s) id = readByte(); while (id > 128 || id == SWITCH_PAGE || id == ENTITY || id == STR_I || id == STR_T || (id >= EXT_I_0 && id <= EXT_I_2) || (id >= EXT_T_0 && id <= EXT_T_2)) { switch (id) { case SWITCH_PAGE: attributePage = readByte(); break; case ENTITY: value.add(new Character((char) readInt())); break; case STR_I: value.add(readStrI()); break; case EXT_I_0: case EXT_I_1: case EXT_I_2: case EXT_T_0: case EXT_T_1: case EXT_T_2: case EXT_0: case EXT_1: case EXT_2: case OPAQUE: handleExtensions(id, tagID, attributeID, result, value); break; case STR_T: value.add(readStrT()); break; default: value.add(new Integer(getAttributeId(id))); } id = readByte(); } switch (value.size()) { case 0: // already handled break; case 1: Object o = value.get(0); if (o instanceof Integer) { result.set(attributeID, ((Integer) o).intValue()); } else if (o instanceof Character) { result.set(attributeID, ((Character) o).charValue()); } else if (o instanceof String) { result.set(attributeID, (String) o); } else { throw new IOException(getClass() + ": Type " + o.getClass() + " not properly handled."); } break; default: result.set(attributeID, value); break; } attributeID = -1; } return result; } private int getTagId(int id) { return (id & 0x03f) + (tagPage * MAX_CODES) - RESERVED_CODES; } private int getAttributeId(int id) { return (id & 0x03f) + (attributePage * MAX_CODES) - RESERVED_CODES; } private void readElement(int id) throws IOException, SAXException { int tagID = getTagId(id & 0x3f); boolean empty; if ((id & CONTENT) != 0) { stack.add(new Integer(tagID)); empty = false; } else { empty = true; } contentHandler.startElement(tagID, ((id & ATTRIBUTE) != 0) ? readAttr(tagID) : new AttributesImpl(), empty); } protected int readByte() throws IOException, SAXException { int i = in.read(); if (i == -1) { throw new SAXException("Unexpected EOF"); } return i; } protected int readInt() throws SAXException, IOException { int result = 0; int i; do { i = readByte(); result = (result << 7) | (i & 0x7f); } while ((i & 0x80) != 0); return result; } protected String readStrI() throws IOException, SAXException { String s = in.readUTF(); in.read(); // skip NULL Termination return s; } protected String readStrT() throws IOException, SAXException { Integer pos = new Integer(readInt()); return (String)stringTable.get(pos); } public static int stringUTFLength(String s) { int bytesNeeded = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) < 0x80) { ++bytesNeeded; } else if (s.charAt(i) < 0x0800) { bytesNeeded += 2; } else if (s.charAt(i) < 0x10000) { bytesNeeded += 3; } else { bytesNeeded += 4; } } return bytesNeeded; } public static void main(String[] args) throws Exception { if (args.length < 1) { System.err.println("Usage: WBXMLParser filename"); System.exit(1); } ContentHandler contentHandler = new ContentHandler() { public void characters(char[] chars, int start, int len) throws SAXException { System.err.print("'" + String.valueOf(chars) + "'"); } public void endDocument() throws SAXException { System.err.println("END DOCUMENT"); } public void endElement(int tagID) throws SAXException { System.err.println(""); } public void startDocument() throws SAXException { System.err.println("START DOCUMENT"); } public void startElement(int tagID, Attributes attr, boolean empty) throws SAXException { System.err.println("<" + tagID); System.err.println(attr.getTags().length); if (empty) System.err.print("/"); System.err.println(">"); } }; WBXMLParser p = new WBXMLParser(contentHandler); p.parse(new FileInputStream(args[0])); } } src/main/java/org/freehep/wbxml/EntityResolver.java0000644000175000017500000000042111335255452023121 0ustar giovannigiovannipackage org.freehep.wbxml; import java.io.IOException; import java.io.InputStream; import org.xml.sax.SAXException; public interface EntityResolver { public InputStream resolveEntity(String name, String publicId, String systemId) throws SAXException, IOException; } src/main/java/org/freehep/wbxml/Attributes.java0000644000175000017500000000503511335255452022257 0ustar giovannigiovanni// Copyright FreeHEP, 2007. package org.freehep.wbxml; /** * * @author Mark Donszelmann * @version $Id$ */ public interface Attributes { public static final int UNDEFINED = -1; public static final int BOOLEAN = 0x00; public static final int BYTE = 0x01; public static final int CHAR = 0x02; public static final int DOUBLE = 0x03; public static final int FLOAT = 0x04; public static final int INT = 0x05; public static final int LONG = 0x06; public static final int SHORT = 0x07; public static final int STRING = 0x08; public static final int OBJECT = 0x09; public static final int COLOR = 0x0a; public static final int BOOLEAN_ARRAY = 0x10; public static final int BYTE_ARRAY = 0x11; public static final int CHAR_ARRAY = 0x12; public static final int DOUBLE_ARRAY = 0x13; public static final int FLOAT_ARRAY = 0x14; public static final int INT_ARRAY = 0x15; public static final int LONG_ARRAY = 0x16; public static final int SHORT_ARRAY = 0x17; public static final int STRING_ARRAY = 0x18; /** * Return the type for a particular attribute tag, or UNDEFINED if * the tag does not exist. * * @param tag * @return */ public int getType(int tag); /** * Return the list of defined attributes * @return */ public int[] getTags(); public String getStringValue(int tag, String def); public double getDoubleValue(int tag, double def); public float getFloatValue(int tag, float def); public long getLongValue(int tag, long def); public int getIntValue(int tag, int def); public char getCharValue(int tag, char def); public short getShortValue(int tag, short def); public byte getByteValue(int tag, byte def); public boolean getBooleanValue(int tag, boolean def); public String getStringValue(int tag); public double getDoubleValue(int tag); public float getFloatValue(int tag); public long getLongValue(int tag); public int getIntValue(int tag); public char getCharValue(int tag); public short getShortValue(int tag); public byte getByteValue(int tag); public boolean getBooleanValue(int tag); public String[] getStringArray(int tag); public double[] getDoubleArray(int tag); public float[] getFloatArray(int tag); public long[] getLongArray(int tag); public int[] getIntArray(int tag); public char[] getCharArray(int tag); public short[] getShortArray(int tag); public byte[] getByteArray(int tag); public boolean[] getBooleanArray(int tag); } src/main/java/org/freehep/wbxml/WBXMLWriter.java0000644000175000017500000003141411335255452022217 0ustar giovannigiovanni// Copyright FreeHEP, 2007. package org.freehep.wbxml; import java.awt.Color; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; /** * Writes out Binary XML see http://www.wapforum.org instead of ASCII XML. * * @author Mark Donszelmann * @version $Id$ */ public class WBXMLWriter implements WBXMLTagWriter { // outputstream variables private DataOutputStream os; private String dtd; private String version; private boolean writtenHeader; // Code pages private int tagPage; private int attributePage; // tag attributes private boolean hasAttributes; private int[] attributeTypes; // cache private boolean[][] attributeBoolean; private int[] attributeBooleanOffset; private int[] attributeBooleanLength; private byte[][] attributeByte; private int[] attributeByteOffset; private int[] attributeByteLength; private char[][] attributeChar; private int[] attributeCharOffset; private int[] attributeCharLength; private double[][] attributeDouble; private int[] attributeDoubleOffset; private int[] attributeDoubleLength; private float[][] attributeFloat; private int[] attributeFloatOffset; private int[] attributeFloatLength; private int[][] attributeInt; private int[] attributeIntOffset; private int[] attributeIntLength; private long[][] attributeLong; private int[] attributeLongOffset; private int[] attributeLongLength; private short[][] attributeShort; private int[] attributeShortOffset; private int[] attributeShortLength; private String[][] attributeString; private int[] attributeStringOffset; private int[] attributeStringLength; private String encoding; private boolean standalone; /** * Create a Binary AIDA Writer for given stream * * @param os * stream to write to * @param maxAttributeCode largest tagcode for attributes */ public WBXMLWriter(OutputStream os, int maxAttributeTagCode) throws IOException { this.os = (os instanceof DataOutputStream) ? (DataOutputStream) os : new DataOutputStream(os); tagPage = 0; attributePage = 0; int len = maxAttributeTagCode+1; attributeBoolean = new boolean[len][]; attributeBooleanOffset = new int[len]; attributeBooleanLength = new int[len]; attributeByte = new byte[len][]; attributeByteOffset = new int[len]; attributeByteLength = new int[len]; attributeChar = new char[len][]; attributeCharOffset = new int[len]; attributeCharLength = new int[len]; attributeDouble = new double[len][]; attributeDoubleOffset = new int[len]; attributeDoubleLength = new int[len]; attributeFloat = new float[len][]; attributeFloatOffset = new int[len]; attributeFloatLength = new int[len]; attributeInt = new int[len][]; attributeIntOffset = new int[len]; attributeIntLength = new int[len]; attributeLong = new long[len][]; attributeLongOffset = new int[len]; attributeLongLength = new int[len]; attributeShort = new short[len][]; attributeShortOffset = new int[len]; attributeShortLength = new int[len]; attributeString = new String[len][]; attributeStringOffset = new int[len]; attributeStringLength = new int[len]; attributeTypes = new int[len]; clearAttributes(); } private void clearAttributes() { hasAttributes = false; for (int i = 0; i < attributeTypes.length; i++) { attributeTypes[i] = -1; } } public void close() throws IOException { os.close(); } public void openDoc() throws IOException { openDoc("Binary/1.0", "UTF-8", false); } public void openDoc(String version, String encoding, boolean standalone) throws IOException { dtd = null; writtenHeader = false; this.version = version; this.encoding = encoding; this.standalone = standalone; } private void writeHeader() throws IOException { if (writtenHeader) return; if (dtd == null) throw new IOException("DTD is missing"); // header writeByte(WBXML.WBXML_VERSION); writeByte(WBXML.INDEXED_PID); writeMultiByteInt(0); // dtd has to be first entry in table. writeMultiByteInt(WBXML.UTF8); // length string table: add (short) length and (byte) null. int len = WBXMLParser.stringUTFLength(dtd) + 2 + 1; len += WBXMLParser.stringUTFLength(version) + 2 + 1; writeMultiByteInt(len); // Binary AIDA Header (as part of the string table) writeString(dtd); writeString(version); writtenHeader = true; } public void closeDoc() throws IOException { // ignored } public void referToDTD(String name, String pid, String ref) { // ignored } public void referToDTD(String name, String system) { dtd = name+" "+system; } public void openTag(int tag) throws IOException { writeTag(tag, true); } public void closeTag() throws IOException { writeByte(WBXML.END); } public void printTag(int tag) throws IOException { writeTag(tag, false); } public void print(String text) throws IOException { writeByte(WBXML.STR_I); writeString(text); } public void printComment(String comment) throws IOException { // ignored } private void writeTag(int tag, boolean hasContent) throws IOException { if (!writtenHeader) writeHeader(); // write tag int page = tag / WBXML.MAX_CODES; if (page != tagPage) { writeByte(WBXML.SWITCH_PAGE); writeByte(page); tagPage = page; } tag = tag % WBXML.MAX_CODES; writeByte((tag + WBXML.RESERVED_CODES) | (hasContent ? WBXML.CONTENT : 0x00) | (hasAttributes ? WBXML.ATTRIBUTE : 0x00)); // write attributes if (hasAttributes) { // write attributes for (int i = 0; i < attributeTypes.length; i++) { if (attributeTypes[i] >= 0) { // write ATTRSTART writeAttribute(i); switch (attributeTypes[i]) { case Attributes.BOOLEAN: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeBooleanLength[i]*1+1); writeByte(Attributes.BOOLEAN); for (int j = 0; j < attributeBooleanLength[i]; j++) { writeByte(attributeBoolean[i][j+attributeBooleanOffset[i]] ? 1 : 0); } break; case Attributes.BYTE: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeByteLength[i]*1+1); writeByte(Attributes.BYTE); for (int j = 0; j < attributeByteLength[i]; j++) { writeByte(attributeByte[i][j+attributeByteOffset[i]]); } break; case Attributes.CHAR: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeCharLength[i]*2+1); writeByte(Attributes.CHAR); for (int j = 0; j < attributeCharLength[i]; j++) { os.writeChar(attributeChar[i][j+attributeCharOffset[i]]); } break; case Attributes.DOUBLE: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeDoubleLength[i]*8+1); writeByte(Attributes.DOUBLE); for (int j = 0; j < attributeDoubleLength[i]; j++) { os.writeDouble(attributeDouble[i][j+attributeDoubleOffset[i]]); } break; case Attributes.FLOAT: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeFloatLength[i]*4+1); writeByte(Attributes.FLOAT); for (int j = 0; j < attributeFloatLength[i]; j++) { os.writeFloat(attributeFloat[i][j+attributeFloatOffset[i]]); } break; case Attributes.INT: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeIntLength[i]*4+1); writeByte(Attributes.INT); for (int j = 0; j < attributeIntLength[i]; j++) { os.writeInt(attributeInt[i][j+attributeIntOffset[i]]); } break; case Attributes.LONG: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeLongLength[i]*8+1); writeByte(Attributes.LONG); for (int j = 0; j < attributeLongLength[i]; j++) { os.writeLong(attributeLong[i][j+attributeLongOffset[i]]); } break; case Attributes.SHORT: // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(attributeShortLength[i]*2+1); writeByte(Attributes.SHORT); for (int j = 0; j < attributeShortLength[i]; j++) { os.writeShort(attributeShort[i][j+attributeShortOffset[i]]); } break; case Attributes.STRING: // calculate total length int length = 0; for (int j = 0; j < attributeStringLength[i]; j++) { // add (short) length and (byte) null termination length += WBXMLParser.stringUTFLength((String)attributeString[i][j+attributeStringOffset[i]]) + 2 + 1; } // write OPAQUE writeByte(WBXML.OPAQUE); writeMultiByteInt(length+1); writeByte(Attributes.STRING); // write UTF strings for (int j = 0; j < attributeStringLength[i]; j++) { writeString(attributeString[i][j+attributeStringOffset[i]]); } break; } } } // end of attributes writeByte(WBXML.END); clearAttributes(); } } private void writeAttribute(int tag) throws IOException { int page = tag / WBXML.MAX_CODES; tag = tag % WBXML.MAX_CODES; if (page != attributePage) { writeByte(WBXML.SWITCH_PAGE); writeByte(page); attributePage = page; } writeByte(tag + WBXML.RESERVED_CODES); } public void setAttribute(int tag, String value) { setAttribute(tag, new String[] { value }, 0, 1); } public void setAttribute(int tag, String[] value, int offset, int length) { hasAttributes = true; attributeString[tag] = value; attributeStringOffset[tag] = offset; attributeStringLength[tag] = length; attributeTypes[tag] = Attributes.STRING; } public void setAttribute(int tag, byte value) { setAttribute(tag, new byte[] { value }, 0, 1); } public void setAttribute(int tag, byte[] value, int offset, int length) { hasAttributes = true; attributeByte[tag] = value; attributeByteOffset[tag] = offset; attributeByteLength[tag] = length; attributeTypes[tag] = Attributes.BYTE; } public void setAttribute(int tag, long value) { setAttribute(tag, new long[] { value }, 0, 1); } public void setAttribute(int tag, long[] value, int offset, int length) { hasAttributes = true; attributeLong[tag] = value; attributeLongOffset[tag] = offset; attributeLongLength[tag] = length; attributeTypes[tag] = Attributes.LONG; } public void setAttribute(int tag, int value) { setAttribute(tag, new int[] { value }, 0, 1); } public void setAttribute(int tag, int[] value, int offset, int length) { hasAttributes = true; attributeInt[tag] = value; attributeIntOffset[tag] = offset; attributeIntLength[tag] = length; attributeTypes[tag] = Attributes.INT; } public void setAttribute(int tag, boolean value) { setAttribute(tag, new boolean[] { value }, 0, 1); } public void setAttribute(int tag, boolean[] value, int offset, int length) { hasAttributes = true; attributeBoolean[tag] = value; attributeBooleanOffset[tag] = offset; attributeBooleanLength[tag] = length; attributeTypes[tag] = Attributes.BOOLEAN; } public void setAttribute(int tag, float value) { setAttribute(tag, new float[] { value }, 0, 1); } public void setAttribute(int tag, float[] value, int offset, int length) { hasAttributes = true; attributeFloat[tag] = value; attributeFloatOffset[tag] = offset; attributeFloatLength[tag] = length; attributeTypes[tag] = Attributes.FLOAT; } public void setAttribute(int tag, double value) { setAttribute(tag, new double[] { value }, 0, 1); } public void setAttribute(int tag, double[] value, int offset, int length) { hasAttributes = true; attributeDouble[tag] = value; attributeDoubleOffset[tag] = offset; attributeDoubleLength[tag] = length; attributeTypes[tag] = Attributes.DOUBLE; } public void setAttribute(int tag, Color value) { setAttribute(tag, new Color[] { value }, 0, 1); } public void setAttribute(int tag, Color[] value, int offset, int length) { // ignored } public void setAttribute(int tag, char value) { setAttribute(tag, new char[] { value }, 0, 1); } public void setAttribute(int tag, char[] value, int offset, int length) { hasAttributes = true; attributeChar[tag] = value; attributeCharOffset[tag] = offset; attributeCharLength[tag] = length; attributeTypes[tag] = Attributes.CHAR; } public void setAttribute(int tag, short value) { setAttribute(tag, new short[] { value }, 0, 1); } public void setAttribute(int tag, short[] value, int offset, int length) { hasAttributes = true; attributeShort[tag] = value; attributeShortOffset[tag] = offset; attributeShortLength[tag] = length; attributeTypes[tag] = Attributes.SHORT; } private void writeMultiByteInt(long ui) throws IOException { int buf[] = new int[5]; int idx = 0; do { buf[idx++] = (int) (ui & 0x7f); ui = ui >> 7; } while (ui != 0); while (idx > 1) { writeByte(buf[--idx] | 0x80); } writeByte(buf[0]); } private void writeByte(int b) throws IOException { os.writeByte(b); } private void writeString(String s) throws IOException { os.writeUTF(s); os.writeByte(0); } } src/main/java/org/freehep/wbxml/WBXML.java0000644000175000017500000000632011335255452021020 0ustar giovannigiovanni// Copyright FreeHEP, 2007 package org.freehep.wbxml; /** * Tag Codes for Binary XML. * @author Mark Donszelmann * @version $Id$ */ public interface WBXML { // Change the code page for the current token state. Followed by a single u_int8 indicating the new code page number. public final static int SWITCH_PAGE = 0x00; // Indicates the end of an attribute list or the end of an element. public final static int END = 0x01; // A character entity. Followed by a mb_u_int32 encoding the character entity number. public final static int ENTITY = 0x02; // Inline string. Followed by a termstr. public final static int STR_I = 0x03; // An unknown tag or attribute name. Followed by an mb_u_int32 that encodes an offset into the string table. public final static int LITERAL = 0x04; // Inline string document-type-specific extension token. Token is followed by a termstr. public final static int EXT_I_0 = 0x40; // Inline string document-type-specific extension token. Token is followed by a termstr. public final static int EXT_I_1 = 0x41; // Inline string document-type-specific extension token. Token is followed by a termstr. public final static int EXT_I_2 = 0x42; // Processing instruction. public final static int PI = 0x43; // Unknown tag, with content. public final static int LITERAL_C = 0x44; // Inline integer document-type-specific extension token. Token is followed by a mb_uint_32. public final static int EXT_T_0 = 0x80; // Inline integer document-type-specific extension token. Token is followed by a mb_uint_32. public final static int EXT_T_1 = 0x81; // Inline integer document-type-specific extension token. Token is followed by a mb_uint_32. public final static int EXT_T_2 = 0x82; // String table reference. Followed by a mb_u_int32 encoding a byte offset from the beginning of the string table. public final static int STR_T = 0x83; // Unknown tag, with attributes. public final static int LITERAL_A = 0x84; // Single-byte document-type-specific extension token. public final static int EXT_0 = 0xC0; // Single-byte document-type-specific extension token. public final static int EXT_1 = 0xC1; // Single-byte document-type-specific extension token. public final static int EXT_2 = 0xC2; // Opaque document-type-specific data. public final static int OPAQUE = 0xC3; // Unknown tag, with content and attributes. public final static int LITERAL_AC = 0xC4; /** * WBXML version number */ public static final int WBXML_VERSION = 0x03; /** * WBXML Constant for Unknown PID */ public static final int UNKNOWN_PID = 0x01; /** * WBXML Constant for Indexed PID */ public static final int INDEXED_PID = 0x00; /** * WBXML Constant for UTF 8 */ public static final int UTF8 = 0x6a; /** * Content Mask */ public static final int CONTENT = 0x40; /** * Attribute Mask */ public static final int ATTRIBUTE = 0x80; /** * Number of reserved tag codes */ public static final int RESERVED_CODES = 5; /** * Maximum attribute or tag codes */ public static final int MAX_CODES = CONTENT - RESERVED_CODES; } src/main/java/org/freehep/wbxml/MutableAttributes.java0000644000175000017500000000205211335255452023565 0ustar giovannigiovanni// Copyright FreeHEP, 2007. package org.freehep.wbxml; import java.util.List; /** * * @author Mark Donszelmann * @version $Id$ */ public interface MutableAttributes extends Attributes { public void clear(); public void set(int tag, boolean value); public void set(int tag, boolean[] value); public void set(int tag, byte value); public void set(int tag, byte[] value); public void set(int tag, char value); public void set(int tag, char[] value); public void set(int tag, double value); public void set(int tag, double[] value); public void set(int tag, float value); public void set(int tag, float[] value); public void set(int tag, int value); public void set(int tag, int[] value); public void set(int tag, long value); public void set(int tag, long[] value); public void set(int tag, short value); public void set(int tag, short[] value); public void set(int tag, String value); public void set(int tag, String[] value); public void set(int tag, List value); } src/main/java/org/freehep/wbxml/ExtensionHandler.java0000644000175000017500000000141311335255452023377 0ustar giovannigiovanni// Copyright FreeHEP, 2007. package org.freehep.wbxml; import java.io.DataInputStream; import java.io.IOException; import java.util.List; import org.xml.sax.SAXException; /** * * @author Mark Donszelmann * @version $Id$ */ public interface ExtensionHandler { public void extI(int i, String readStrI, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException; public void extT(int i, int readInt, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException; public void ext(int i, int tagID, int attributeID, MutableAttributes atts, List value) throws SAXException; public void opaque(int len, DataInputStream in, int tagID, int attributeID, MutableAttributes atts, List value) throws IOException, SAXException; } src/main/resources/0000755000175000017500000000000011335255452015016 5ustar giovannigiovannisrc/main/resources/org/0000755000175000017500000000000011335255452015605 5ustar giovannigiovannisrc/main/resources/org/freehep/0000755000175000017500000000000011335255452017223 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/0000755000175000017500000000000011335255452020023 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/util/0000755000175000017500000000000011341744321020773 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/0000755000175000017500000000000011335255452021152 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/1.0/0000755000175000017500000000000011335255452021450 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/1.0/menus.dtd0000644000175000017500000000725511335255452023305 0ustar giovannigiovanni src/main/resources/org/freehep/xml/menus/test/0000755000175000017500000000000011335255452022131 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/test/images/0000755000175000017500000000000011335255452023376 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/test/images/New_Program_Wizard.gif0000644000175000017500000000155511335255452027633 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@JY H@ 0J,"ANdq Ž+:hPD5^ JGtILL\hqgΊ;src/main/resources/org/freehep/xml/menus/test/images/Load_Program.gif0000644000175000017500000000160411335255452026434 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@a H@.i)$`` Y8 D/N,' vFR\./c48 šrȉ c(B:CXk8!*h0 ;src/main/resources/org/freehep/xml/menus/test/images/Run.gif0000644000175000017500000000154711335255452024640 0ustar giovannigiovanniGIF89a 3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!, DY H  P@ B!ˆ`TqA@MG$$4D;&,jFM ;src/main/resources/org/freehep/xml/menus/test/images/Back.gif0000644000175000017500000000155111335255452024727 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@FY H@ǚ[p!=q"ŋU Ǐ" I$)jLYPƗ/D(͛,m3 ;src/main/resources/org/freehep/xml/menus/test/images/Home.gif0000644000175000017500000000163511335255452024762 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@zY H@X]CV >xbM*  B4(pEV2pH'rlh2䵑ܩdɊh\I&CYTxӨƥ.U qnGZYI} ;src/main/resources/org/freehep/xml/menus/test/images/Open.gif0000644000175000017500000000021411335255452024763 0ustar giovannigiovanniGIF89aff! ,9I*_<~ڕ,gmp8DQJ$2b Y;src/main/resources/org/freehep/xml/menus/test/images/Save.gif0000644000175000017500000000021211335255452024756 0ustar giovannigiovanniGIF89aff! ,7IT8k}(bh)%VKat Iu(婘4";src/main/resources/org/freehep/xml/menus/test/images/Redo.gif0000644000175000017500000000153011335255452024755 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@5Y H@l Y B &4HE^ȱ#E-NQ"E#%Ȓe@;src/main/resources/org/freehep/xml/menus/test/images/Step.gif0000644000175000017500000000153611335255452025005 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@;Y H A#*L ÉF8Qŏ -RpdA =LrC~ ;src/main/resources/org/freehep/xml/menus/test/images/Undo.gif0000644000175000017500000000153411335255452024775 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@9Y H@6dpJ8!Å )HǏ-dqHIR:y%2v%-&j"FHiz\e#HѢH;Br G*?1e 8q4i2PJ&3^@tBH5r5+t£HZ!Ԣ`r ;src/main/resources/org/freehep/xml/menus/test/images/Splash.jpg0000644000175000017500000013342611335255452025343 0ustar giovannigiovanniJFIFHHC  !"$"$C,,"H!1A"Q2aq#BR$34Cb%rSc&Ds=!1A"Qaq#23BRb64S ? .OM2DII2Ve-AAVM*SWMfO-)I>7R&c:SvC4ABյcw0AҎJzaewSa۾:ZFJJhxs\b%E%KZ!I *ʙʜT56lzFt}0)& z%$$/UXߌc = vԝ> liTž'νa?ݚROE@%'ܝcQ% *TjY麻܅H}cb;qoTb2۽JԦ*6>Se9hz"\СuTEjIԃBю(_ԧbTX-[^Qɵ%eHTd1tNN-iJDx76*wAsbCe)$7oMmk[|kɐfKEM PhA{ml.֕/,ܵ2bD])Ωp((e I7 g?0sLMVVQ/pBFK4A`ISI$ck#Tf?XJ$bww lUd:BM3Pc*D8xi?oObAVVߍj{19)ajZGQָ'6$r"LSeiZdJԓx#PWc6k~jfD3Pڑ^--=Yl)HIV7*"D\aE#6j.)V6 T**B >8Hҝ=IVZU{5Q~`t 6?|- 6KESF5$FxW}Gt: dMR5yHmZT 0؃lVvbK] #CW KehJiXAh{Gm&"%'¢R zNSҋe7Q)Gs=S?J1ғSq+Qbjol660~@a$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QTĆSY #U`C3T'ZaO(;Ƕ!yO)7BDB` +:jt% u co"c-iM+%M]mV/!6IԄzN?t$ޢl|M&G>n9Bw،\ۏ]iIK`0"Þp"[R.F ?%Ge(?\XW+ =ɑҤe_ +*bRT$Gp]rA  2|R HC(TMo0 -A`ސdJUrp70B] 6 E\cp8a94 t2*=vJ*lGq?UA ^*D+2I%J)Z9$V\X5 |73='Ad%Z[78GYXqg[Բm7T9_src/main/resources/org/freehep/xml/menus/test/images/Forward.gif0000644000175000017500000000155211335255452025474 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,@GY H`*L,BpE2jhYŋ$^Irdyh˖V@&c"A~Dɳ`@;src/main/resources/org/freehep/xml/menus/test/images/Rewind.gif0000644000175000017500000000167311335255452025324 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,Y H=$z tE=K94"k%qOX D='z)pV; kVذAF&́zIds资 Ȓh"&ȪkѐNeUJάP(Ȕт?_5mD 5J6J,W`@;src/main/resources/org/freehep/xml/menus/test/images/Go.gif0000644000175000017500000000163411335255452024436 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,yY H @V*LheAVI81È)ZȆkBf‘1K5:%L:iڔ0/%^ɊM%  :OUy5hMEÅٲe ;src/main/resources/org/freehep/xml/menus/test/images/Stop.gif0000644000175000017500000000161111335255452025011 0ustar giovannigiovanniGIF89a3f333f3333f3ffffff3f̙3f3f333f333333333f33333333f33f3ff3f3f3f3333f33̙33333f3333333f3333f3ffffff3f33ff3f3f3f3fff3ffffffffffff3ffff̙fff3fffffff3ffffff3f333f3333f3ffffff3f̙̙3̙f̙̙̙̙3f3f̙333f3̙333f3fff̙fff3f̙̙3f̙3f̙3f333f3333f3ffffff3f̙3f3f!,fY  A4XaC pHaĉ+P85V=^+ AtXR"E),XQF/EdʕqE$nj7"5ɇ38Zӫ;src/main/resources/org/freehep/xml/menus/test/menus.xml0000644000175000017500000002752611335255452024016 0ustar giovannigiovanni src/main/resources/org/freehep/xml/menus/1.1/0000755000175000017500000000000011335255452021451 5ustar giovannigiovannisrc/main/resources/org/freehep/xml/menus/1.1/menus.dtd0000644000175000017500000000731111335255452023277 0ustar giovannigiovanni src/site/0000755000175000017500000000000011335255452013024 5ustar giovannigiovannisrc/site/site.xml0000644000175000017500000000314511335255452014515 0ustar giovannigiovanni FreeHEP XML http://java.freehep.org/freehep-xml FreeHEP http://java.freehep.org/images/sm-freehep.gif http://java.freehep.org/ src/site/apt/0000755000175000017500000000000011335255452013610 5ustar giovannigiovannisrc/site/apt/index.apt0000644000175000017500000000026211335255452015425 0ustar giovannigiovanni --- FreeHEP XML --- --- Mark Donszelmann --- Introduction Readers and writers for the XML format as well as a Menu System for building GUI menus from XML.