Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.AttributeListImpl


  throws SAXException
    {
  // If not inside directory element, start it
  if ( ! _insideDirectory ) {
      _insideDirectory = true;
      _docHandler.startElement( prefix( XML.Entries.Element ), new AttributeListImpl() );
  }
    }
View Full Code Here


  throws SAXException
    {
  // If not inside schema element, start it
  if ( ! _insideSchema ) {
      _insideSchema = true;
      _docHandler.startElement( prefix( XML.Schema.Element ), new AttributeListImpl() );
  }
    }
View Full Code Here


    public void produce( DocumentHandler docHandler )
  throws SAXException
    {
  AttributeListImpl attrList;
  int               policy;
  Enumeration       enumeration;
  String            name;

  attrList = new AttributeListImpl();
  docHandler.startElement( XML.Namespace.Root, attrList );
  attrList = new AttributeListImpl();
  docHandler.startElement( Names.Element.Policies, attrList );

  enumeration = listDNs();
  while ( enumeration.hasMoreElements() ) {
      name = (String) enumeration.nextElement();
      policy = getDirectPolicy( name );
      attrList = new AttributeListImpl();
      attrList.addAttribute( Names.Attribute.DN, "ID", name );
      if ( ( policy & Policy.DeleteEmpty ) != 0 )
    attrList.addAttribute( Names.Attribute.DeleteEmpty, null, "true" );
      if ( ( policy & Policy.ReplaceAttr ) != 0 )
    attrList.addAttribute( Names.Attribute.ReplaceAttr, null, "true" );
      if ( ( policy & Policy.RefreshOnly ) != 0 )
    attrList.addAttribute( Names.Attribute.RefreshOnly, null, "true" );
      if ( ( policy & Policy.UpdateOnly ) != 0 )
    attrList.addAttribute( Names.Attribute.UpdateOnly, null, "true" );
      if ( ( policy & Policy.NewAttrOnly ) != 0 )
    attrList.addAttribute( Names.Attribute.NewAttrOnly, null, "true" );
      docHandler.startElement( Names.Element.Policy, attrList );
      docHandler.endElement( Names.Element.Policy );
  }

  docHandler.endElement( Names.Element.Policies );
View Full Code Here


    public void produce( DocumentHandler docHandler )
  throws SAXException
    {
  AttributeListImpl attrList;
  Enumeration       enumeration;

  attrList = new AttributeListImpl();
  docHandler.startElement( XML.Namespace.Root, attrList );

  attrList = new AttributeListImpl();
  if ( _baseDN != null )
      attrList.addAttribute( Names.Attribute.BaseDN, "CDATA", _baseDN );
  if ( _filter != null )
      attrList.addAttribute( Names.Attribute.Filter, "CDATA", _filter );
  switch ( _scope ) {
  case Scope.OneLevel:
      attrList.addAttribute( Names.Attribute.Scope, null,
           Names.Attribute.ScopeOneLevel );
      break;
  case Scope.Base:
      attrList.addAttribute( Names.Attribute.Scope, null,
           Names.Attribute.ScopeBase );
      break;
  case Scope.SubTree:
      attrList.addAttribute( Names.Attribute.Scope, null,
           Names.Attribute.ScopeSubTree );
      break;
  }
  docHandler.startElement( Names.Element.Search, attrList );

  if ( _returnAttrs != null ) {
      enumeration = _returnAttrs.elements();
      while ( enumeration.hasMoreElements() ) {
    attrList = new AttributeListImpl();
    attrList.addAttribute( Names.Attribute.AttrName, "NMTOKEN",
               (String) enumeration.nextElement() );
    docHandler.startElement( Names.Element.ReturnAttr, attrList );
    docHandler.endElement( Names.Element.ReturnAttr );
      }
  }
View Full Code Here


    public void produce( String name, Attributes attrs )
        throws SAXException, NamingException
    {
        AttributeListImpl  attrList;
        Attribute          attr;
        NamingEnumeration  enumeration;
        NamingEnumeration  values;
        Object             value;

        leaveSchema();
        enterDirectory();

        // dsml:entry dn
        attrList = new AttributeListImpl();
        attrList.addAttribute( XML.Entries.Attributes.DN, "CDATA", name );
        // dsml:entry
        _docHandler.startElement( prefix( XML.Entries.Elements.Entry ), attrList );

        if ( attrs != null ) {
            attr = attrs.get( "objectclass" );
            if ( attr != null ) {
                // dsml:objectclass
                attrList = new AttributeListImpl();
                _docHandler.startElement( prefix( XML.Entries.Elements.ObjectClass ),
                                          attrList );
                values = attr.getAll();
                while ( values.hasMore() ) {
                    char[] chars;

                    // dsml:oc-value
                    value = values.next();
                    if ( value != null )
                        chars = value.toString().toCharArray();
                    else
                        chars = new char[ 0 ];
                    attrList = new AttributeListImpl();
                    _docHandler.startElement( prefix( XML.Entries.Elements.OCValue ), attrList );
                    _docHandler.characters( chars, 0, chars.length );
                    _docHandler.endElement( prefix( XML.Entries.Elements.OCValue ) );
                }
                _docHandler.endElement( prefix( XML.Entries.Elements.ObjectClass ) );
            }

            enumeration = attrs.getAll();
            while ( enumeration.hasMore() ) {
                // dsml:attr
                attr = (Attribute) enumeration.next();
                if ( attr.getID().equals( "objectclass" ) )
                    continue;
                attrList = new AttributeListImpl();
                attrList.addAttribute( XML.Entries.Attributes.Name, "CDATA", attr.getID() );
                _docHandler.startElement( prefix( XML.Entries.Elements.Attribute ), attrList );

                values = attr.getAll();
                while ( values.hasMore() ) {
                    char[] chars = null;
                    byte[] bytes = null;

                    attrList = new AttributeListImpl();

                    // dsml:value
                    value = values.next();
                    if ( value == null ) {
                        chars = new char[ 0 ];
                    } else if ( value instanceof String ) {
                        chars = ( (String) value ).toCharArray();
                    } else if (value instanceof byte[]) {
                        bytes = (byte[])value;
                    } else {
                        chars = value.toString().toCharArray();
                    }
                    if (chars != null) {
                        boolean encode = false;
                        boolean wchar = false;
                        int i = 0;
                        while (i < chars.length && !wchar) {
                            char c = chars[i++];
                            if (c >= '\u0100')
                                    encode = wchar = true;
                            else if (c >= '\u0080' || (c < ' ' && c != '\n' && c != '\t'))
                                    encode = true;
                        }
                        if (encode) {
                            if (wchar) {
                                bytes = new byte[chars.length << 1];
                                int j = 0;
                                // bigendian
                                for (i = 0; i < chars.length; i++) {
                                        bytes[j++] = (byte) (chars[i] >> 8);
                                        bytes[j++] = (byte) (0xff & chars[i]);
                                }
                            } else {
                                bytes = new byte[chars.length];
                                for (i = 0; i < chars.length; i++) {
                                        bytes[i] = (byte)chars[i];
                                }
                            }
                        }
                    }

                    if (bytes != null)
                    {
                        MimeBase64Encoder encoder = new MimeBase64Encoder();
                        encoder.translate( bytes );
                        chars = encoder.getCharArray();
                        attrList.addAttribute( XML.Entries.Attributes.Encoding, "NMTOKEN",
                                               XML.Entries.Attributes.Encodings.Base64 );
                    }
                    _docHandler.startElement( prefix( XML.Entries.Elements.Value ), attrList );
                    _docHandler.characters( chars, 0, chars.length );
                    _docHandler.endElement( prefix( XML.Entries.Elements.Value ) );
View Full Code Here

    throws SAXException {
        if (this.documentHandler==null)
            throw new SAXException("DocumentHandler not set");
        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
        // Create the AttributeList
        AttributeListImpl a2=new AttributeListImpl();
        // Set the xmlns:...="..." attributes
        if (this.undecl.size()>0) {
            for (int x=0; x<this.undecl.size(); x++) {
                NamespacesTable.Declaration dec=null;
                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
                String aname="xmlns";
                if (dec.getPrefix().length()>0) aname="xmlns:"+dec.getPrefix();
                a2.addAttribute(aname,"CDATA",dec.getUri());
            }
            this.undecl.clear();
        }
        // Set the real attributes
        for (int x=0; x<a.getLength(); x++) {
            NamespacesTable.Name aname=namespaces.resolve(a.getURI(x),
                                                          a.getQName(x),
                                                          null,
                                                          a.getLocalName(x));
            a2.addAttribute(aname.getQName(),a.getType(x),a.getValue(x));
        }
        // Call the document handler startElement() method.
        this.documentHandler.startElement(name.getQName(),a2);
    }
View Full Code Here

     * @deprecated since 1.6.x.
     * @param attributes List of attributes defined in the XML for this
     *                   element. May be <code>null</code>.
     */
    public synchronized void setAttributes(AttributeList attributes) {
        this.attributes = new AttributeListImpl(attributes);
        for (int i = 0; i < attributes.getLength(); i++) {
            setAttribute(attributes.getName(i), attributes.getValue(i));
        }
    }
View Full Code Here

     * @deprecated
     * @param attributes List of attributes defined in the XML for this
     *                   element. May be <code>null</code>.
     */
    public void setAttributes(AttributeList attributes) {
        this.attributes = new AttributeListImpl(attributes);
        for (int i = 0; i < attributes.getLength(); i++) {
            setAttribute(attributes.getName(i), attributes.getValue(i));
        }
    }
View Full Code Here

  throws FOPException {

  /* most of this code is modified from John Cowan's */

  Node currentNode;
  AttributeListImpl currentAtts;
 
  /* temporary array for making Strings into character arrays */
  char[] array = null;

  currentAtts = new AttributeListImpl();
 
  /* start at the document element */
  currentNode = document;

  try {
      while (currentNode != null) {
    switch (currentNode.getNodeType()) {
    case Node.DOCUMENT_NODE:
        this.treeBuilder.startDocument();
        break;
    case Node.CDATA_SECTION_NODE:
    case Node.TEXT_NODE:
        String data = currentNode.getNodeValue();
        int datalen = data.length();
        if (array == null || array.length < datalen) {
      /* if the array isn't big enough, make a new
         one */
      array = new char[datalen];
        }
        data.getChars(0, datalen, array, 0);
        this.treeBuilder.characters(array, 0, datalen);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        this.treeBuilder.processingInstruction(
              currentNode.getNodeName(),
      currentNode.getNodeValue());
        break;
    case Node.ELEMENT_NODE:
        NamedNodeMap map = currentNode.getAttributes();
        currentAtts.clear();
        for (int i = map.getLength() - 1; i >= 0; i--) {
      Attr att = (Attr)(map.item(i));
      currentAtts.addAttribute(att.getName(),
             "CDATA",
             att.getValue());
        }
        this.treeBuilder.startElement(
      currentNode.getNodeName(), currentAtts);
View Full Code Here

     *
     * @param attributes List of attributes defined in the XML for this
     *                   element. May be <code>null</code>.
     */
    public void setAttributes(AttributeList attributes) {
        this.attributes = new AttributeListImpl(attributes);
    }
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.AttributeListImpl

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.