From da1bceaddf21e9493ae72e2f6dcfe2cbb5cf15ec Mon Sep 17 00:00:00 2001 From: Markus Kroetzsch Date: Thu, 27 Feb 2014 16:16:51 +0100 Subject: [PATCH 1/2] Fixing issue #27. --- .../wdtk/datamodel/implementation/ItemIdValueImpl.java | 6 +++--- .../wdtk/datamodel/implementation/PropertyIdValueImpl.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java index e7fd55512..283b894f0 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java @@ -24,8 +24,8 @@ import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue; /** - * Generic implementation of {@link ItemIdValue} that works with arbitrary Wikibase - * instances: it requires a baseIri that identifies the site globally. + * Generic implementation of {@link ItemIdValue} that works with arbitrary + * Wikibase instances: it requires a baseIri that identifies the site globally. * * @author Markus Kroetzsch * @@ -42,7 +42,7 @@ public class ItemIdValueImpl extends EntityIdValueImpl implements ItemIdValue { if (!id.matches("^Q[1-9][0-9]*$")) { throw new IllegalArgumentException( - "Wikibase item ids must have the form \"Q[1-9]+\""); + "Wikibase item ids must have the form \"Q\""); } } diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java index 87d99b601..d22af3487 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java @@ -30,7 +30,8 @@ * @author Markus Kroetzsch * */ -public class PropertyIdValueImpl extends EntityIdValueImpl implements PropertyIdValue { +public class PropertyIdValueImpl extends EntityIdValueImpl implements + PropertyIdValue { /** * @see EntityIdValueImpl#EntityIdImpl(String, String) @@ -42,7 +43,7 @@ public class PropertyIdValueImpl extends EntityIdValueImpl implements PropertyId if (!id.matches("^P[1-9][0-9]*$")) { throw new IllegalArgumentException( - "Wikibase item ids must have the form \"Q[1-9]+\""); + "Wikibase property ids must have the form \"P\""); } } From 37be7b7a7ceb8b9a9958f0518b1bdfcb264bc8b6 Mon Sep 17 00:00:00 2001 From: Markus Kroetzsch Date: Fri, 28 Feb 2014 14:28:06 +0100 Subject: [PATCH 2/2] Extended documentation of constructor parameters --- .../implementation/EntityIdValueImpl.java | 11 ++++++----- .../datamodel/implementation/ItemIdValueImpl.java | 6 ++++++ .../implementation/PropertyIdValueImpl.java | 6 ++++++ .../datamodel/interfaces/DataObjectFactory.java | 14 ++++++++------ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityIdValueImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityIdValueImpl.java index 5809fc59d..8b677595a 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityIdValueImpl.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityIdValueImpl.java @@ -25,8 +25,8 @@ import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue; /** - * Generic implementation of {@link EntityIdValue} that works with arbitrary Wikibase - * instances: it requires a baseIri that identifies the site globally. + * Generic implementation of {@link EntityIdValue} that works with arbitrary + * Wikibase instances: it requires a baseIri that identifies the site globally. * * TODO It would be cleaner to have an object that manages the site context * instead of passing a base IRI string that is simply concatenated. @@ -47,10 +47,11 @@ public abstract class EntityIdValueImpl implements EntityIdValue { * Constructor. * * @param id - * the ID string, e.g., "Q1234" + * the ID string, e.g., "Q1234". The required format depends on + * the specific type of entity * @param baseIri - * the first part of the IRI of the site this belongs to, e.g., - * "http://www.wikidata.org/entity/" + * the first part of the entity IRI of the site this belongs to, + * e.g., "http://www.wikidata.org/entity/" */ EntityIdValueImpl(String id, String baseIri) { Validate.notNull(id, "Entity ids cannot be null"); diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java index 283b894f0..56ca97117 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/ItemIdValueImpl.java @@ -33,9 +33,15 @@ public class ItemIdValueImpl extends EntityIdValueImpl implements ItemIdValue { /** + * Constructor. + * * @see EntityIdValueImpl#EntityIdImpl(String, String) * @param id + * a string of the form Qn... where n... is the string + * representation of a positive integer number * @param baseIri + * the first part of the entity IRI of the site this belongs to, + * e.g., "http://www.wikidata.org/entity/" */ ItemIdValueImpl(String id, String baseIri) { super(id, baseIri); diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java index d22af3487..1fa1de541 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/PropertyIdValueImpl.java @@ -34,9 +34,15 @@ public class PropertyIdValueImpl extends EntityIdValueImpl implements PropertyIdValue { /** + * Constructor. + * * @see EntityIdValueImpl#EntityIdImpl(String, String) * @param id + * a string of the form Pn... where n... is the string + * representation of a positive integer number * @param baseIri + * the first part of the entity IRI of the site this belongs to, + * e.g., "http://www.wikidata.org/entity/" */ PropertyIdValueImpl(String id, String baseIri) { super(id, baseIri); diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/DataObjectFactory.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/DataObjectFactory.java index 115ea1a64..f3144481c 100644 --- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/DataObjectFactory.java +++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/DataObjectFactory.java @@ -37,10 +37,11 @@ public interface DataObjectFactory { * Create an {@link ItemIdValue}. * * @param id - * the ID string, e.g., "Q1234" + * a string of the form Qn... where n... is the string + * representation of a positive integer number * @param baseIri - * the first part of the IRI of the site this belongs to, e.g., - * "http://www.wikidata.org/entity/" + * the first part of the entity IRI of the site this belongs to, + * e.g., "http://www.wikidata.org/entity/" * @return an {@link ItemIdValue} corresponding to the input */ ItemIdValue getItemIdValue(String id, String baseIri); @@ -49,10 +50,11 @@ public interface DataObjectFactory { * Create a {@link PropertyIdValue}. * * @param id - * the ID string, e.g., "P1234" + * a string of the form Pn... where n... is the string + * representation of a positive integer number * @param baseIri - * the first part of the IRI of the site this belongs to, e.g., - * "http://www.wikidata.org/entity/" + * the first part of the entity IRI of the site this belongs to, + * e.g., "http://www.wikidata.org/entity/" * @return a {@link PropertyIdValue} corresponding to the input */ PropertyIdValue getPropertyIdValue(String id, String baseIri);