Skip to content

Commit

Permalink
Merge pull request #28 from Wikidata/issue-#27
Browse files Browse the repository at this point in the history
Fixing issue #27.
  • Loading branch information
Fredo Erxleben committed Feb 28, 2014
2 parents 0bf484b + 37be7b7 commit 1f7ec00
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
Expand Up @@ -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.
Expand All @@ -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");
Expand Down
Expand Up @@ -24,25 +24,31 @@
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
*
*/
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);

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<positive integer>\"");
}
}

Expand Down
Expand Up @@ -30,19 +30,26 @@
* @author Markus Kroetzsch
*
*/
public class PropertyIdValueImpl extends EntityIdValueImpl implements PropertyIdValue {
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);

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<positive integer>\"");
}
}

Expand Down
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 1f7ec00

Please sign in to comment.