예제 #1
0
  public void addLocalTagEntry(PropertyDefinition propertyDefinition) throws NullPointerException {

    if (propertyDefinition == null)
      throw new NullPointerException("Cannot add a null property definition to a primer pack.");
    AUID uid = propertyDefinition.getAUID();
    if (!reverseMap.containsKey(uid)) {
      short localTag = propertyDefinition.getLocalIdentification();
      if (localTag <= 0) localTag = getNextLocalCounter();
      addLocalTagEntry(localTag, propertyDefinition.getAUID());
    }
  }
예제 #2
0
  public Short lookupLocalTag(PropertyDefinition propertyDefinition) throws NullPointerException {

    if (propertyDefinition == null)
      throw new NullPointerException(
          "Cannot look up a property to find its local tag using a null value.");

    AUID propertyID = propertyDefinition.getAUID();

    //		if (!(reverseMap.containsKey(propertyID)))
    //			addLocalTagEntry(propertyDefinition);

    Short localTag = reverseMap.get(propertyID);
    if (localTag == null) {
      System.err.println(
          "Cannot map the given property "
              + propertyDefinition.getMemberOf().getName()
              + "."
              + propertyDefinition.getName()
              + " to a tag.");
      return null;
    } else return localTag;
  }
예제 #3
0
  public static final long addPropertiesForObject(PrimerPack primerPack, MetadataObject mdObject)
      throws NullPointerException {

    if (primerPack == null)
      throw new NullPointerException("Cannot add local tag entries to a null primer pack.");
    if (mdObject == null)
      throw new NullPointerException(
          "Cannot add local tag entries to a primer pack using a null metadata object.");

    ClassDefinition objectsClass = MediaEngine.getClassDefinition(mdObject);
    long setLength =
        MXFBuilder.lengthOfLocalSet(mdObject)
            + 20l; // Bytes in value plus initial class ID and 4-byte length

    for (PropertyDefinition propertyDefinition : objectsClass.getAllPropertyDefinitions()) {

      PropertyValue propertyValue = null;
      try {
        if (propertyDefinition.getIsOptional()) propertyDefinition.getPropertyValue(mdObject);
      } catch (IllegalArgumentException iae) {
        continue;
      } catch (PropertyNotPresentException pnpe) {
        continue;
      }

      primerPack.addLocalTagEntry(propertyDefinition);

      TypeDefinition propertyType = propertyDefinition.getTypeDefinition();

      switch (propertyType.getTypeCategory()) {
        case StrongObjRef:
          if (propertyValue == null) propertyValue = propertyDefinition.getPropertyValue(mdObject);
          MetadataObject stronglyReferencedObject = (MetadataObject) propertyValue.getValue();
          setLength += addPropertiesForObject(primerPack, stronglyReferencedObject);
          break;
        case Set:
          if (propertyValue == null) propertyValue = propertyDefinition.getPropertyValue(mdObject);
          TypeDefinition setElementType = ((TypeDefinitionSet) propertyType).getElementType();

          if (setElementType instanceof TypeDefinitionStrongObjectReference) {
            Set<?> setValues = (Set<?>) propertyValue.getValue();
            for (Object value : setValues)
              setLength += addPropertiesForObject(primerPack, (MetadataObject) value);
          }
          break;
        case VariableArray:
          if (propertyValue == null) propertyValue = propertyDefinition.getPropertyValue(mdObject);
          TypeDefinition arrayElementType = ((TypeDefinitionVariableArray) propertyType).getType();

          if (arrayElementType instanceof TypeDefinitionStrongObjectReference) {
            List<?> arrayValues = (List<?>) propertyValue.getValue();
            for (Object value : arrayValues)
              setLength += addPropertiesForObject(primerPack, (MetadataObject) value);
          }
          break;
        default:
          break;
      }
    }

    // Add local tags defined in the index packs
    PrimerPack indexPrimerPack = new IndexPrimerPackImpl();
    for (LocalTagEntry tagEntry : indexPrimerPack.getLocalTagEntryBatch()) {
      primerPack.addLocalTagEntry(tagEntry);
    }

    return setLength;
  }