Exemplo n.º 1
0
 public DataBlockDefinitionType(final DataBlockDefinition db) {
   if (db != null) {
     this.id = db.getId();
     if (db.getEncoding() != null) {
       this.encoding = new AbstractEncodingPropertyType(db.getEncoding());
     }
     if (db.getComponents() != null) {
       final ObjectFactory factory = new ObjectFactory();
       this.components = new ArrayList<JAXBElement<? extends AbstractDataComponentType>>();
       for (AbstractDataComponent c : db.getComponents()) {
         if (c instanceof BooleanType) {
           this.components.add(factory.createBoolean(new BooleanType((BooleanType) c)));
         } else if (c instanceof ConditionalValueType) {
           this.components.add(
               factory.createConditionalValue(new ConditionalValueType((ConditionalValueType) c)));
         } else if (c instanceof DataArrayType) {
           this.components.add(factory.createDataArray(new DataArrayType((DataArrayType) c)));
         } else if (c instanceof DataRecordType) {
           this.components.add(factory.createDataRecord(new DataRecordType((DataRecordType) c)));
         } else if (c instanceof EnvelopeType) {
           this.components.add(factory.createEnvelope(new EnvelopeType((EnvelopeType) c)));
         } else if (c instanceof GeoLocationArea) {
           this.components.add(
               factory.createGeoLocationArea(new GeoLocationArea((GeoLocationArea) c)));
         } else if (c instanceof PositionType) {
           this.components.add(factory.createPosition(new PositionType((PositionType) c)));
         } else if (c instanceof QuantityType) {
           this.components.add(factory.createQuantity(new QuantityType((QuantityType) c)));
         } else if (c instanceof SimpleDataRecordType) {
           this.components.add(
               factory.createSimpleDataRecord(new SimpleDataRecordType((SimpleDataRecordType) c)));
         } else if (c instanceof SquareMatrixType) {
           this.components.add(
               factory.createSquareMatrix(new SquareMatrixType((SquareMatrixType) c)));
         } else if (c instanceof TimeType) {
           this.components.add(factory.createTime(new TimeType((TimeType) c)));
         } else if (c instanceof VectorType) {
           this.components.add(factory.createVector(new VectorType((VectorType) c)));
         } else if (c instanceof AbstractDataRecordType) {
           this.components.add(
               factory.createAbstractDataRecord(
                   new AbstractDataRecordType((AbstractDataRecordType) c)));
         } else if (c instanceof AbstractDataComponentType) {
           this.components.add(
               factory.createAbstractDataComponent(
                   new AbstractDataComponentType((AbstractDataComponentType) c)));
         } else {
           throw new IllegalArgumentException(
               "unexpected type for component:" + c.getClass().getName());
         }
       }
     }
   }
 }
Exemplo n.º 2
0
 /**
  * créé un nouveau resultat d'observation. Liste de valeur decrite dans swe:DatablockDefinition de
  * type simple, pour valeur scalaire ou textuelle.
  *
  * @param id l'identifiant du resultat.
  * @param components liste de composant data record.
  * @param encoding encodage des données.
  */
 public DataBlockDefinitionType(
     final String id,
     final Collection<? extends AbstractDataComponentType> components,
     final AbstractEncodingType encoding) {
   this.id = id;
   this.components = new ArrayList<JAXBElement<? extends AbstractDataComponentType>>();
   final ObjectFactory factory = new ObjectFactory();
   for (AbstractDataComponent c : components) {
     if (c instanceof BooleanType) {
       this.components.add(factory.createBoolean((BooleanType) c));
     } else if (c instanceof ConditionalValueType) {
       this.components.add(factory.createConditionalValue((ConditionalValueType) c));
     } else if (c instanceof DataArrayType) {
       this.components.add(factory.createDataArray((DataArrayType) c));
     } else if (c instanceof DataRecordType) {
       this.components.add(factory.createDataRecord((DataRecordType) c));
     } else if (c instanceof EnvelopeType) {
       this.components.add(factory.createEnvelope((EnvelopeType) c));
     } else if (c instanceof GeoLocationArea) {
       this.components.add(factory.createGeoLocationArea((GeoLocationArea) c));
     } else if (c instanceof PositionType) {
       this.components.add(factory.createPosition((PositionType) c));
     } else if (c instanceof QuantityType) {
       this.components.add(factory.createQuantity((QuantityType) c));
     } else if (c instanceof SimpleDataRecordType) {
       this.components.add(factory.createSimpleDataRecord((SimpleDataRecordType) c));
     } else if (c instanceof SquareMatrixType) {
       this.components.add(factory.createSquareMatrix((SquareMatrixType) c));
     } else if (c instanceof TimeType) {
       this.components.add(factory.createTime((TimeType) c));
     } else if (c instanceof VectorType) {
       this.components.add(factory.createVector((VectorType) c));
     } else if (c instanceof AbstractDataArrayType) {
       this.components.add(factory.createAbstractDataArray((AbstractDataArrayType) c));
     } else if (c instanceof AbstractDataRecordType) {
       this.components.add(factory.createAbstractDataRecord((AbstractDataRecordType) c));
     } else if (c instanceof AbstractDataComponentType) {
       this.components.add(factory.createAbstractDataComponent((AbstractDataComponentType) c));
     } else {
       throw new IllegalArgumentException(
           "unexpected type for component:" + c.getClass().getName());
     }
   }
   this.encoding = new AbstractEncodingPropertyType(encoding);
 }