Package net.xoetrope.xml

Examples of net.xoetrope.xml.XmlElement


   * @param reader the stream to read
   */
  public void read( Reader reader )
  {
    try {
      XmlElement root = XmlSource.read( reader );

      Vector nodes = root.getChildren();
      int numNodes = nodes.size();
      for ( int i = 0; i < numNodes; i++ ) {
        XmlElement node = (XmlElement)nodes.elementAt( i );
        String nodeName = node.getName();
        if ( nodeName.equals( "PropertySets" )) {
          Vector customizationNodes = node.getChildren();
          int numCustomizations = customizationNodes.size();
          for ( int j = 0; j < numCustomizations; j++ ) {
            XmlElement customizationNode = (XmlElement)customizationNodes.elementAt( j );
            String setName = customizationNode.getAttribute( "name" );
            customizations.put( setName, customizationNode );
          }
        }
        else if ( nodeName.equals( "Adaptors" )) {
          Vector customizationNodes = node.getChildren();
          int numCustomizations = customizationNodes.size();
          for ( int j = 0; j < numCustomizations; j++ ) {
            XmlElement customizationNode = (XmlElement)customizationNodes.elementAt( j );
            String customizationName = customizationNode.getAttribute( "name" );
            Object[] args = getArguments( customizationNode.getAttribute( "args" ), null );
            CustomizationAdapter adapter = (CustomizationAdapter)ReflectionHelper.constructViaReflection( customizationNode.getAttribute( "class" ), args );
            adaptors.put( customizationName, adapter );
          }
        }
      }
    }
View Full Code Here


   */
  public void run()
  {
    try {
      if ( content != null ) {
        XmlElement src;
        if ( !useContent ) {
          src = XmlSource.read( currentProject.getBufferedReader( content, null ) );
          ( ( XMetaContentHolder ) comp ).setContent( content, src );
        }
        else {
View Full Code Here

   */
  public void setFileName( String fileName )
  {
    try {
      if ( fileName != null ) {
        XmlElement src = XmlSource.read( currentProject.getBufferedReader( fileName, null ) );
        setContent( fileName, src );
      }
    }
    catch ( Exception ex ) {
      DebugLogger.logWarning( "Unable to load content: " + fileName );
View Full Code Here

   * @param newContent the new content to display
   */
  public void setContent( String newContent )
  {
    if (( strContent != null ) && ( strContent.indexOf( "<?xml" ) == 0 )) {
      XmlElement src = XmlSource.read( new StringReader( newContent ) );
      setContent( newContent, src );
    }
    else if ( newContent.indexOf ( ".xml" ) > 0 )
      setContent( newContent, null );
    else {
View Full Code Here

    Vector elements = element.getChildren();
    int numElements = elements.size();

    for ( int i = 0; i < numElements; i++ ) {
      XmlElement child = (XmlElement)elements.elementAt( i );
      int method = ((Integer)methodTable.get( child.getName().toLowerCase())).intValue();

      if ( !renderItem( g, child, method ))
        renderText( g, child.getContent() );

      pushStyle();
      render( g, child );
      popStyle();
    }
View Full Code Here

   * Read a model from the Reader
   * @param r the Reader
   */
  public void read( Reader r )
  {
    XmlElement ele = XmlSource.read( r );
    XmlElement dbSrc = null, routeSrc = null, serviceSrc = null;
    Vector v = ele.getChildren();
    if ( v != null ) {
      int numFiles = v.size();
      XModel model = currentProject.getModel();
      for ( int i = 0; i < numFiles; i++ ) {
        try {
          XmlElement source = ( XmlElement )v.elementAt( i );
          Reader sr = currentProject.getBufferedReader( source.getAttribute( "filename" ), "UTF8" );
          if ( sr == null )
            continue;

          if ( BuildProperties.DEBUG )
            DebugLogger.trace( "Datasource: " + source.getAttribute( "filename" ) );

          XmlElement src = XmlSource.read( sr );
          String type = source.getAttribute( "type" );
          if (( type == null ) || ( type.length()==0 ))
            loadTable( src, model );
          else if ( type.equals( "database" ))
            dbSrc = src;
View Full Code Here

   * @param source the source element
   * @param model the model for the source element
   */
  public void loadDatabase( XmlElement source, XModel model )
  {
    XmlElement connEle = source.elementAt( 0 );
    String dbDriver = connEle.getAttribute( "driver" );
    String dbUrl = connEle.getAttribute( "url" );
    dbUrl = checkLocalHsqldb( dbDriver, dbUrl );

    NamedConnectionManager connMgr = ( NamedConnectionManager )NamedConnectionManager.getInstance();
    connMgr = ( NamedConnectionManager )connMgr.reset( connEle.getAttribute( "id" ),
        dbDriver,
        dbUrl,
        connEle.getAttribute( "user" ),
        connEle.getAttribute( "pwd" ) );

    registerDatabaseNode( connEle );
    Vector vRS = source.getChildren();
    int rsCount = vRS.size();
    int numChildren = model.getNumChildren();
    numChildren += rsCount;
    model.setNumChildren( numChildren );
    for ( int i = 1; i < rsCount; i++ ) {
      XmlElement rsEle = ( XmlElement )vRS.elementAt( i );
      if ( rsEle.getName().compareTo( "Connection" ) == 0 ) {
        String extraDbDriver = rsEle.getAttribute( "driver" );
        String extraDbUrl = rsEle.getAttribute( "url" );
        extraDbUrl = checkLocalHsqldb( extraDbDriver, extraDbUrl );
        connMgr.addConnection( rsEle.getAttribute( "id" ),
                               extraDbDriver,
                               extraDbUrl,
                               rsEle.getAttribute( "user" ),
                               rsEle.getAttribute( "pwd" ) );
      }
      else {
        DatabaseTableModel tableModel = new DatabaseTableModel( currentProject );
        String escapeStr = rsEle.getAttribute( "escape" );
        if ( escapeStr != null )
          tableModel.setDoesEscapeProcessing( "true".equals( escapeStr ));
       
        tableModel.setName( rsEle.getAttribute( "id" ) );
        boolean updateDb = false;
        String updateStr = rsEle.getAttribute( "update" );
        if ( updateStr != null )
          updateDb = updateStr.compareTo( "true" ) == 0;

        String sqlStr = rsEle.getAttribute( "sql" );
        if (( sqlStr != null ) && ( sqlStr.length() > 0 ))
          tableModel.setSqlStatement( sqlStr, rsEle.getAttribute( "conn" ), updateDb );
        else {
            // We should probably change the name table to from as it equates to the FROM clause
          tableModel.setupTable( rsEle.getAttribute( "from" ),
                                 rsEle.getAttribute( "fields" ),
                                 rsEle.getAttribute( "where" ),
                                 rsEle.getAttribute( "conn" ),
                                 updateDb );
          String distinctStr = rsEle.getAttribute( "distinct" );
          if ( distinctStr != null )
            tableModel.setDistinct( distinctStr.equals( "true" ));

          tableModel.setOrderField( rsEle.getAttribute( "order" ) );
        }
        model.append( tableModel );
      }
      registerDatabaseNode( rsEle );
    }
View Full Code Here

    Vector serviceNodes = source.getChildren();

    // iterate all of the 'service' children
    int serviceCount = serviceNodes.size();
    for ( int i = 0; i < serviceCount; i++ ) {
      XmlElement eleService = ( XmlElement )serviceNodes.elementAt( i );
      String serviceName = eleService.getAttribute( "id" );
      if ( BuildProperties.DEBUG ) {
        if ( serviceName == null )
          DebugLogger.logWarning( "Service (" + i + ") id is null or missing" );
      }
      String serviceRoute = eleService.getAttribute( "route" );
      String serviceImplementationClass = eleService.getAttribute( "server" );
//      int argSize = eleService.getChildren().size();

      // iterate the 'arg' and 'return' elements of the service
      /*
       * This is removed for now as it really wasn't doing anything. We should re-introduce it
View Full Code Here

    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 );
View Full Code Here

   * @param reader the reader from which to read the file
   */
  public void read( String key, Reader reader )
  {
    try {
      XmlElement regRoot = XmlSource.read( reader );
     
      // Setup the action factory
      String actionFactoryClass = (String)regRoot.getAttribute( "factory" );
      if ( actionFactoryClass == null )
        actionFactoryClass = "net.xoetrope.swing.actions.XSwingActionFactory";
      try {       
        if ( actionFactory == null )
          actionFactory = (XActionFactory)Class.forName( actionFactoryClass.trim()).newInstance();
      }
      catch ( Exception ex )
      {
        DebugLogger.logError( "Unable to setup the action factory" );
        ex.printStackTrace();
        return;
      }

      Vector registrationNodes = regRoot.getChildren();
      int numElements = registrationNodes.size();
      for ( int i = 0; i < numElements; i++ ) {
        XmlElement regElement = (XmlElement)registrationNodes.elementAt( i );
        String tag = regElement.getName();
        String context;
        if ( !"Context".equalsIgnoreCase( tag )) {
          context = "global";
          Hashtable contextActions = (Hashtable)actionContexts.get( context );
          if ( contextActions == null )
            actionContexts.put( context, contextActions = new Hashtable());
         
          contextActions.put( regElement.getAttribute( "id" ), actionFactory.getAction( regElement ));
        }
        else {
          context = regElement.getAttribute( "name" );
          Hashtable contextActions = (Hashtable)actionContexts.get( context );
          if ( contextActions == null )
            actionContexts.put( context, contextActions = new Hashtable());

          Vector contextChildren = regElement.getChildren();
          int numChildren = contextChildren.size();
          for ( int j = 0; j < numChildren; j++ ) {
            XmlElement actionElement = (XmlElement)contextChildren.elementAt( j );
            contextActions.put( actionElement.getAttribute( "id" ), actionFactory.getAction( actionElement ));
          }
        }
      }
    }
    catch ( Exception ex ) {
View Full Code Here

TOP

Related Classes of net.xoetrope.xml.XmlElement

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.