Package net.xoetrope.optional.service

Examples of net.xoetrope.optional.service.XRouteManager


   * @param model the model for the source element
   */
  public void loadRoutes( XmlElement source, XModel model )
  {
    // Initialise the XRouteManager
    XRouteManager routeMgr = ((XRouteManager)currentProject.getObject( "RouteMgr" ));
    if ( routeMgr == null ) {
      routeMgr = new XRouteManager( currentProject );
      currentProject.setObject( "RouteMgr", routeMgr );
    }

    Vector routeNodes = source.getChildren();

    // iterate all of the 'route' children
    int routeCount = routeNodes.size();
    for ( int i = 0; i < routeCount; i++ ) {
      XmlElement routeElement = ( XmlElement )routeNodes.elementAt( i );
      String routeName = routeElement.getAttribute( "id" );
      if ( routeName == null )
        continue;

      // For each route add the layers
      int layerCount = routeElement.getChildren().size();
      Hashtable[] layers = new Hashtable[ layerCount ];
      for ( int layer = 0; layer < layerCount; layer++ ) {
        XmlElement layerElement = routeElement.elementAt( layer );
        Hashtable layerTable = new Hashtable();

        // Put any extra attributes into a hashtable
        Enumeration attribs = layerElement.enumerateAttributeNames();
        while ( attribs.hasMoreElements() ) {
          String attribName = attribs.nextElement().toString();
          layerTable.put( attribName, layerElement.getAttribute( attribName ) );

          // Add the children of the layer node
          int pathCount = layerElement.getChildren().size();
          for ( int pathIdx = 0; pathIdx < pathCount; pathIdx++ ) {
            XmlElement pathElement = layerElement.elementAt( pathIdx );
            Vector pathTable = new Vector();

            // Put any extra path attributes into a hashtable
            Enumeration pathAttribs = pathElement.enumerateAttributeNames();
            while ( pathAttribs.hasMoreElements() ) {
              String pathAttribName = (String)pathAttribs.nextElement();
              if ( pathAttribName.compareTo( "id" ) == 0 )
                pathTable.add( pathElement.getAttribute( "id" ) );
              else
                ; // do nothing with the extra data for now.
            }

            layerTable.put( new Integer( pathIdx ).toString(), pathTable );
          }
        }
        layers[ layer ] = layerTable;

      }
      // add the route to the XRouteManager
      routeMgr.addRoute( routeName, layers );
    }
  }
View Full Code Here

TOP

Related Classes of net.xoetrope.optional.service.XRouteManager

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