public String getOptionalAttributeValue()

in ch-sxmp/src/main/java/com/cloudhopper/sxmp/SxmpParser.java [215:243]


        public String getOptionalAttributeValue(String tag, Attributes attrs, String name) throws SxmpParsingException {
            //
            // make sure the attribute exists
            //
            int size = attrs.getLength();
            String value = null;

            for (int i = 0; i < size; i++) {
                if (attrs.getQName(i).equals(name)) {
                    // is this the second time we found this attribute?
                    if (value != null) {
                        throw new SxmpParsingException(SxmpErrorCode.MULTIPLE_ATTRIBUTES_NOT_SUPPORTED, "Multiple [" + name + "] attributes within the [" + tag + "] element are not supported", (this.operation != null ? this.operation : new PartialOperation(this.operationType)));
                    }

                    value = attrs.getValue(i);

                    // is there some sort of value for it?
                    if (StringUtil.isEmpty(value)) {
                        throw new SxmpParsingException(SxmpErrorCode.EMPTY_VALUE, "The [" + name + "] attribute was empty in the [" + tag + "] element", (this.operation != null ? this.operation : new PartialOperation(this.operationType)));
                    }
                }
            }

            if (value != null) {
                return value;
            } else {
                return null;
            }
        }