You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2011/11/12 13:06:58 UTC
svn commit: r1201252 [3/3] - in
/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox: ./ parser/
schema/ type/
Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java?rev=1201252&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java Sat Nov 12 12:06:57 2011
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox.schema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.apache.padaf.xmpbox.type.AbstractField;
+import org.apache.padaf.xmpbox.type.Attribute;
+import org.apache.padaf.xmpbox.type.BadFieldValueException;
+import org.apache.padaf.xmpbox.type.ComplexProperty;
+import org.apache.padaf.xmpbox.type.JobType;
+import org.apache.padaf.xmpbox.type.LayerType;
+
+public class XMPBasicJobTicketSchema extends XMPSchema {
+
+ public static String PREFERED_JOB_TICKET_PREFIX = "xmpBJ";
+
+ public static String JOB_TICKET_URI = "http://ns.adobe.com/xap/1.0/bj/";
+
+ @PropertyType(propertyType = "bag Job")
+ public static final String JOB_REF = "JobRef";
+
+ protected ComplexProperty bagJobs;
+
+
+ public XMPBasicJobTicketSchema(XMPMetadata metadata) {
+ this(metadata, PREFERED_JOB_TICKET_PREFIX);
+ }
+
+ public XMPBasicJobTicketSchema(XMPMetadata metadata, String ownPrefix) {
+ super(metadata, ownPrefix, JOB_TICKET_URI);
+ content.setAttribute(new Attribute(NS_NAMESPACE, "xmlns",
+ JobType.PREFERED_PREFIX, JobType.ELEMENT_NS));
+
+ }
+
+ public void addJob(String id , String name, String url) {
+ if (bagJobs == null) {
+ bagJobs = new ComplexProperty(metadata, localPrefix, JOB_REF,
+ ComplexProperty.UNORDERED_ARRAY);
+ addProperty(bagJobs);
+ }
+ JobType job = new JobType(metadata, "rdf", "li");
+ job.setId("stJob", id);
+ job.setName("stJob", name);
+ job.setUrl("stJob", url);
+ bagJobs.getContainer().addProperty(job);
+ }
+
+ public List<JobType> getJobs() throws BadFieldValueException {
+ List<AbstractField> tmp = getArrayList(localPrefixSep + JOB_REF);
+ if (tmp != null) {
+ List<JobType> layers = new ArrayList<JobType>();
+ for (AbstractField abstractField : tmp) {
+ if (abstractField instanceof JobType) {
+ layers.add((JobType) abstractField);
+ } else {
+ throw new BadFieldValueException("Job expected and "
+ + abstractField.getClass().getName() + " found.");
+ }
+ }
+ return layers;
+ }
+ return null;
+
+ }
+
+
+}
Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java?rev=1201252&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java (added)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java Sat Nov 12 12:06:57 2011
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+package org.apache.padaf.xmpbox.type;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+
+public class JobType extends ComplexPropertyContainer {
+
+ public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/sType/Job#";
+
+ public static final String PREFERED_PREFIX = "stJob";
+
+ public static final String ID = "id";
+
+ public static final String NAME = "name";
+
+ public static final String URL = "url";
+
+ protected XMPMetadata metadata;
+
+
+ public JobType(XMPMetadata metadata, String namespace, String prefix,
+ String propertyName) {
+ super(metadata, namespace, prefix, propertyName);
+ this.metadata = metadata;
+ setAttribute(new Attribute(null, "rdf", "parseType", "Resource"));
+ }
+
+
+
+ public JobType(XMPMetadata metadata, String prefix, String propertyName) {
+ super(metadata, prefix, propertyName);
+ this.metadata = metadata;
+ setAttribute(new Attribute(null, "rdf", "parseType", "Resource"));
+ }
+
+ public void setId(String prefix, String id) {
+ this.addProperty(new TextType(metadata, prefix, ID, id));
+ }
+
+ public void setName(String prefix, String name) {
+ this.addProperty(new TextType(metadata, prefix, NAME, name));
+ }
+
+ public void setUrl(String prefix, String name) {
+ this.addProperty(new TextType(metadata, prefix, URL, name));
+ }
+
+ public String getId() {
+ AbstractField absProp = getFirstEquivalentProperty(ID,TextType.class);
+ if (absProp != null) {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ public String getName() {
+ AbstractField absProp = getFirstEquivalentProperty(NAME,TextType.class);
+ if (absProp != null) {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ public String getUrl() {
+ AbstractField absProp = getFirstEquivalentProperty(URL,TextType.class);
+ if (absProp != null) {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+}
Propchange: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java
------------------------------------------------------------------------------
svn:eol-style = native