You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2009/12/09 14:21:05 UTC
svn commit: r888794 - in /xmlgraphics/commons/trunk:
src/java/org/apache/xmlgraphics/xmp/
src/java/org/apache/xmlgraphics/xmp/schemas/
test/java/org/apache/xmlgraphics/xmp/
Author: jeremias
Date: Wed Dec 9 13:21:04 2009
New Revision: 888794
URL: http://svn.apache.org/viewvc?rev=888794&view=rev
Log:
Added access methods for the remaining Dublin Core properties to the adapter.
Added support for removing properties.
Added:
xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java Wed Dec 9 13:21:04 2009
@@ -57,6 +57,11 @@
}
/** {@inheritDoc} */
+ public XMPProperty removeProperty(QName name) {
+ return (XMPProperty)properties.remove(name);
+ }
+
+ /** {@inheritDoc} */
public XMPProperty getValueProperty() {
return getProperty(XMPConstants.RDF_VALUE);
}
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java Wed Dec 9 13:21:04 2009
@@ -50,6 +50,13 @@
XMPProperty getProperty(QName name);
/**
+ * Removes a property and returns it if it was found.
+ * @param name the name of the property
+ * @return the removed property or null if it was not found
+ */
+ XMPProperty removeProperty(QName name);
+
+ /**
* Returns the rdf:value property. This is a shortcut for getProperty(XMPConstants.RDF_VALUE).
* @return the rdf:value property or null if it's no available
*/
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java Wed Dec 9 13:21:04 2009
@@ -128,19 +128,21 @@
/**
* Removes a language-dependent value
* @param lang the language ("x-default" for the default value)
+ * @return the removed value (or null if no value was set)
*/
- public void removeLangValue(String lang) {
+ public String removeLangValue(String lang) {
if (lang == null && "".equals(lang)) {
- return;
+ return null;
}
for (int i = 0, c = values.size(); i < c; i++) {
String l = (String)xmllang.get(i);
if (lang.equals(l)) {
- values.remove(i);
+ String value = (String)values.remove(i);
xmllang.remove(i);
- return;
+ return value;
}
}
+ return null;
}
/**
@@ -153,6 +155,22 @@
}
/**
+ * Removes a value from the array. If the value doesn't exist, nothing happens.
+ * @param value the value to be removed
+ * @return true if the value was removed, false if it wasn't found
+ */
+ public boolean remove(String value) {
+ int idx = values.indexOf(value);
+ if (idx >= 0) {
+ values.remove(idx);
+ xmllang.remove(idx);
+ return true;
+ }
+ return false;
+
+ }
+
+ /**
* Adds a language-dependent value to the array. Make sure not to add the same language twice.
* @param value the value
* @param lang the language ("x-default" for the default value)
@@ -162,7 +180,10 @@
xmllang.add(lang);
}
- /** @return the current number of value in the array */
+ /**
+ * Returns the current number of values in the array.
+ * @return the current number of values in the array
+ */
public int getSize() {
return this.values.size();
}
@@ -212,5 +233,4 @@
return "XMP array: " + type + ", " + getSize();
}
-
}
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java Wed Dec 9 13:21:04 2009
@@ -76,6 +76,14 @@
}
/**
+ * Resets this property to no value.
+ */
+ public void clear() {
+ setValue(null);
+ setXMLLang(null);
+ }
+
+ /**
* Sets the xml:lang value for this property
* @param lang the language ("x-default" for the default language, null to make the value
* language-independent)
@@ -91,9 +99,17 @@
return this.xmllang;
}
+ /**
+ * Indicates whether the property is an array.
+ * @return true if the property is an array
+ */
+ public boolean isArray() {
+ return value instanceof XMPArray;
+ }
+
/** @return the XMPArray for an array or null if the value is not an array. */
public XMPArray getArrayValue() {
- return (value instanceof XMPArray ? (XMPArray)value : null);
+ return (isArray() ? (XMPArray)value : null);
}
/**
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java Wed Dec 9 13:21:04 2009
@@ -75,6 +75,9 @@
* @param arrayType the type of array to operate on
*/
private void addStringToArray(String propName, String value, XMPArrayType arrayType) {
+ if (value == null || value.length() == 0) {
+ throw new IllegalArgumentException("Value must not be empty");
+ }
QName name = getQName(propName);
XMPProperty prop = meta.getProperty(name);
XMPArray array;
@@ -90,6 +93,37 @@
}
/**
+ * Removes a value from an array.
+ * @param propName the name of the property
+ * @param value the value to be removed
+ * @return true if the value was removed, false if it was not found
+ */
+ protected boolean removeStringFromArray(String propName, String value) {
+ if (value == null) {
+ return false;
+ }
+ QName name = getQName(propName);
+ XMPProperty prop = meta.getProperty(name);
+ if (prop != null) {
+ if (prop.isArray()) {
+ XMPArray arr = prop.getArrayValue();
+ boolean removed = arr.remove(value);
+ if (arr.getSize() == 0) {
+ meta.removeProperty(name);
+ }
+ return removed;
+ } else {
+ Object currentValue = prop.getValue();
+ if (value.equals(currentValue)) {
+ meta.removeProperty(name);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
* Adds a String value to an ordered array.
* @param propName the property name
* @param value the String value
@@ -272,11 +306,13 @@
protected void setValue(String propName, String value) {
QName name = getQName(propName);
XMPProperty prop = meta.getProperty(name);
- if (prop == null) {
+ if (prop == null && value != null && value.length() > 0) {
prop = new XMPProperty(name, value);
meta.setProperty(prop);
- } else {
+ } else if (value != null) {
prop.setValue(value);
+ } else {
+ meta.removeProperty(name);
}
}
@@ -299,21 +335,29 @@
* Removes a language-dependent value from an alternative array.
* @param lang the language ("x-default" for the default language)
* @param propName the property name
+ * @return the removed value
*/
- protected void removeLangAlt(String lang, String propName) {
- XMPProperty prop = meta.getProperty(getQName(propName));
+ protected String removeLangAlt(String lang, String propName) {
+ QName name = getQName(propName);
+ XMPProperty prop = meta.getProperty(name);
XMPArray array;
if (prop != null && lang != null) {
array = prop.getArrayValue();
if (array != null) {
- array.removeLangValue(lang);
+ String removed = array.removeLangValue(lang);
+ if (array.getSize() == 0) {
+ meta.removeProperty(name);
+ }
+ return removed;
} else {
+ String removed = prop.getValue().toString();
if (lang.equals(prop.getXMLLang())) {
- prop.setValue(null);
- prop.setXMLLang(null);
+ prop.clear();
}
+ return removed;
}
}
+ return null;
}
/**
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java Wed Dec 9 13:21:04 2009
@@ -68,6 +68,11 @@
}
/** {@inheritDoc} */
+ public XMPProperty removeProperty(QName name) {
+ return (XMPProperty)properties.remove(name);
+ }
+
+ /** {@inheritDoc} */
public int getPropertyCount() {
return this.properties.size();
}
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java?rev=888794&r1=888793&r2=888794&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java Wed Dec 9 13:21:04 2009
@@ -33,12 +33,21 @@
*/
public class DublinCoreAdapter extends XMPSchemaAdapter {
+ private static final String CONTRIBUTOR = "contributor";
+ private static final String COVERAGE = "coverage";
private static final String CREATOR = "creator";
private static final String DATE = "date";
- private static final String SUBJECT = "subject";
- private static final String TITLE = "title";
private static final String DESCRIPTION = "description";
+ private static final String FORMAT = "format";
+ private static final String IDENTIFIER = "identifier";
private static final String LANGUAGE = "language";
+ private static final String PUBLISHER = "publisher";
+ private static final String RELATION = "relation";
+ private static final String RIGHTS = "rights";
+ private static final String SOURCE = "source";
+ private static final String SUBJECT = "subject";
+ private static final String TITLE = "title";
+ private static final String TYPE = "type";
/**
* Constructs a new adapter for Dublin Core around the given metadata object.
@@ -49,6 +58,47 @@
}
/**
+ * Adds a new entry to the list of contributors (other than the authors).
+ * @param value the new value
+ */
+ public void addContributor(String value) {
+ addStringToBag(CONTRIBUTOR, value);
+ }
+
+ /**
+ * Removes an entry from the list of contributors.
+ * @param value the value to be removed
+ * @return the removed entry
+ */
+ public boolean removeContributor(String value) {
+ return removeStringFromArray(CONTRIBUTOR, value);
+ }
+
+ /**
+ * Returns an array of all contributors.
+ * @return a String array of all contributors (or null if not set)
+ */
+ public String[] getContributors() {
+ return getStringArray(CONTRIBUTOR);
+ }
+
+ /**
+ * Sets the extent or scope of the resource.
+ * @param value the new value.
+ */
+ public void setCoverage(String value) {
+ setValue(COVERAGE, value);
+ }
+
+ /**
+ * Returns the extent or scope of the resource.
+ * @return the property value (or null if not set)
+ */
+ public String getCoverage() {
+ return getValue(COVERAGE);
+ }
+
+ /**
* Adds a new entry to the list of creators (authors of the resource).
* @param value the new value
*/
@@ -56,7 +106,19 @@
addStringToSeq(CREATOR, value);
}
- /** @return a String array of all creators */
+ /**
+ * Removes an entry from the list of creators (authors of the resource).
+ * @param value the value to be removed
+ * @return the removed entry
+ */
+ public boolean removeCreator(String value) {
+ return removeStringFromArray(CREATOR, value);
+ }
+
+ /**
+ * Returns an array of all creators.
+ * @return a String array of all creators (or null if not set)
+ */
public String[] getCreators() {
return getStringArray(CREATOR);
}
@@ -101,6 +163,156 @@
}
/**
+ * Sets the description of the content of the resource.
+ * @param lang the language of the value ("x-default" or null for the default language)
+ * @param value the new value
+ */
+ public void setDescription(String lang, String value) {
+ setLangAlt(DESCRIPTION, lang, value);
+ }
+
+ /**
+ * Returns the description of the content of the resource (in the default language).
+ * @return the description of the content of the resource (or null if not set)
+ */
+ public String getDescription() {
+ return getDescription(null);
+ }
+
+ /**
+ * Returns the description of the content of the resource in a language-dependant way.
+ * @param lang the language ("x-default" or null for the default language)
+ * @return the language-dependent value (or null if not set)
+ */
+ public String getDescription(String lang) {
+ return getLangAlt(lang, DESCRIPTION);
+ }
+
+ /**
+ * Sets the file format used when saving the resource. Tools and
+ * applications should set this property to the save format of the
+ * data. It may include appropriate qualifiers.
+ * @param value a MIME type
+ */
+ public void setFormat(String value) {
+ setValue(FORMAT, value);
+ }
+
+ /**
+ * Returns the file format used when saving this resource.
+ * @return the MIME type of the file format (or null if not set)
+ */
+ public String getFormat() {
+ return getValue(FORMAT);
+ }
+
+ /**
+ * Sets the unique identifier of the resource.
+ * @param value the new value
+ */
+ public void setIdentifier(String value) {
+ setValue(IDENTIFIER, value);
+ }
+
+ /**
+ * Returns the unique identifier of the resource.
+ * @return the unique identifier (or null if not set)
+ */
+ public String getIdentifier() {
+ return getValue(IDENTIFIER);
+ }
+
+ /**
+ * Adds a new entry to the list of languages (RFC 3066).
+ * @param value the new value
+ */
+ public void addLanguage(String value) {
+ addStringToBag(LANGUAGE, value);
+ }
+
+ /**
+ * Returns an array of languages.
+ * @return a String array of all languages (or null if not set)
+ */
+ public String[] getLanguages() {
+ return getStringArray(LANGUAGE);
+ }
+
+ /**
+ * Adds a new entry to the list of publishers.
+ * @param value the new value
+ */
+ public void addPublisher(String value) {
+ addStringToBag(PUBLISHER, value);
+ }
+
+ /**
+ * Returns an array of publishers.
+ * @return a String array of all publishers (or null if not set)
+ */
+ public String[] getPublisher() {
+ return getStringArray(PUBLISHER);
+ }
+
+ /**
+ * Adds a new entry to the list of relationships to other documents.
+ * @param value the new value
+ */
+ public void addRelation(String value) {
+ addStringToBag(RELATION, value);
+ }
+
+ /**
+ * Returns an array of all relationship to other documents.
+ * @return a String array of all relationships (or null if none are set)
+ */
+ public String[] getRelations() {
+ return getStringArray(RELATION);
+ }
+
+ /**
+ * Sets the informal rights statement.
+ * @param lang the language of the value ("x-default" or null for the default language)
+ * @param value the new value
+ */
+ public void setRights(String lang, String value) {
+ setLangAlt(RIGHTS, lang, value);
+ }
+
+ /**
+ * Returns the informal rights statement.
+ * @return the informal right statement (or null if not set)
+ */
+ public String getRights() {
+ return getRights(null);
+ }
+
+ /**
+ * Returns the informal rights statement in a language-dependant way.
+ * @param lang the language ("x-default" or null for the default language)
+ * @return the language-dependent value (or null if not set)
+ */
+ public String getRights(String lang) {
+ return getLangAlt(lang, RIGHTS);
+ }
+
+ /**
+ * Sets the unique identifier of the work from which this resource was derived.
+ * @param value the new value
+ */
+ public void setSource(String value) {
+ setValue(SOURCE, value);
+ }
+
+ /**
+ * Returns unique identifier of the work from which this resource was derived.
+ * @return the source (or null if not set)
+ */
+ public String getSource() {
+ return getValue(SOURCE);
+ }
+
+ /**
* Adds a new entry to the list of subjects (descriptive phrases or keywords that
* specify the topic of the content of the resource).
* @param value the new value
@@ -109,7 +321,10 @@
addStringToBag(SUBJECT, value);
}
- /** @return a String array of all subjects */
+ /**
+ * Returns an array of all subjects.
+ * @return a String array of all subjects
+ */
public String[] getSubjects() {
return getStringArray(SUBJECT);
}
@@ -131,7 +346,10 @@
setLangAlt(TITLE, lang, value);
}
- /** @return the title of the resource (in the default language) */
+ /**
+ * Returns the title of the resource (in the default language).
+ * @return the title of the resource (in the default language)
+ */
public String getTitle() {
return getTitle(null);
}
@@ -139,46 +357,36 @@
/**
* Returns the title of the resource in a language-dependant way.
* @param lang the language ("x-default" or null for the default language)
- * @return the language-dependent value.
+ * @return the language-dependent value (or null if not set)
*/
public String getTitle(String lang) {
return getLangAlt(lang, TITLE);
}
/**
- * Sets the description of the content of the resource.
- * @param lang the language of the value ("x-default" or null for the default language)
- * @param value the new value
+ * Removes a title of the resource.
+ * @param lang the language variant to be removed
+ * @return the previously set value or null if this language variant wasn't set
*/
- public void setDescription(String lang, String value) {
- setLangAlt(DESCRIPTION, lang, value);
- }
-
- /** @return the description of the content of the resource (in the default language) */
- public String getDescription() {
- return getDescription(null);
+ public String removeTitle(String lang) {
+ return removeLangAlt(lang, TITLE);
}
/**
- * Returns the description of the content of the resource in a language-dependant way.
- * @param lang the language ("x-default" or null for the default language)
- * @return the language-dependent value.
+ * Adds a new entry to the list of document types (for example: novel, poem or working paper).
+ * @param value the new value
*/
- public String getDescription(String lang) {
- return getLangAlt(lang, DESCRIPTION);
+ public void addType(String value) {
+ addStringToBag(TYPE, value);
}
/**
- * Adds a new entry to the list of languages (RFC 3066).
- * @param value the new value
+ * Returns an array of all document types.
+ * @return a String array of all document types (or null if not set)
*/
- public void addLanguage(String value) {
- addStringToBag(LANGUAGE, value);
+ public String[] getTypess() {
+ return getStringArray(TYPE);
}
- /** @return a String array of all language */
- public String[] getLanguages() {
- return getStringArray(LANGUAGE);
- }
}
Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java?rev=888794&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java Wed Dec 9 13:21:04 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.xmp;
+
+import junit.framework.TestCase;
+
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
+
+/**
+ * Tests property access methods.
+ */
+public class XMPPropertyTest extends TestCase {
+
+ public void testPropertyAccess() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+ assertNull(dc.getContributors());
+ dc.addContributor("Contributor1");
+ assertEquals(1, dc.getContributors().length);
+ assertEquals("Contributor1", dc.getContributors()[0]);
+ dc.addContributor("Contributor2");
+ assertEquals(2, dc.getContributors().length);
+ assertFalse(dc.removeContributor("DoesNotExist"));
+ assertTrue(dc.removeContributor("Contributor1"));
+ assertEquals(1, dc.getContributors().length);
+ assertTrue(dc.removeContributor("Contributor2"));
+ assertFalse(dc.removeContributor("Contributor2"));
+ assertNull(dc.getContributors());
+ }
+
+ public void testPropertyRemovalLangAlt() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+
+ //dc:title is a "Lang Alt"
+ dc.setTitle("en", "The title");
+ dc.setTitle("de", "Der Titel");
+ String title = dc.removeTitle("en");
+ assertEquals("The title", title);
+ title = dc.removeTitle("en");
+ assertNull(title);
+
+ title = dc.removeTitle("de");
+ assertEquals("Der Titel", title);
+ title = dc.removeTitle("de");
+ assertNull(title);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
Re: svn commit: r888794 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/xmp/ src/java/org/apache/xmlgraphics/xmp/schemas/ test/java/org/apache/xmlgraphics/xmp/
Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Thanks for the nudge and the typo fixes, Vincent. I've fixed a few
smaller bugs by improving test coverage. The whole thing should behave
much better now.
On 10.12.2009 12:25:31 Vincent Hennebert wrote:
> Hi,
>
> > Author: jeremias
> > Date: Wed Dec 9 13:21:04 2009
> > New Revision: 888794
> >
> > URL: http://svn.apache.org/viewvc?rev=888794&view=rev
> > Log:
> > Added access methods for the remaining Dublin Core properties to the adapter.
> > Added support for removing properties.
> >
> > Added:
> > xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
> > Modified:
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java
> >
> <snip/>
> > Modified:
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
> > URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java?rev=888794&r1=888793&r2=888794&view=diff
> > ==============================================================================
> > --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java (original)
> > +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java Wed Dec 9 13:21:04 2009
> > @@ -272,11 +306,13 @@
> > protected void setValue(String propName, String value) {
> > QName name = getQName(propName);
> > XMPProperty prop = meta.getProperty(name);
> > - if (prop == null) {
> > + if (prop == null && value != null && value.length() > 0) {
> > prop = new XMPProperty(name, value);
> > meta.setProperty(prop);
> > - } else {
> > + } else if (value != null) {
> > prop.setValue(value);
> > + } else {
> > + meta.removeProperty(name);
>
> What’s supposed to happen if (prop == null && value != null && value.length()
> == 0)?
>
> Vincent
>
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org
Re: svn commit: r888794 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/xmp/
src/java/org/apache/xmlgraphics/xmp/schemas/ test/java/org/apache/xmlgraphics/xmp/
Posted by Vincent Hennebert <vh...@gmail.com>.
Hi,
> Author: jeremias
> Date: Wed Dec 9 13:21:04 2009
> New Revision: 888794
>
> URL: http://svn.apache.org/viewvc?rev=888794&view=rev
> Log:
> Added access methods for the remaining Dublin Core properties to the adapter.
> Added support for removing properties.
>
> Added:
> xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
> Modified:
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/Metadata.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/PropertyAccess.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPStructure.java
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/schemas/DublinCoreAdapter.java
>
<snip/>
> Modified:
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java?rev=888794&r1=888793&r2=888794&view=diff
> ==============================================================================
> --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java (original)
> +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java Wed Dec 9 13:21:04 2009
> @@ -272,11 +306,13 @@
> protected void setValue(String propName, String value) {
> QName name = getQName(propName);
> XMPProperty prop = meta.getProperty(name);
> - if (prop == null) {
> + if (prop == null && value != null && value.length() > 0) {
> prop = new XMPProperty(name, value);
> meta.setProperty(prop);
> - } else {
> + } else if (value != null) {
> prop.setValue(value);
> + } else {
> + meta.removeProperty(name);
What’s supposed to happen if (prop == null && value != null && value.length()
== 0)?
Vincent
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org