示例#1
0
 MetadataAttribute attributeToMetadata(Attribute attribute) {
   final int productDataType = getProductDataType(attribute.getDataType(), false, false);
   if (productDataType != -1) {
     ProductData productData;
     if (attribute.isString()) {
       productData = ProductData.createInstance(attribute.getStringValue());
     } else if (attribute.isArray()) {
       productData = ProductData.createInstance(productDataType, attribute.getLength());
       productData.setElems(attribute.getValues().getStorage());
     } else {
       productData = ProductData.createInstance(productDataType, 1);
       productData.setElems(attribute.getValues().getStorage());
     }
     return new MetadataAttribute(attribute.getShortName(), productData, true);
   }
   return null;
 }
示例#2
0
文件: DataNode.java 项目: TonioF/beam
  /**
   * Sets the data elements of this data node.
   *
   * @see ProductData#setElems(Object)
   */
  public void setDataElems(Object elems) {

    if (isReadOnly()) {
      throw new IllegalArgumentException("attribute is read-only");
    }

    checkState();
    if (data == null) {
      if (numElems > Integer.MAX_VALUE) {
        throw new IllegalStateException(
            "number of elements must be less than " + (long) Integer.MAX_VALUE + 1);
      }
      data = createCompatibleProductData((int) numElems);
    }
    Object oldData = data.getElems();
    if (!ObjectUtils.equalObjects(oldData, elems)) {
      data.setElems(elems);
      fireProductNodeDataChanged();
      setModified(true);
    }
  }