Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.AttributeListImpl


        }
        m_contextPushed = false;

        final String name = getTagName( loc, raw, uri );

        final AttributeListImpl attributeList = new AttributeListImpl();
        for( int i = 0; i < a.getLength(); i++ )
        {
            String attributeName = a.getQName( i );
            if( ( attributeName == null ) || ( attributeName.length() == 0 ) )
            {
                final String attributeNamespaceURI = a.getURI( i );
                final String attributeLocalName = a.getLocalName( i );
                if( attributeNamespaceURI.length() == 0 )
                {
                    attributeName = attributeLocalName;
                }
                else
                {
                    final String prefix = m_support.getPrefix( attributeNamespaceURI );
                    if( prefix == null )
                    {
                        throw new SAXException( "No attribute prefix for namespace URI: " + attributeNamespaceURI );
                    }
                    attributeName = prefix + ':' + attributeLocalName;
                }
            }
            attributeList.addAttribute( attributeName, a.getType( i ), a.getValue( i ) );
        }

        final Enumeration e = m_support.getDeclaredPrefixes();
        while( e.hasMoreElements() )
        {
            final String prefix = (String)e.nextElement();
            if( prefix.length() == 0 )
            {
                attributeList.addAttribute( XMLNS, CDATA, uri );
            }
            else
            {
                attributeList.addAttribute( XMLNS_PREFIX + prefix, CDATA, uri );
            }
        }

        m_documentHandler.startElement( name, attributeList );
    }
View Full Code Here


      writeProperty(pp, p);

    pp.endElement("schema");

    String dbclass = config.getDatabase(false).getClass().getName();
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("class", "CDATA", dbclass);
    pp.startElement("database", atts);
    pp.endElement("database");

    if (config.isDeduplicationMode())
      for (DataSource src : config.getDataSources())
View Full Code Here

  private static void writeParam(XMLPrettyPrinter pp, String name, String value) {
    if (value == null)
      return;

    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("name", "CDATA", name);
    atts.addAttribute("value", "CDATA", value);
    pp.startElement("param", atts);
    pp.endElement("param");
  }
View Full Code Here

    pp.text(value);
    pp.endElement(name);
  }

  private static void writeProperty(XMLPrettyPrinter pp, Property prop) {
    AttributeListImpl atts = new AttributeListImpl();
    if (prop.isIdProperty())
      atts.addAttribute("type", "CDATA", "id");
    else if (prop.isIgnoreProperty())
      atts.addAttribute("type", "CDATA", "ignore");

    if (!prop.isIdProperty() &&
        prop.getLookupBehaviour() != Property.Lookup.DEFAULT) {
      String value = prop.getLookupBehaviour().toString().toLowerCase();
      atts.addAttribute("lookup", "CDATA", value);
    }

    pp.startElement("property", atts);
    writeElement(pp, "name", prop.getName());
    if (prop.getComparator() != null)
View Full Code Here

    } else if (src instanceof MongoDBDataSource) {
      name = "data-source";
      MongoDBDataSource mongodb = (MongoDBDataSource) src;
      String klass = mongodb.getClass().getName();
      AttributeListImpl attribs = new AttributeListImpl();
      attribs.addAttribute("class", "CDATA", klass);
      pp.startElement(name, attribs);

      writeParam(pp, "server-address", mongodb.getServerAddress());
      writeParam(pp, "port-number", mongodb.getPortNumber());
      writeParam(pp, "user-name", mongodb.getUserName());
      writeParam(pp, "password", mongodb.getPassword());
      writeParam(pp, "db-auth", mongodb.getDbAuth());
      writeParam(pp, "database", mongodb.getDatabase());
      writeParam(pp, "cursor-notimeout", mongodb.getCursorNotimeout());
      writeParam(pp, "collection", mongodb.getCollection());
      writeParam(pp, "query", mongodb.getQuery());
      writeParam(pp, "projection", mongodb.getProjection());
    } else if (src instanceof CSVDataSource) {
      name = "csv";
      CSVDataSource csv = (CSVDataSource) src;
      pp.startElement(name, null);

      writeParam(pp, "input-file", csv.getInputFile());
      writeParam(pp, "encoding", csv.getEncoding());
      writeParam(pp, "skip-lines", csv.getSkipLines());
      writeParam(pp, "header-line", csv.getHeaderLine());
      if (csv.getSeparator() != 0)
        writeParam(pp, "separator", csv.getSeparator());
    } else if (src instanceof SparqlDataSource) {
      name = "sparql";
      SparqlDataSource sparql = (SparqlDataSource) src;
      pp.startElement(name, null);

      writeParam(pp, "endpoint", sparql.getEndpoint());
      writeParam(pp, "query", sparql.getQuery());
      writeParam(pp, "page-size", sparql.getPageSize());
      writeParam(pp, "triple-mode", sparql.getTripleMode());
    }

    if (src instanceof ColumnarDataSource) {
      // FIXME: this breaks the order...
      for (Column col : ((ColumnarDataSource) src).getColumns()) {
        AttributeListImpl atts = new AttributeListImpl();
        atts.addAttribute("name", "CDATA", col.getName());
        atts.addAttribute("property", "CDATA", col.getProperty());
        if (col.getPrefix() != null)
          atts.addAttribute("prefix", "CDATA", col.getPrefix());
        // FIXME: cleaner really requires object support ... :-(
        if (col.getCleaner() != null)
          atts.addAttribute("cleaner", "CDATA", col.getCleaner().getClass().getName());
        if (col.isSplit())
          atts.addAttribute("split-on", "CDATA", col.getSplitOn());

        pp.startElement("column", atts);
        pp.endElement("column");
      }
    }
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

    /**
     * Set's the attributes for the wrapped element.
     */
    public void setAttributes(AttributeList attributes) {
        this.attributes = new AttributeListImpl(attributes);
    }
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


    public void produce( LDAPEntry entry )
  throws SAXException
    {
  AttributeListImpl attrList;
  LDAPAttributeSet  attrSet;
  LDAPAttribute     attr;
  Enumeration       enumeration;
  Enumeration       values;
  byte[]            value;

  leaveSchema();
  enterDirectory();

  // dsml:entry dn
  attrList = new AttributeListImpl();
  attrList.addAttribute( XML.Entries.Attributes.DN, "CDATA", entry.getDN() );
  // dsml:entry
  _docHandler.startElement( prefix( XML.Entries.Elements.Entry ), attrList );
 
  attrSet = entry.getAttributeSet();
  if ( attrSet != null ) {
     
      attr = attrSet.getAttribute( "objectclass" );
      if ( attr != null ) {
    // dsml:objectclass
    attrList = new AttributeListImpl();
    _docHandler.startElement( prefix( XML.Entries.Elements.ObjectClass ), attrList );
    values = attr.getStringValues();
    while ( values.hasMoreElements() ) {
        char[] chars;
       
        // dsml:oc-value
        chars = ( (String) values.nextElement() ).toCharArray();
        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 = attrSet.getAttributes();
      while ( enumeration.hasMoreElements() ) {
    // dsml:attr
    attr = (LDAPAttribute) enumeration.nextElement();
    if ( attr.getName().equals( "objectclass" ) )
        continue;
    attrList = new AttributeListImpl();
    attrList.addAttribute( XML.Entries.Attributes.Name, "CDATA", attr.getName() );
    _docHandler.startElement( prefix( XML.Entries.Elements.Attribute ), attrList );
   
    values = attr.getByteValues();
    while ( values.hasMoreElements() ) {
        char[] chars;
        int    i;

        // dsml:value
        value = (byte[]) values.nextElement();
        attrList = new AttributeListImpl();
        if ( value == null ) {
      chars = new char[ 0 ];
        } else {
      // XXX We have no way of knowing if the attribute is
      //     string or binary, so we do this stupid check
      //     to determine and print it as ASCII text or
      //     base 64 encoding.
      //     (note: OpenLDAP does not provide the attributes
      //     schema as one would hope)
      for ( i = 0 ; i < value.length ; ++i ) {
          if ( value[ i ] < 0x20 || value[ i ] == 0x7f )
        break;
      }
      if ( i == value.length ) {
          chars = new char[ value.length ];
          for ( i = 0 ; i < value.length ; ++i )
        chars[ i ] = (char) value[ i ];
      } else {
          MimeBase64Encoder encoder;
         
          encoder = new MimeBase64Encoder();
          encoder.translate( value );
          chars = encoder.getCharArray();
          attrList.addAttribute( XML.Entries.Attributes.Encoding, "NMTOKEN",
               XML.Entries.Attributes.Encodings.Base64 );
      }
        }

        _docHandler.startElement( prefix( XML.Entries.Elements.Value ), attrList );
View Full Code Here


    public void produce( LDAPObjectClassSchema schema )
  throws SAXException
    {
  AttributeListImpl attrList;
  String            superiors[];
  String            superior;
  int               i;
  Enumeration       enumeration;

  leaveDirectory();
  enterSchema();
 
  attrList = new AttributeListImpl();
  // dsml:class id
  attrList.addAttribute( XML.Schema.Attributes.Id, "ID", schema.getName() );
  // dsml:class superior
  superiors = schema.getSuperiors();
  superior = null;
  for ( i = 0 ; i < superiors.length ; ++i ) {
      if ( i == 0 )
    superior = superiors[ i ];
      else
    superior = superior + "," + superiors[ i ];
  }
  if ( i > 0 )
      attrList.addAttribute( XML.Schema.Attributes.Superior, "CDATA", superior );
  // dsml:class obsolete
  attrList.addAttribute( XML.Schema.Attributes.Obsolete, null,
             schema.isObsolete() ? "true" : "false" );
  // dsml:class type
  switch ( schema.getType() ) {
  case LDAPObjectClassSchema.STRUCTURAL:
      attrList.addAttribute( XML.Schema.Attributes.Type, null,
           XML.Schema.Attributes.Types.Structural );
      break;
  case LDAPObjectClassSchema.ABSTRACT:
      attrList.addAttribute( XML.Schema.Attributes.Type, null,
           XML.Schema.Attributes.Types.Abstract );
      break;
  case LDAPObjectClassSchema.AUXILIARY:
      attrList.addAttribute( XML.Schema.Attributes.Type, null,
           XML.Schema.Attributes.Types.Auxiliary );
      break;
  }

  // dsml:class
  _docHandler.startElement( prefix( XML.Schema.Elements.Class ), attrList );

  // dsml:class name
  if ( schema.getName() != null ) {
      attrList = new AttributeListImpl();
      _docHandler.startElement( prefix( XML.Schema.Elements.Name ), attrList );
      _docHandler.characters( schema.getName().toCharArray(), 0,
            schema.getName().length() );
      _docHandler.endElement( prefix( XML.Schema.Elements.Name ) );
  }
  // dsml:class description
  if ( schema.getDescription() != null ) {
      attrList = new AttributeListImpl();
      _docHandler.startElement( prefix( XML.Schema.Elements.Description ), attrList );
      _docHandler.characters( schema.getDescription().toCharArray(), 0,
            schema.getDescription().length() );
      _docHandler.endElement( prefix( XML.Schema.Elements.Description ) );
  }
  // dsml:class object-identifier
  if ( schema.getID() != null ) {
      attrList = new AttributeListImpl();
      _docHandler.startElement( prefix( XML.Schema.Elements.OID ), attrList );
      _docHandler.characters( schema.getID().toCharArray(), 0,
            schema.getID().length() );
      _docHandler.endElement( prefix( XML.Schema.Elements.OID ) );
  }

  // dsml:class attribute required=false
  enumeration = schema.getOptionalAttributes();
  while ( enumeration.hasMoreElements() ) {
      attrList = new AttributeListImpl();
      attrList.addAttribute( XML.Schema.Attributes.Ref, "CDATA",
           "#" + (String) enumeration.nextElement() );
      attrList.addAttribute( XML.Schema.Attributes.Required, null, "false" );
      _docHandler.startElement( prefix( XML.Schema.Elements.Attribute) , attrList );
      _docHandler.endElement( prefix( XML.Schema.Elements.Attribute ) );
  }
  // dsml:class attribute required=true
  enumeration = schema.getRequiredAttributes();
  while ( enumeration.hasMoreElements() ) {
      attrList = new AttributeListImpl();
      attrList.addAttribute( XML.Schema.Attributes.Ref, "CDATA",
           "#" + (String) enumeration.nextElement() );
      attrList.addAttribute( XML.Schema.Attributes.Required, null, "true" );
      _docHandler.startElement( prefix( XML.Schema.Elements.Attribute) , attrList );
      _docHandler.endElement( prefix( XML.Schema.Elements.Attribute ) );
  }

  _docHandler.endElement( prefix( XML.Schema.Elements.Class ) );
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.