Package org.dom4j

Examples of org.dom4j.Attribute


    oneToMany.setIgnoreNotFound( "ignore".equals( notFound ) );

  }

  public static void bindColumn(Element node, Column column, boolean isNullable) {
    Attribute lengthNode = node.attribute( "length" );
    if ( lengthNode != null ) column.setLength( Integer.parseInt( lengthNode.getValue() ) );
    Attribute scalNode = node.attribute( "scale" );
    if ( scalNode != null ) column.setScale( Integer.parseInt( scalNode.getValue() ) );
    Attribute precNode = node.attribute( "precision" );
    if ( precNode != null ) column.setPrecision( Integer.parseInt( precNode.getValue() ) );

    Attribute nullNode = node.attribute( "not-null" );
    column.setNullable( nullNode == null ? isNullable : nullNode.getValue().equals( "false" ) );

    Attribute unqNode = node.attribute( "unique" );
    if ( unqNode != null ) column.setUnique( unqNode.getValue().equals( "true" ) );

    column.setCheckConstraint( node.attributeValue( "check" ) );
    column.setDefaultValue( node.attributeValue( "default" ) );

    Attribute typeNode = node.attribute( "sql-type" );
    if ( typeNode != null ) column.setSqlType( typeNode.getValue() );

    Element comment = node.element("comment");
    if (comment!=null) column.setComment( comment.getTextTrim() );

  }
View Full Code Here


  public static void bindArray(Element node, Array array, String prefix, String path,
      Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

    bindCollection( node, array, prefix, path, mappings, inheritedMetas );

    Attribute att = node.attribute( "element-class" );
    if ( att != null ) array.setElementClassName( getClassName( att, mappings ) );

  }
View Full Code Here

    component.setRoleName( path );

    inheritedMetas = getMetas( node, inheritedMetas );
    component.setMetaAttributes( inheritedMetas );

    Attribute classNode = isIdentifierMapper ? null : node.attribute( "class" );
    if ( classNode != null ) {
      component.setComponentClassName( getClassName( classNode, mappings ) );
    }
    else if ( "dynamic-component".equals( node.getName() ) ) {
      component.setDynamic( true );
View Full Code Here

    }
  }

  public static String getTypeFromXML(Element node) throws MappingException {
    // TODO: handle TypeDefs
    Attribute typeNode = node.attribute( "type" );
    if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any
    if ( typeNode == null ) return null; // we will have to use reflection
    return typeNode.getValue();
  }
View Full Code Here

    if ( typeNode == null ) return null; // we will have to use reflection
    return typeNode.getValue();
  }

  private static void initOuterJoinFetchSetting(Element node, Fetchable model) {
    Attribute fetchNode = node.attribute( "fetch" );
    final FetchMode fetchStyle;
    boolean lazy = true;
    if ( fetchNode == null ) {
      Attribute jfNode = node.attribute( "outer-join" );
      if ( jfNode == null ) {
        if ( "many-to-many".equals( node.getName() ) ) {
          //NOTE SPECIAL CASE:
          // default to join and non-lazy for the "second join"
          // of the many-to-many
          lazy = false;
          fetchStyle = FetchMode.JOIN;
        }
        else if ( "one-to-one".equals( node.getName() ) ) {
          //NOTE SPECIAL CASE:
          // one-to-one constrained=false cannot be proxied,
          // so default to join and non-lazy
          lazy = ( (OneToOne) model ).isConstrained();
          fetchStyle = lazy ? FetchMode.DEFAULT : FetchMode.JOIN;
        }
        else {
          fetchStyle = FetchMode.DEFAULT;
        }
      }
      else {
        // use old (HB 2.1) defaults if outer-join is specified
        String eoj = jfNode.getValue();
        if ( "auto".equals( eoj ) ) {
          fetchStyle = FetchMode.DEFAULT;
        }
        else {
          boolean join = "true".equals( eoj );
View Full Code Here

    }

    model.getTable().setIdentifierValue( model );

    // ID UNSAVED-VALUE
    Attribute nullValueNode = node.attribute( "unsaved-value" );
    if ( nullValueNode != null ) {
      model.setNullValue( nullValueNode.getValue() );
    }
    else {
      if ( "assigned".equals( model.getIdentifierGeneratorStrategy() ) ) {
        model.setNullValue( "undefined" );
      }
View Full Code Here

  }

  private static final void makeVersion(Element node, SimpleValue model) {

    // VERSION UNSAVED-VALUE
    Attribute nullValueNode = node.attribute( "unsaved-value" );
    if ( nullValueNode != null ) {
      model.setNullValue( nullValueNode.getValue() );
    }
    else {
      model.setNullValue( "undefined" );
    }
View Full Code Here

          " -> " + collection.getCollectionTable().getName()
        );
    }

    // CHECK
    Attribute chNode = node.attribute( "check" );
    if ( chNode != null ) {
      collection.getCollectionTable().addCheckConstraint( chNode.getValue() );
    }

    // contained elements:
    Iterator iter = node.elementIterator();
    while ( iter.hasNext() ) {
      Element subnode = (Element) iter.next();
      String name = subnode.getName();

      if ( "key".equals( name ) ) {
        KeyValue keyVal;
        String propRef = collection.getReferencedPropertyName();
        if ( propRef == null ) {
          keyVal = collection.getOwner().getIdentifier();
        }
        else {
          keyVal = (KeyValue) collection.getOwner().getRecursiveProperty( propRef ).getValue();
        }
        SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
        key.setCascadeDeleteEnabled( "cascade"
          .equals( subnode.attributeValue( "on-delete" ) ) );
        bindSimpleValue(
            subnode,
            key,
            collection.isOneToMany(),
            Collection.DEFAULT_KEY_COLUMN_NAME,
            mappings
          );
        collection.setKey( key );

        Attribute notNull = subnode.attribute( "not-null" );
        ( (DependantValue) key ).setNullable( notNull == null
          || notNull.getValue().equals( "false" ) );
        Attribute updateable = subnode.attribute( "update" );
        ( (DependantValue) key ).setUpdateable( updateable == null
          || updateable.getValue().equals( "true" ) );

      }
      else if ( "element".equals( name ) ) {
        SimpleValue elt = new SimpleValue( collection.getCollectionTable() );
        collection.setElement( elt );
View Full Code Here

  private static void bindManyToManySubelements(
          Collection collection,
          Element manyToManyNode,
          Mappings model) throws MappingException {
    // Bind the where
    Attribute where = manyToManyNode.attribute( "where" );
    String whereCondition = where == null ? null : where.getValue();
    collection.setManyToManyWhere( whereCondition );

    // Bind the order-by
    Attribute order = manyToManyNode.attribute( "order-by" );
    String orderFragment = order == null ? null : order.getValue();
    collection.setManyToManyOrdering( orderFragment );

    // Bind the filters
    Iterator filters = manyToManyNode.elementIterator( "filter" );
    if ( ( filters.hasNext() || whereCondition != null ) &&
View Full Code Here

    String query = queryElem.getText();
    log.debug( "Named query: " + queryName + " -> " + query );

    boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
    String region = queryElem.attributeValue( "cache-region" );
    Attribute tAtt = queryElem.attribute( "timeout" );
    Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
    Attribute fsAtt = queryElem.attribute( "fetch-size" );
    Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
    Attribute roAttr = queryElem.attribute( "read-only" );
    boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
    Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
    String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
    Attribute cmAtt = queryElem.attribute( "comment" );
    String comment = cmAtt == null ? null : cmAtt.getValue();

    NamedQueryDefinition namedQuery = new NamedQueryDefinition(
        query,
        cacheable,
        region,
View Full Code Here

TOP

Related Classes of org.dom4j.Attribute

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.