Beispiel #1
0
        public FieldDef( ObjectDef parent,
                         String name,
                         FieldType fieldType,
                         int sequence,
                         int nodeTypeFlag )
            : base(name)
        {
            fParent = parent;
            fSequence = sequence;
            fFieldType = fieldType;
            fFlags = nodeTypeFlag;

            if ( fFieldType.IsComplex ) {
                if ( fFlags == FLAG_ATTRIBUTE ) {
                    throw new ParseException
                        (
                        "Cannot create an attribute as a ComplexType: " +
                        parent.Name + "." + name + " {" + fieldType.ClassType + "}" );
                }
                fFlags |= FLAG_COMPLEX;
                if ( fieldType.ClassType.Equals( name ) ) {
                    fSuperclass = fieldType.ClassType;
                }
            }
            fDtdSymbol = fParent.DTDSymbol + "_" + fName.ToUpper();
            fElementDefConst = fParent.PackageQualifiedDTDSymbol + "_" + (fName.ToUpper());
        }
Beispiel #2
0
 public void SetEnumType( string enumType )
 {
     fValueType = FieldType.ToEnumType( FieldType.GetFieldType( "String" ), enumType );
 }
Beispiel #3
0
 /// <summary>
 /// If this this object accepts an element value the datatype of that 
 /// value is set in the metadata using a "datatype" element/// </summary>
 /// <param name="dataType"></param>
 public void SetDataType( String dataType )
 {
     fValueType = FieldType.GetFieldType( dataType );
 }
Beispiel #4
0
 /**
  *  Does this element have a text value?
  *  @return true if this element has no elements or attributes, or it has
  *      no elements but at least one attribute and the FLAG_EMPTYOBJECT flag
  *
  *      is not set
  */
 public FieldType GetValueType()
 {
     if ( fValueType == null ) {
         if ( (fFlags & FLAG_EMPTYOBJECT) == 0 ) {
             if ( fFields == null || fFields.Count == 0 || GetElements().Length == 0 ) {
                 fValueType = FieldType.GetFieldType( "String" );
             }
         }
     }
     return fValueType;
 }
Beispiel #5
0
 internal void SetEnum( string enumName )
 {
     if ( enumName != null ) {
         fFieldType = FieldType.ToEnumType( fFieldType, enumName );
     }
 }
Beispiel #6
0
        public static FieldType ToEnumType( FieldType existingField,
                                            String enumName )
        {
            if ( existingField.DataType == AdkDataType.Enum ) {
                if ( existingField.ClassType.Equals( enumName ) ) {
                    return existingField;
                }
                else {
                    throw new ParseException
                        ( "Field was already defined as an Enum with a different name: " +
                          existingField.DataType + " { ENUM:" + enumName + "}" );
                }
            }
            else {
                if ( existingField.DataType != AdkDataType.String ) {
                    throw new ParseException
                        ( "Cannot define an enum for a type other than a String. Field:" +
                          existingField.DataType + " { ENUM:" + enumName + "}" );
                }
            }
            // TODO: We could support "YesNo" values as boolean fields, but we need to be able
            // to format them differently than booleans....
            //		if( enumName.equals( "YesNo" )){
            //			return FIELD_BOOLEAN;
            //		}

            FieldType returnValue = new FieldType( AdkDataType.Enum );
            returnValue.fClassType = enumName;
            return returnValue;
        }
Beispiel #7
0
 public static FieldType GetFieldType( String classType )
 {
     if ( classType == null ||
          classType.Length == 0 ||
          String.Compare( classType, "String", true ) == 0 ||
          String.Compare( classType, "Token", true ) == 0 ||
          String.Compare( classType, "IdRefType", true ) == 0 ||
          String.Compare( classType, "NormalizedString", true ) == 0 ||
          String.Compare( classType, "NCName", true ) == 0 ||
          String.Compare( classType, "AnyUri", true ) == 0 ||
          String.Compare( classType, "Language", true ) == 0 ||
          String.Compare( classType, "AnyAtomicType", true ) == 0 ) {
         return FIELD_STRING;
     }
     else if ( String.Compare( classType, "DateTime", true ) == 0 ) {
         return FIELD_DATETIME;
     }
     else if ( String.Compare( classType, "Int", true ) == 0 ||
               String.Compare( classType, "PositiveInteger", true ) == 0 ||
               String.Compare( classType, "NonNegativeInteger", true ) == 0 ||
               String.Compare( classType, "GYear", true ) == 0 ||
               String.Compare( classType, "GMonth", true ) == 0 ||
               String.Compare( classType, "GDay", true ) == 0 ) {
         return FIELD_INT;
     }
     else if ( String.Compare( classType, "UnsignedInt", true ) == 0 ||
               String.Compare(classType, "UINT", true) == 0)
     {
         return FIELD_UINT;
     }
     else if ( String.Compare( classType, "Decimal", true ) == 0 ) {
         return FIELD_DECIMAL;
     }
     else if ( String.Compare( classType, "SIFDate", true ) == 0 ||
               String.Compare( classType, "Date", true ) == 0 ) {
         return FIELD_DATE;
     }
     else if ( String.Compare( classType, "Boolean", true ) == 0 ||
               String.Compare( classType, "YesNo", true ) == 0 ) {
         return FIELD_BOOLEAN;
     }
     else if ( String.Compare( classType, "SIFSimpleTime", true ) == 0 ||
               String.Compare( classType, "Time", true ) == 0 ||
               String.Compare( classType, "SIFTime", true ) == 0 ) {
         return FIELD_TIME;
     }
     else if ( String.Compare( classType, "SIFVersion", true ) == 0 ) {
         return FIELD_SIFVERSION;
     }
     else if( String.Compare( classType, "Duration", true ) == 0 )
     {
         return FIELD_DURATION;
     }
     else {
         FieldType returnValue = new FieldType( AdkDataType.Complex );
         returnValue.fClassType = classType;
         return returnValue;
     }
 }