Package net.xoetrope.xml

Examples of net.xoetrope.xml.XmlElement


   */
  public void loadTable( XmlElement source, XModel model )
  {
    try {
      // Setup the pojo context
      XmlElement contextElement = source.getFirstChildNamed( "context" );
      String contextClassName = contextElement.getAttribute( "class" );
      String configFileName = contextElement.getAttribute( "config" );     
     
      XProjectClassLoader classLoader = (XProjectClassLoader)currentProject.getProjectClassLoader();
      pojoContext = instantiatePojoContext( contextClassName, classLoader );
      pojoContext.setProject( currentProject );
      currentProject.setObject( "PojoContext", pojoContext ); //???
      if ( configFileName != null )
        pojoContext.configure( currentProject.findResource( configFileName ));       
   
      // Load the customizations of the POJO classes     
      XmlElement overridesElement = source.getFirstChildNamed( "overrides" );
      if ( overridesElement != null ) {
        Vector overrideSpecs = overridesElement.getChildren();
        int numOverrides = overrideSpecs.size();
        for ( int i = 0; i < numOverrides; i++ ) {
          XmlElement overrideElement = (XmlElement)overrideSpecs.elementAt( i );
          String pojoClassName = overrideElement.getAttribute( "class" );               
          overrides.put( pojoClassName, overrideElement );
        }
      }
     
      // Setup the POJO root
      Object pojoRoot = null;
      XmlElement rootElement = source.getFirstChildNamed( "root" );     
      String pojoRootName = "pojo";
      if ( rootElement != null ) {
        String rootClassName = rootElement.getAttribute( "class" );
        pojoRootName = rootElement.getAttribute( "id" );
        configFileName = rootElement.getAttribute( "config" );
        int numParams = rootElement.getChildren().size();       
        if ( numParams == 0 ) {
          if ( classLoader != null )
            pojoRoot = Class.forName( rootClassName.trim(), true, classLoader ).newInstance();
          else
            pojoRoot = Class.forName( rootClassName.trim() ).newInstance();
        }
        else {
          Class[] params = new Class[ numParams ];
          Object[] values = new Object[ numParams ];
          for ( int i = 0; i < numParams; i++ ) {
            XmlElement paramElement = (XmlElement)rootElement.getChildren().elementAt( i );
            String paramType = paramElement.getAttribute( "class" );
            params[ i ] = ReflectionHelper.getParamClass( paramType );
            values[ i ] = ReflectionHelper.getObject( paramType, paramElement.getAttribute( "value" ));
          }
          Class klass = null;
          if ( classLoader != null )
            klass = Class.forName( rootClassName.trim(), true, classLoader );
          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
   */
  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 = 0;
      String methodName = child.getName();
      method = ((Integer)methodTable.get( methodName.toLowerCase())).intValue();

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

      pushStyle();
      render( g, child );
      popStyle();
    }
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 );

      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();
        int mode = ( tag.equals( "InspectorTransferHandlers" ) ? INSPECTOR_MATCH :
                     tag.equals( "ClassTransferHandlers" ) ? CLASS_MATCH :
                     tag.equals( "InterfaceTransferHandlers" ) ? INTERFACE_MATCH :
                     INSTANCE_MATCH
                   );
View Full Code Here

    if ( r == null ) {
      loadSingleTarget( pageDisplay );
      return true;
    }

    XmlElement model = XmlSource.read( r );
    Vector componentNodes = model.getChildren();
    int numChildren = componentNodes.size();
    if ( numChildren == 0 ) {
      if ( !"NONE".equals( currentProject.getStartupParam( "DefaultTarget" )))
        loadSingleTarget( pageDisplay );
     
      return true;
    }
   
    Hashtable framesetParams = new Hashtable();
    Enumeration framesetAttribNames = model.enumerateAttributeNames();
    while ( framesetAttribNames.hasMoreElements()) {
      String attribName = (String)framesetAttribNames.nextElement();
      framesetParams.put( attribName, (String)model.getAttribute( attribName ));
    }
    pageDisplay.setupFrameset( framesetParams );
   
    for ( int i = 0; i < numChildren; i++ ) {
      XmlElement childNode = ( XmlElement )componentNodes.elementAt( i );
      String typeStr = childNode.getName();
      String targetName = childNode.getAttribute( "name" );
      String pageName = childNode.getAttribute( "content" );
      Hashtable params = new Hashtable();
      Enumeration attribNames = childNode.enumerateAttributeNames();
      while ( attribNames.hasMoreElements()) {
        String attribName = (String)attribNames.nextElement();
        params.put( attribName, (String)childNode.getAttribute( attribName ));
      }
     
      if ( typeStr.equals( "Frame" )) {
        try {
          Object constraint = layoutHelper.getConstraint( childNode.getAttribute( "constraint" ));
          int preferredWidth = new Integer( childNode.getAttribute( "width" ) ).intValue();
          int preferredHeight = new Integer( childNode.getAttribute( "height" ) ).intValue();
          XContentHolder target;
          if ( addFrames )
            target = pageDisplay.addTarget( targetName, constraint,
                                            preferredWidth,
                                            preferredHeight,
                                            params );
          else {/** @todo set the target parameters for this new frame */
            target = (XContentHolder)pageDisplay.findTarget( targetName );
            target.setup( targetName, preferredWidth, preferredHeight, params );
          }
         
          if ( pageName != null ) {
            target.setContent( pageName );
            PageSupport targetPage = currentProject.getPageManager().loadPage( pageName );
            pageDisplay.displayPage( targetPage, targetName );
          }
        }
        catch ( NumberFormatException ex1 ) {
          ex1.printStackTrace();
        }
      }
      else if ( typeStr.equals( "Toolbar" )) {
        String constraint = childNode.getAttribute( "constraint" );
        PageSupport toolbar = currentProject.getPageManager().loadPage( pageName );
        pageDisplay.displayDecoration( toolbar, constraint );
      }
    }
    pageDisplay.doLayout();
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 );

      Vector children = regRoot.getChildren();
      int numChildren = children.size();
      for ( int i = 0; i < numChildren; i++ ) {
        XmlElement ele = (XmlElement)children.elementAt( i );
        String name = ele.getAttribute( "name" );
        XEventRegistration er = new XEventRegistration();
        er.interfaceName = ele.getAttribute( "adapter" );
        if (( er.interfaceName == null ) || ( er.interfaceName.length() == 0 )) {
          er.interfaceName = ele.getAttribute( "interface" );
          er.mask = Long.parseLong( ele.getAttribute( "mask" ));
        }
        registrations.put( name, er );
      }
    }
    catch ( Exception ex ) {
View Full Code Here

   * @param include the page to be loaded is being included in another page
   * @return the page
   */
  public PageSupport readPage( Reader reader, String pageName, String ext, boolean include )
  {
    XmlElement model = XmlSource.read( reader );
    if ( BuildProperties.DEBUG && ( model == null ))
      DebugLogger.logError( "BUILDER", "The file - " + pageName + " - could not be parsed!" );
    setupPage( model, pageName, ext, include );
    eventHandler = page.getEventHandler();
   
    XmlElement componentsNode = null;
    XmlElement eventsNode = null;
    XmlElement dataNode = null;
    XmlElement menuNode = null;
    XmlElement validationsNode = null;
    XmlElement scriptsNode = null;

    Vector componentNodes = model.getChildren();
    int numChildren = componentNodes.size();
    for ( int i = 0; i < numChildren; i++ ) {
      XmlElement childNode = ( XmlElement )componentNodes.elementAt( i );
      String typeStr = childNode.getName().toLowerCase();
      if ( typeStr.equals( "components" ))
        componentsNode = childNode;
      else if ( typeStr.equals( "events" ))
        eventsNode = childNode;
      else if ( typeStr.equals( "data" ))
        dataNode = childNode;
      else if ( typeStr.equals( "validations" ))
        validationsNode = childNode;
      else if ( typeStr.equals( "menubar" ))
        menuNode = childNode;
      else if ( typeStr.equals( "attributes" ))
        loadAttributeSet( childNode );
      else if ( typeStr.equals( "include" )) {
        loadPage( packageName, childNode.getAttribute( "file" ), true );
        componentFactory.setParentComponent( page );
      }
      else if ( typeStr.equals( "scripts" ))
        scriptsNode = childNode;
      else
View Full Code Here

        ;//setResourceBundle( page, attribValue );
      else if ( attribNameLwr.equals( "layout" )) {
        if ( attribValue != null )
          layoutMgr = attribValue;

        XmlElement layoutElement = model.getFirstChildNamed( "Layout" );
        if ( layoutElement != null ) {
          layoutAttributes = new Hashtable();
          Enumeration layoutAttribNamesEnum = layoutElement.enumerateAttributeNames();
          while ( layoutAttribNamesEnum.hasMoreElements()) {
            String layoutAttribName = (String)layoutAttribNamesEnum.nextElement();
            String layoutAttribValue = (String)layoutElement.getAttribute( layoutAttribName );
            layoutAttributes.put( layoutAttribName, layoutAttribValue );
          }
        }
        else
          layoutAttributes = currentAttributes;
View Full Code Here

//    componentFactory.setParentComponent( (Container)page );

    Vector componentNodes = model.getChildren();
    int numChildren = componentNodes.size();
    for ( int i = 0; i < numChildren; i++ ) {
      XmlElement childNode = ( XmlElement )componentNodes.elementAt( i );
      String childName = childNode.getName();
      if ( childName == null )
        continue;
      else if ( !"Repeat".equalsIgnoreCase( childName ))
        addComponent( childNode );
      else {
        String repeatReference = childNode.getAttribute( "while" );
        pushRepeatReference( repeatReference );
        // Repeat the child addition.
        boolean whileClauseResult = ((Boolean)rootPage.evaluateAttribute( repeatReference )).booleanValue();
        if ( whileClauseResult ) {
          i--;
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.