Package org.xml.sax

Examples of org.xml.sax.AttributeList


    public static void setTagRules( XmlMapper xh ) {
  xh.addRule( "module"new XmlAction() {
    public void start(SaxContext ctx ) throws Exception {
        Object elem=ctx.currentObject();
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String classN=attributes.getValue("javaClass");
        if( name==null || classN==null ) return;
        ContextManager cm=(ContextManager)ctx.currentObject();
        Hashtable modules=(Hashtable)cm.getNote("modules");
        modules.put( name, classN );
        addTagRule( ctx.getMapper(), name, classN );
View Full Code Here


            xh.addRule("tomcat-users/user",
                       new XmlAction() {
                               public void start(SaxContext sctx) throws Exception {
                                   int top=sctx.getTagCount()-1;
                                   MemoryRealm mr=(MemoryRealm)sctx.getRoot();
                                   AttributeList attributes = sctx.getAttributeList( top );
                                   String user=attributes.getValue("name");
                                   String pass=attributes.getValue("password");
                                   String group=attributes.getValue("roles");

                                   mr.addUser( user, pass, group );
                               }
                           }
                       );
View Full Code Here

  if( locator!=null ) sb.append("Line ").append(locator.getLineNumber()).append(" ");
  sb.append("/");
  for( int i=0; i< sp ; i++ ) sb.append( tagStack[i] ).append( "/" );
  sb.append(" ");
  if( sp > 0 ) {
      AttributeList attributes=(AttributeList) attributeStack[sp-1];
      if( attributes!=null)
          for (int i = 0; i < attributes.getLength (); i++) {
        sb.append(attributes.getName(i)).append( "=" ).append(attributes.getValue(i));
        sb.append(" ");
          }
  }
  return sb.toString();
    }
View Full Code Here

    private void initDefaultRules() {
  // One-time actions, in line
  addRule( "xmlmapper:debug",
     new XmlAction() {
       public void start(SaxContext ctx) {
           AttributeList attributes =
         ctx.getCurrentAttributes();
           String levelS=attributes.getValue("level");
           XmlMapper mapper=(XmlMapper)ctx;
           if( levelS!=null)
         mapper.setDebug( new Integer(levelS).intValue());
       }
         }
     );
  // ant-like
  addRule( "xmlmapper:taskdef",
     new XmlAction() {
       public void start(SaxContext ctx) {
           XmlMapper mapper=(XmlMapper)ctx;
           AttributeList attributes =
         ctx.getCurrentAttributes();
           String match=attributes.getValue("match");
           if(match==null) return; //log
           String obj=attributes.getValue("object-create");
           String objA=attributes.getValue("object-create-attrib");
           if( obj!=null || objA!=null)
         mapper.addRule( match, new ObjectCreate( obj, objA));
           obj=attributes.getValue("set-properties");
           if( obj!=null)
         mapper.addRule( match, new SetProperties());
           obj=attributes.getValue("set-parent");
           if( obj!=null)
         mapper.addRule( match, new SetParent(obj));
           obj=attributes.getValue("add-child");
           objA=attributes.getValue("child-type");
           if( obj!=null)
         mapper.addRule( match, new AddChild(obj, objA));

           // Custom actions
           obj=attributes.getValue("action");
           if( obj!=null) {
         try {
             ClassLoader cl=getClassLoader();
             Class c=cl.loadClass( obj );
             Object o=c.newInstance();
View Full Code Here

  String tag=ctx.getCurrentElement();
  String classN=className;
  ClassLoader cl=ctx.getClassLoader();

  if( attrib!=null) {
      AttributeList attributes = ctx.getCurrentAttributes();
      if (attributes.getValue(attrib) != null)
    classN= attributes.getValue(attrib);
  }
  Class c=null;
  if( pref!=null && classN.indexOf( "." ) <0 ) {
      for( int i=0; i<pref.length; i++ ) {
    try {
View Full Code Here

    public SetProperties() {
    }

    public void start( SaxContext ctx ) {
  Object elem=ctx.currentObject();
  AttributeList attributes = ctx.getCurrentAttributes();
  XmlMapper xh=ctx.getMapper();
 
  for (int i = 0; i < attributes.getLength (); i++) {
      String type = attributes.getType (i);
      String name=attributes.getName(i);
      String value=attributes.getValue(i);

      String value1=xh.replaceProperties( value );
      if( !value1.equals(value) && ctx.getDebug() > -1 )
    ctx.log( "Replace " + value + " " + value1 );
   
View Full Code Here

      this.ploader=ploader;
  }
 
  public void start(SaxContext ctx ) throws Exception {
      Profile p=new Profile(ploader.getContextManager() );
      AttributeList attributes = ctx.getCurrentAttributes();
      p.setName( attributes.getValue("name"));
      p.initClassLoaders();
      ctx.pushObject( p );
  }
View Full Code Here

    c=profile.commonLoader.loadClass(className);
      }

      Object o=c.newInstance();

      AttributeList attributes = ctx.getCurrentAttributes();

      for (int i = 0; i < attributes.getLength (); i++) {
    String type = attributes.getType (i);
    String name=attributes.getName(i);
    String value=attributes.getValue(i);
   
    IntrospectionUtils.setProperty( o, name, value );
      }

      profile.addModule( (BaseInterceptor)o );
View Full Code Here

    public static void setTagRules( XmlMapper xh ) {
  xh.addRule( "module"new XmlAction() {
    public void start(SaxContext ctx ) throws Exception {
        Object elem=ctx.currentObject();
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String classN=attributes.getValue("javaClass");
        if( name==null || classN==null ) return;
        addTagRule( ctx.getMapper(), name, classN );
        if( ctx.getDebug() > 0 ) ctx.log("Adding " + name + " " + classN );
    }
      });
View Full Code Here

            boolean nsEnabled = false;
            try { nsEnabled = getNamespaces(); }
            catch (SAXException s) {}

            String elementName = fStringPool.toString(elementTypeIndex);
            AttributeList attrList = xmlAttrList.getAttributeList(attrListIndex);
            // Until DOM2 is REC, the DOM2 methods are in XXXImpl
            Element e;
            if (nsEnabled) {
                //System.out.println("createElementNS:"+
                //fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)));
                e = (ElementImpl)
                    ((DocumentImpl)fDocument).createElementNS(
                        fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)),
                        fStringPool.toString(elementTypeIndex)
                    );
            } else {
                e = fDocument.createElement(elementName);
            }
            int attrListLength = attrList.getLength();
            for (int i = 0; i < attrListLength; i++) {
                if (nsEnabled) {
                    // REVISTNS:
                    int attName = xmlAttrList.getAttrName(i);
                    /***
                    // createAttributeNS code below has a bug.
                    // Should be interchangeable with setAttributeNS
                    Attr attr =
                    ((DocumentImpl)fDocument).createAttributeNS(
                        fStringPool.toString(fStringPool.getURIForQName(attName)),
                        fStringPool.toString(attName)
                    );
                    attr.setNodeValue(attrList.getValue(i));
                    e.appendChild(attr);
                    /***/
                    // setAttributeNS can't set qualified name or prefix.
                    // Reported to W3C.
                    ((ElementImpl)e).setAttributeNS(
                        fStringPool.toString(fStringPool.getURIForQName(attName)),
                        fStringPool.toString(attName),
                        attrList.getValue(i));
                    /***/
                    //DEBUGGING...
                    //System.out.println("    Attr uri, name, value");
                    //System.out.println("    "+
                    //    fStringPool.toString(fStringPool.getURIForQName(attName))+", "+
                    //    fStringPool.toString(attName)+", "+
                    //    attrList.getValue(i)
                    //);
                } else {
                    String attrName = attrList.getName(i);
                    String attrValue = attrList.getValue(i);
                    e.setAttribute(attrName, attrValue);
                    // REVISIT: Does this also apply to namespace attributes? -Ac
                    if (fDocumentImpl != null && !xmlAttrList.isSpecified(i)) {
                        ((AttrImpl)e.getAttributeNode(attrName)).setSpecified(false);
                    }
View Full Code Here

TOP

Related Classes of org.xml.sax.AttributeList

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.