You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/03/16 19:44:00 UTC
svn commit: r1082257 [3/4] - in /incubator/stanbol/trunk/entityhub: ./
generic/core/src/main/java/org/apache/stanbol/entityhub/core/impl/
generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/
generic/core/src/main/java/org/apache/stanbo...
Modified: incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/GeoNamesIndexer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/GeoNamesIndexer.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/GeoNamesIndexer.java (original)
+++ incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/GeoNamesIndexer.java Wed Mar 16 18:43:57 2011
@@ -33,6 +33,7 @@ import java.util.EnumMap;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -101,7 +102,7 @@ public class GeoNamesIndexer {
mappings.add(Properties.rdf_type.toString());
fieldMappings = mappings.toArray(new String[mappings.size()]);
}
- Logger log = LoggerFactory.getLogger(GeoNamesIndexer.class);
+ private static final Logger log = LoggerFactory.getLogger(GeoNamesIndexer.class);
private Yard yard;
private ValueFactory vf;
@@ -110,6 +111,7 @@ public class GeoNamesIndexer {
private int indexingChunkSize = 1000;
private File dataDir;
+ @SuppressWarnings("unused") //TODO implement indexing of Ontology
private File geonamesOntFile;
private File alternateNamesFile;
private File hierarchyFile;
@@ -117,9 +119,9 @@ public class GeoNamesIndexer {
private File countryInfoFile;
private final int countryGeonamesIdPos = 17;
private File geonamesArchiveFile;
- private final String geonamesOntBase = "http://www.geonames.org/ontology/";
+ //private final String geonamesOntBase = "http://www.geonames.org/ontology/";
private final String geonamesFeatureBase = "http://sws.geonames.org/";
- private final String geonamesCountryBase = "http://www.geonames.org/countries/";
+ //private final String geonamesCountryBase = "http://www.geonames.org/countries/";
//for date processing we use joda time!
private final Map<Integer,List<FeatureName>> featureNames = new TreeMap<Integer,List<FeatureName>>();
private final Map<String, Integer> adminCode2featureId = new TreeMap<String, Integer>();
@@ -233,7 +235,7 @@ public class GeoNamesIndexer {
skos_narrower(NamespaceEnum.skos.getNamespace(),"narrower"),
skos_related(NamespaceEnum.skos.getNamespace(),"related"),
;
- String uri;
+ private String uri;
Properties(String namespace,String name){
uri = namespace+name;
}
@@ -262,13 +264,13 @@ public class GeoNamesIndexer {
this.indexingChunkSize = chunkSize;
} //else use default value of 1000
log.info(" ... start indexing at position "+startPosition);
- Boolean indexOntology = (Boolean)config.get(KEY_INDEX_ONTOLOGY_STATE);
- if(indexOntology != null){
- this.indexOntology = indexOntology;
+ Boolean indexOntologyState = (Boolean)config.get(KEY_INDEX_ONTOLOGY_STATE);
+ if(indexOntologyState != null){
+ this.indexOntology = indexOntologyState;
} else {
this.indexOntology = false;
}
- log.info(" ... indexing geonames.org thesaurus="+indexOntology);
+ log.info(" ... indexing geonames.org thesaurus="+indexOntologyState);
this.dataDir = checkFile(KEY_DATA_DIR, config, "/data");
this.geonamesArchiveFile = checkFile(KEY_GEONAMES_ARCHIVE, dataDir, config,"allCountries.zip");
this.countryInfoFile = checkFile(KEY_COUNTRY_INFOS, dataDir,config,"countryInfo.txt");
@@ -396,7 +398,7 @@ public class GeoNamesIndexer {
}
} else {
//remove alternate labels from the inMemoryMap for the ID to save memory
- Integer id = new Integer(line.substring(0, line.indexOf('\t')));
+ Integer id = Integer.valueOf(line.substring(0, line.indexOf('\t')));
featureNames.remove(id);
}
}
@@ -430,23 +432,23 @@ public class GeoNamesIndexer {
}
private Representation importFeature(String line){
Tokenizer t = new Tokenizer(line);
- String id = t.nextElement();
+ String id = t.next();
Integer geoNamesId = Integer.parseInt(id);
//create a new Doc based on the first Element (geonamesID)
Representation doc = this.yard.getValueFactory().createRepresentation(String.format("%s%s/", geonamesFeatureBase,id));
//add the geonames:Feature type
doc.add(Properties.rdf_type.toString(), getDocRef(Properties.gn_Feature.toString()));
//add the UTF-8name
- String utf8Label = t.nextElement();
+ String utf8Label = t.next();
doc.addNaturalText(Properties.gn_name.toString(),utf8Label);
//add the ASKII Name as rdfs:label
- String askiiLabel = t.nextElement();
+ String askiiLabel = t.next();
if(utf8Label == null){
utf8Label = askiiLabel; //use ASKII label as fallback for the utf8 version
}
doc.addNaturalText(Properties.rdfs_label.toString(),utf8Label);
//alternate Names (alternate names also include Airport codes, postal codes and Wikipedia links!
- t.nextElement(); //consume this Element and use the alternateNames Map instead
+ t.next(); //consume this Element and use the alternateNames Map instead
List<FeatureName> alternateNames = featureNames.remove(geoNamesId); //use remove, because we need not need it a 2nd time!
if(alternateNames != null){
List<Text> altList = new ArrayList<Text>(alternateNames.size());
@@ -495,20 +497,20 @@ public class GeoNamesIndexer {
}
}
//lat
- doc.add(Properties.geo_lat.toString(),new BigDecimal(t.nextElement()));
+ doc.add(Properties.geo_lat.toString(),new BigDecimal(t.next()));
//lon
- doc.add(Properties.geo_long.toString(),new BigDecimal(t.nextElement()));
+ doc.add(Properties.geo_long.toString(),new BigDecimal(t.next()));
//featureClass
- String featureClass = String.format("%s%s",NamespaceEnum.geonames,t.nextElement());
+ String featureClass = String.format("%s%s",NamespaceEnum.geonames,t.next());
doc.add(Properties.gn_featureClass.toString(),getDocRef(featureClass));
//featureCode (-> need to use <featureClass>.<featureCode>!!)
- doc.add(Properties.gn_featureCode.toString(),getDocRef(String.format("%s.%s",featureClass,t.nextElement())));
+ doc.add(Properties.gn_featureCode.toString(),getDocRef(String.format("%s.%s",featureClass,t.next())));
//countryCode
// -> geonames uses here the link to an HTML Page showing the Country
// We would like to use an Link to a SKOS:Concept representing the Country
// ... But luckily here we need only to add the URI!
Set<String> ccs = new HashSet<String>();
- String countryCode = t.nextElement();
+ String countryCode = t.next();
if(countryCode != null){
countryCode = countryCode.trim(); //need to trim because some country codes use ' ' to indicate null!
if(countryCode.length() == 2){ //Yes there are some features that are in no country!
@@ -516,7 +518,7 @@ public class GeoNamesIndexer {
}
}
//alternate countryCodes
- String altCc = t.nextElement();
+ String altCc = t.next();
if(altCc != null){
StringTokenizer altCcT = new StringTokenizer(altCc,",");
while(altCcT.hasMoreElements()){
@@ -533,10 +535,10 @@ public class GeoNamesIndexer {
//first read them -> we need to consume the tokens anyway
String[] adminCodes = new String[] {
countryCode, //country
- t.nextElement(), //ADM1
- t.nextElement(), //ADM2
- t.nextElement(), //ADM3
- t.nextElement()};//ADM4
+ t.next(), //ADM1
+ t.next(), //ADM2
+ t.next(), //ADM3
+ t.next()};//ADM4
//Workaround for Admin1 -> add leading '0' for single Value
if(adminCodes[1] != null && adminCodes[1].length() < 2){
adminCodes[1] = '0'+adminCodes[1];
@@ -544,7 +546,7 @@ public class GeoNamesIndexer {
addParents(doc,geoNamesId,adminCodes);
//population
- String populationString = t.nextElement();
+ String populationString = t.next();
if(populationString != null){
//NOTE: we need to used Long, because of Asia (3.800.000)
Long population = new Long(populationString);
@@ -553,20 +555,20 @@ public class GeoNamesIndexer {
}
}
//elevation
- String latString = t.nextElement();
- if(latString == null){
- latString = t.nextElement(); //if no elevation than use the gtopo30
+ String altString = t.next();
+ if(altString == null){
+ altString = t.next(); //if no elevation than use the gtopo30
} else {
- t.nextElement(); //if there is already en elevation, than consume these entry
+ t.next(); //if there is already en elevation, than consume these entry
}
- Integer alt = new Integer(latString);
+ Integer alt = Integer.valueOf(altString);
if(alt.intValue() > -9999){ //it looks like that -9999 is sometimes used as not known!
doc.add(Properties.geo_alt.toString(),alt);
}
//time zone
- t.nextElement(); //not used
+ t.next(); //not used
//mod-date
- String modDateString = t.nextElement();
+ String modDateString = t.next();
if(modDateString != null){
try {
doc.add(Properties.dc_date.toString(),TimeUtils.toDate(DataTypeEnum.DateTime, modDateString));
@@ -696,13 +698,13 @@ public class GeoNamesIndexer {
String code = null;
Integer geonamesId = null;
int i=1;
- for(;t.hasMoreElements();i++){
- String actToken = t.nextElement();
+ for(;t.hasNext();i++){
+ String actToken = t.next();
if(i==1){
code = actToken;
}
if(i==countryGeonamesIdPos){
- geonamesId = new Integer(actToken);
+ geonamesId = Integer.valueOf(actToken);
break;
}
}
@@ -742,7 +744,7 @@ public class GeoNamesIndexer {
lineCount++;
//no tokenizer this time ... need only first and last column!
String code = line.substring(0, line.indexOf('\t'));
- Integer geonamesId = new Integer(line.substring(line.lastIndexOf('\t')+1));
+ Integer geonamesId = Integer.valueOf(line.substring(line.lastIndexOf('\t')+1));
adminCode2featureId.put(code, geonamesId);
}
}
@@ -875,11 +877,11 @@ public class GeoNamesIndexer {
while((line = reader.readLine()) != null){
lineCount++;
Tokenizer t = new Tokenizer(line);
- Integer parent = new Integer(t.nextElement());
- Integer child = new Integer(t.nextElement());
+ Integer parent = Integer.valueOf(t.next());
+ Integer child = Integer.valueOf(t.next());
String type;
- if(t.hasMoreElements()){
- type = t.nextElement();
+ if(t.hasNext()){
+ type = t.next();
} else {
type = null;
}
@@ -964,34 +966,34 @@ public class GeoNamesIndexer {
private final static String TRUE = "1";
protected FeatureName(String line){
Tokenizer t = new Tokenizer(line);
- labelID = Integer.parseInt(t.nextElement()); //first Elem the labelID
- geonameID = Integer.parseInt(t.nextElement());
- String lang = t.nextElement();
- if(lang != null && (lang.length() == 2 || lang.length() == 3)){
- this.lang = lang;
+ labelID = Integer.parseInt(t.next()); //first Elem the labelID
+ geonameID = Integer.parseInt(t.next());
+ String language = t.next();
+ if(language != null && (language.length() == 2 || language.length() == 3)){
+ this.lang = language;
} else {
this.lang = null; //no valied lang Code
}
- if(lang == null || lang.length()<=3){
+ if(language == null || language.length()<=3){
type = NameType.naturalLanguage;
- } else if("post".equals(lang)){
+ } else if("post".equals(language)){
type = NameType.postal;
- } else if("link".equals(lang)) {
+ } else if("link".equals(language)) {
type = NameType.link;
- } else if("abbr".equals(lang)) {
+ } else if("abbr".equals(language)) {
type = NameType.abbreviation;
- } else if("iata".equals(lang) || "icao".equals(lang) || "faac".equals(lang)){
+ } else if("iata".equals(language) || "icao".equals(language) || "faac".equals(language)){
type = NameType.airportCode;
} else {
type = NameType.unknown; // e.g. fr_1793 for French Revolution names
}
- name = t.nextElement();
+ name = t.next();
if(name == null){
throw new IllegalStateException(" Unable to parse name from line:" + line);
}
- String act = t.nextElement();
+ String act = t.next();
this.preferred = act != null && act.equals(TRUE);
- act = t.nextElement();
+ act = t.next();
this.shortName = act != null && act.equals(TRUE);
}
public final Integer getGeonameID() {
@@ -1017,9 +1019,7 @@ public class GeoNamesIndexer {
}
@Override
public final boolean equals(Object obj) {
- return obj != null &&
- obj instanceof FeatureName &&
- ((FeatureName)obj).labelID == labelID;
+ return obj instanceof FeatureName && ((FeatureName)obj).labelID == labelID;
}
@Override
public final int hashCode() {
@@ -1029,20 +1029,20 @@ public class GeoNamesIndexer {
return name+(lang!=null?('@'+lang):"");
}
}
- public static class Tokenizer implements Enumeration<String>{
+ public static class Tokenizer implements Iterator<String>{
private static final String DELIM ="\t";
private final StringTokenizer t;
- boolean prevElementWasNull = true;
+ private boolean prevElementWasNull = true;
public Tokenizer(String data){
t = new StringTokenizer(data, DELIM, true);
}
@Override
- public boolean hasMoreElements() {
+ public boolean hasNext() {
return t.hasMoreTokens();
}
@Override
- public String nextElement() {
+ public String next() {
if(!prevElementWasNull){
t.nextElement();//dump the delim
}
@@ -1063,5 +1063,9 @@ public class GeoNamesIndexer {
}
}
}
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
}
}
Modified: incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/cli/CommandLineRunner.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/cli/CommandLineRunner.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/cli/CommandLineRunner.java (original)
+++ incubator/stanbol/trunk/entityhub/indexing/geonames/src/main/java/org/apache/stanbol/entityhub/indexing/geonames/cli/CommandLineRunner.java Wed Mar 16 18:43:57 2011
@@ -25,7 +25,6 @@ import static org.apache.stanbol.entityh
import static org.apache.stanbol.entityhub.indexing.geonames.GeoNamesIndexer.KEY_YARD;
import java.io.IOException;
-import java.net.URL;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -43,7 +42,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class CommandLineRunner {
+public final class CommandLineRunner {
+ private CommandLineRunner(){}
protected static final Logger log = LoggerFactory.getLogger(CommandLineRunner.class);
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpoint.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpoint.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpoint.java Wed Mar 16 18:43:57 2011
@@ -67,20 +67,20 @@ public class JerseyEndpoint {
//public static final String FREEMARKER_TEMPLATE_CLASSPATH_PROPERTY = "org.apache.stanbol.entityhub.jersey.templates.classpath";
@Reference
- TcManager tcManager;
+ private TcManager tcManager;
@Reference
- Entityhub entityhub;
+ private Entityhub entityhub;
@Reference
- ReferencedSiteManager referencedSiteManager;
+ private ReferencedSiteManager referencedSiteManager;
@Reference
- HttpService httpService;
+ private HttpService httpService;
@Reference
- Serializer serializer;
+ private Serializer serializer;
protected ServletContext servletContext;
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpointApplication.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpointApplication.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpointApplication.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/JerseyEndpointApplication.java Wed Mar 16 18:43:57 2011
@@ -21,11 +21,11 @@ import java.util.Set;
import javax.ws.rs.core.Application;
-import org.apache.stanbol.entityhub.jersey.resource.ReferencedSiteRootResource;
import org.apache.stanbol.entityhub.jersey.resource.EntityMappingResource;
import org.apache.stanbol.entityhub.jersey.resource.EntityhubRootResource;
-import org.apache.stanbol.entityhub.jersey.resource.SymbolResource;
+import org.apache.stanbol.entityhub.jersey.resource.ReferencedSiteRootResource;
import org.apache.stanbol.entityhub.jersey.resource.SiteManagerRootResource;
+import org.apache.stanbol.entityhub.jersey.resource.SymbolResource;
import org.apache.stanbol.entityhub.jersey.writers.JettisonWriter;
import org.apache.stanbol.entityhub.jersey.writers.QueryResultListWriter;
import org.apache.stanbol.entityhub.jersey.writers.SignWriter;
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
*/
public class JerseyEndpointApplication extends Application {
- Logger log = LoggerFactory.getLogger(getClass());
+ private static Logger log = LoggerFactory.getLogger(JerseyEndpointApplication.class);
public JerseyEndpointApplication() {
log.info("JerseyEndpointApplication instanceiated");
}
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/parsers/JSONToFieldQuery.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/parsers/JSONToFieldQuery.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/parsers/JSONToFieldQuery.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/parsers/JSONToFieldQuery.java Wed Mar 16 18:43:57 2011
@@ -40,12 +40,14 @@ import org.slf4j.LoggerFactory;
* @author Rupert Westenthaler
*
*/
-public class JSONToFieldQuery {
+public final class JSONToFieldQuery {
+ private JSONToFieldQuery(){}
+
private static final Logger log = LoggerFactory.getLogger(JSONToFieldQuery.class);
public static FieldQuery fromJSON(FieldQueryFactory queryFactory, String jsonQueryString) throws JSONException{
if(jsonQueryString == null){
- throw new NullPointerException("The parsed JSON object MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed JSON object MUST NOT be NULL!");
}
JSONObject jQuery = new JSONObject(jsonQueryString);
FieldQuery query = queryFactory.createFieldQuery();
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityMappingResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityMappingResource.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityMappingResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityMappingResource.java Wed Mar 16 18:43:57 2011
@@ -40,9 +40,6 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.stanbol.entityhub.core.query.QueryResultListImpl;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
import org.apache.stanbol.entityhub.servicesapi.Entityhub;
@@ -74,20 +71,12 @@ public class EntityMappingResource exten
private final Logger log = LoggerFactory.getLogger(getClass());
- protected Entityhub entityhub;
-
- protected TcManager tcManager;
-
- protected Serializer serializer;
-
- protected TripleCollection entityCache;
+ private Entityhub entityhub;
// bind the job manager by looking it up from the servlet request context
public EntityMappingResource(@Context ServletContext context) {
super();
entityhub = (Entityhub) context.getAttribute(Entityhub.class.getName());
- tcManager = (TcManager) context.getAttribute(TcManager.class.getName());
- serializer = (Serializer) context.getAttribute(Serializer.class.getName());
}
@GET
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/NavigationMixin.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/NavigationMixin.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/NavigationMixin.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/NavigationMixin.java Wed Mar 16 18:43:57 2011
@@ -42,7 +42,7 @@ public class NavigationMixin {
}
@Context
- protected UriInfo uriInfo;
+ private UriInfo uriInfo;
public URI getPublicBaseUri() {
return uriInfo.getBaseUri();
@@ -61,11 +61,11 @@ public class NavigationMixin {
cssClass = uriInfo.getPath().startsWith(link.substring(1)) ? "selected" : "unselected";
}
- protected final String label;
+ private final String label;
- protected final String link;
+ private final String link;
- protected final String cssClass;
+ private final String cssClass;
public String getLabel() {
return label;
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java Wed Mar 16 18:43:57 2011
@@ -21,7 +21,6 @@ import static javax.ws.rs.core.MediaType
import java.io.File;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
@@ -41,13 +40,11 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
import org.apache.clerezza.rdf.ontologies.RDFS;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
import org.apache.stanbol.entityhub.servicesapi.model.Sign;
import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery;
-import org.apache.stanbol.entityhub.servicesapi.site.ConfiguredSite;
import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSite;
import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteException;
import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
@@ -77,21 +74,21 @@ public class ReferencedSiteRootResource
/**
* The Field used as default as selected fields for find requests
* TODO: Make configurable via the {@link ConfiguredSite} interface!
+ * NOTE: This feature is deactivated, because OPTIONAL selects do have very
+ * weak performance when using SPARQL endpoints
*/
- private static final Collection<String> DEFAULT_FIND_SELECTED_FIELDS = Arrays.asList(RDFS.comment.getUnicodeString());
+// private static final Collection<String> DEFAULT_FIND_SELECTED_FIELDS = Arrays.asList(RDFS.comment.getUnicodeString());
/**
* The default number of maximal results.
*/
private static final int DEFAULT_FIND_RESULT_LIMIT = 5;
- protected Serializer serializer;
- protected ReferencedSite site;
+ private ReferencedSite site;
public ReferencedSiteRootResource(@Context ServletContext context, @PathParam(value = "site") String siteId) {
super();
log.info("... init ReferencedSiteRootResource for Site {}", siteId);
ReferencedSiteManager referencedSiteManager = (ReferencedSiteManager) context.getAttribute(ReferencedSiteManager.class.getName());
- serializer = (Serializer) context.getAttribute(Serializer.class.getName());
if (referencedSiteManager == null) {
log.error("Missing referencedSiteManager={}", referencedSiteManager);
throw new WebApplicationException(Response.Status.NOT_FOUND);
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java Wed Mar 16 18:43:57 2011
@@ -50,7 +50,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.clerezza.rdf.ontologies.RDFS;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
import org.apache.stanbol.entityhub.servicesapi.model.Sign;
@@ -85,15 +84,12 @@ public class SiteManagerRootResource ext
*/
private static final int DEFAULT_FIND_RESULT_LIMIT = 5;
- protected Serializer serializer;
-
private ReferencedSiteManager referencedSiteManager;
public SiteManagerRootResource(@Context ServletContext context) {
super();
log.info("... init SiteManagerRootResource");
referencedSiteManager = (ReferencedSiteManager) context.getAttribute(ReferencedSiteManager.class.getName());
- serializer = (Serializer) context.getAttribute(Serializer.class.getName());
if (referencedSiteManager == null) {
log.error("Missing referencedSiteManager={}", referencedSiteManager);
throw new WebApplicationException(NOT_FOUND);
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SymbolResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SymbolResource.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SymbolResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SymbolResource.java Wed Mar 16 18:43:57 2011
@@ -50,9 +50,6 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
import org.apache.stanbol.entityhub.servicesapi.Entityhub;
import org.apache.stanbol.entityhub.servicesapi.EntityhubException;
@@ -87,20 +84,12 @@ public class SymbolResource extends Navi
private final Logger log = LoggerFactory.getLogger(getClass());
- protected Entityhub entityhub;
-
- protected TcManager tcManager;
-
- protected Serializer serializer;
-
- protected TripleCollection entityCache;
+ private Entityhub entityhub;
// bind the job manager by looking it up from the servlet request context
public SymbolResource(@Context ServletContext context) {
super();
entityhub = (Entityhub) context.getAttribute(Entityhub.class.getName());
- tcManager = (TcManager) context.getAttribute(TcManager.class.getName());
- serializer = (Serializer) context.getAttribute(Serializer.class.getName());
}
@GET
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/JettisonWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/JettisonWriter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/JettisonWriter.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/JettisonWriter.java Wed Mar 16 18:43:57 2011
@@ -44,7 +44,7 @@ public class JettisonWriter implements M
}
@Override
- public void writeTo(Object value, Class<?> __doNotUse, Type genericType,
+ public void writeTo(Object value, Class<?> doNotUse, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/QueryResultListWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/QueryResultListWriter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/QueryResultListWriter.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/QueryResultListWriter.java Wed Mar 16 18:43:57 2011
@@ -44,8 +44,6 @@ import org.apache.clerezza.rdf.core.seri
import org.apache.commons.io.IOUtils;
import org.apache.stanbol.entityhub.servicesapi.query.QueryResultList;
import org.codehaus.jettison.json.JSONException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* TODO: Replace with Serializer infrastructure similar to {@link Serializer}
@@ -54,9 +52,9 @@ import org.slf4j.LoggerFactory;
@Produces({APPLICATION_JSON, N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE, RDF_JSON})
public class QueryResultListWriter implements MessageBodyWriter<QueryResultList<?>> {
- private final Logger log = LoggerFactory.getLogger(QueryResultListWriter.class);
+// private final Logger log = LoggerFactory.getLogger(QueryResultListWriter.class);
@Context
- protected ServletContext servletContext;
+ private ServletContext servletContext;
protected Serializer getSerializer() {
return (Serializer) servletContext.getAttribute(Serializer.class.getName());
@@ -69,33 +67,14 @@ public class QueryResultListWriter imple
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- //TODO: The type is also parsed as genericType ... so we can only check
- //for the type :(
return QueryResultList.class.isAssignableFrom(type);
-// if(QueryResultList.class.isAssignableFrom(type) &&
-// genericType != null && //QueryResult is always a generic Type
-// genericType instanceof Class<?>){ //and such types do not use generics
-// //This writer supports String, Representation and all types of Signs
-// Class<?> genericClass = (Class<?>) genericType;
-//
-// if(String.class.isAssignableFrom(genericClass) ||
-// Representation.class.isAssignableFrom(genericClass) ||
-// Sign.class.isAssignableFrom(genericClass)){
-// //maybe we need further checks if we do not support all data types
-// //for all generic types! But currently all different types of
-// //QueryResultList support all the different MediaTypes!
-// return true;
-// }
-// }
-// log.info("Request for not writeable combination: type="+type+"|genericType="+genericType+"|mediaType="+mediaType);
-// return false;
}
@Override
- public void writeTo(QueryResultList<?> resultList, Class<?> __doNotUse, Type genericType,
+ public void writeTo(QueryResultList<?> resultList, Class<?> doNotUse, Type genericType,
Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
- Class<?> genericClass = (Class<?>) genericType;
+// Class<?> genericClass = (Class<?>) genericType;
if (APPLICATION_JSON.equals(mediaType.toString())) {
try {
IOUtils.write(QueryResultsToJSON.toJSON(resultList).toString(4), entityStream,"UTF-8");
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignToRDF.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignToRDF.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignToRDF.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignToRDF.java Wed Mar 16 18:43:57 2011
@@ -35,13 +35,13 @@ import org.apache.stanbol.entityhub.serv
final class SignToRDF {
private SignToRDF() { /* do not create instances of utility classes */}
- static UriRef signRepresentation = new UriRef(RdfResourceEnum.signRepresentation.getUri());
- static UriRef signSite = new UriRef(RdfResourceEnum.signSite.getUri());
- static UriRef sign = new UriRef(RdfResourceEnum.Sign.getUri());
- static UriRef entityMapping = new UriRef(RdfResourceEnum.EntityMapping.getUri());
- static UriRef symbol = new UriRef(RdfResourceEnum.Symbol.getUri());
- static RdfValueFactory valueFactory = RdfValueFactory.getInstance();
- static LiteralFactory literalFactory = LiteralFactory.getInstance();
+ private static UriRef signRepresentation = new UriRef(RdfResourceEnum.signRepresentation.getUri());
+ private static UriRef signSite = new UriRef(RdfResourceEnum.signSite.getUri());
+ private static UriRef sign = new UriRef(RdfResourceEnum.Sign.getUri());
+ private static UriRef entityMapping = new UriRef(RdfResourceEnum.EntityMapping.getUri());
+ private static UriRef symbol = new UriRef(RdfResourceEnum.Symbol.getUri());
+ private static RdfValueFactory valueFactory = RdfValueFactory.getInstance();
+ private static LiteralFactory literalFactory = LiteralFactory.getInstance();
static MGraph toRDF(Representation representation) {
MGraph graph = new SimpleMGraph();
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignWriter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignWriter.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/writers/SignWriter.java Wed Mar 16 18:43:57 2011
@@ -70,13 +70,13 @@ public class SignWriter implements Messa
supportedMediaTypes = Collections.unmodifiableSet(types);
}
@Context
- protected ServletContext servletContext;
+ private ServletContext servletContext;
protected Serializer getSerializer() {
return (Serializer) servletContext.getAttribute(Serializer.class.getName());
}
@Override
- public long getSize(Sign Sign, Class<?> type, Type genericType,
+ public long getSize(Sign sign, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return -1; //to hard to calculate
}
Modified: incubator/stanbol/trunk/entityhub/launchers/sling/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/launchers/sling/src/main/bundles/list.xml?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/launchers/sling/src/main/bundles/list.xml (original)
+++ incubator/stanbol/trunk/entityhub/launchers/sling/src/main/bundles/list.xml Wed Mar 16 18:43:57 2011
@@ -109,12 +109,11 @@
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</bundle>
- <!-- TODO: currently embedded in linkedData Bundle because of error
<bundle>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20090211</version>
- </bundle> -->
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.2</version>
+ </bundle>
</startLevel>
<!-- RICK infrastructure and required libraries-->
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/pom.xml?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/pom.xml Wed Mar 16 18:43:57 2011
@@ -58,7 +58,6 @@
<instructions>
<Export-Package>
org.apache.stanbol.entityhub.model.clerezza;version=${pom.version},
- org.apache.stanbol.entityhub.model.clerezza.utils;version=${pom.version},
</Export-Package>
<Private-Package>
org.apache.stanbol.entityhub.model.clerezza.impl;version=${pom.version}
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfReference.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfReference.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfReference.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfReference.java Wed Mar 16 18:43:57 2011
@@ -23,7 +23,7 @@ public class RdfReference implements Ref
private final UriRef uri;
protected RdfReference(String reference){
if(reference == null){
- throw new NullPointerException("The parsed Reference MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Reference MUST NOT be NULL!");
} else if(reference.isEmpty()){
throw new IllegalArgumentException("The parsed Reference MUST NOT be Empty!");
} else {
@@ -32,7 +32,7 @@ public class RdfReference implements Ref
}
protected RdfReference(UriRef uri){
if(uri == null){
- throw new NullPointerException("The parsed Reference MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Reference MUST NOT be NULL!");
} else if(uri.getUnicodeString().isEmpty()){
throw new IllegalArgumentException("The parsed Reference MUST NOT be represent an empty string!");
} else {
@@ -56,7 +56,7 @@ public class RdfReference implements Ref
}
@Override
public boolean equals(Object obj) {
- return obj != null &&obj instanceof Reference && uri.getUnicodeString().equals(((Reference)obj).getReference());
+ return obj instanceof Reference && uri.getUnicodeString().equals(((Reference)obj).getReference());
}
@Override
public String toString() {
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java Wed Mar 16 18:43:57 2011
@@ -35,10 +35,10 @@ import org.apache.stanbol.entityhub.core
import org.apache.stanbol.entityhub.model.clerezza.impl.Literal2TextAdapter;
import org.apache.stanbol.entityhub.model.clerezza.impl.LiteralAdapter;
import org.apache.stanbol.entityhub.model.clerezza.impl.NaturalTextFilter;
+import org.apache.stanbol.entityhub.model.clerezza.impl.Resource2StringAdapter;
import org.apache.stanbol.entityhub.model.clerezza.impl.Resource2ValueAdapter;
import org.apache.stanbol.entityhub.model.clerezza.impl.UriRef2ReferenceAdapter;
import org.apache.stanbol.entityhub.model.clerezza.impl.UriRefAdapter;
-import org.apache.stanbol.entityhub.model.clerezza.utils.Resource2StringAdapter;
import org.apache.stanbol.entityhub.servicesapi.model.Reference;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.model.Text;
@@ -82,7 +82,7 @@ public class RdfRepresentation implement
@Override
public void add(String field, Object value) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -128,7 +128,7 @@ public class RdfRepresentation implement
@Override
public void addReference(String field, String reference) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -142,7 +142,7 @@ public class RdfRepresentation implement
@Override
public void addNaturalText(String field, String text, String...languages) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -164,7 +164,7 @@ public class RdfRepresentation implement
@Override
public <T> Iterator<T> get(String field, final Class<T> type) throws UnsupportedTypeException {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -206,7 +206,7 @@ public class RdfRepresentation implement
@Override
public Iterator<Reference> getReferences(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -218,7 +218,7 @@ public class RdfRepresentation implement
@Override
public Iterator<Text> getText(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -231,7 +231,7 @@ public class RdfRepresentation implement
@Override
public Iterator<Object> get(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -242,7 +242,7 @@ public class RdfRepresentation implement
@Override
public Iterator<Text> get(String field, String...languages) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -261,7 +261,7 @@ public class RdfRepresentation implement
@Override
public <T> T getFirst(String field, Class<T> type) throws UnsupportedTypeException {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -276,7 +276,7 @@ public class RdfRepresentation implement
@Override
public Object getFirst(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -290,7 +290,7 @@ public class RdfRepresentation implement
@Override
public Reference getFirstReference(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -300,7 +300,7 @@ public class RdfRepresentation implement
@Override
public Text getFirst(String field, String...languages) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -331,7 +331,7 @@ public class RdfRepresentation implement
@Override
public void remove(String field, Object parsedValue) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -367,7 +367,7 @@ public class RdfRepresentation implement
@Override
public void removeReference(String field, String reference) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -390,7 +390,7 @@ public class RdfRepresentation implement
@Override
public void removeNaturalText(String field, String value, String... languages) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -414,7 +414,7 @@ public class RdfRepresentation implement
@Override
public void removeAll(String field) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -423,7 +423,7 @@ public class RdfRepresentation implement
@Override
public void removeAllNaturalText(String field, String... languages) {
if(field == null){
- throw new NullPointerException("The parsed field MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
@@ -478,7 +478,7 @@ public class RdfRepresentation implement
}
@Override
public boolean equals(Object obj) {
- return obj != null && obj instanceof Representation && ((Representation)obj).getId().equals(getId());
+ return obj instanceof Representation && ((Representation)obj).getId().equals(getId());
}
}
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java Wed Mar 16 18:43:57 2011
@@ -37,15 +37,13 @@ import org.apache.clerezza.rdf.core.UriR
import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
import org.apache.clerezza.rdf.core.impl.SimpleLiteralFactory;
import org.apache.stanbol.entityhub.servicesapi.defaults.DataTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Utilities to create {@link Resource} instances for Java Objects.
* @author Rupert Westenthaler
*
*/
-public class RdfResourceUtils {
+public final class RdfResourceUtils {
private RdfResourceUtils(){/*do not create instances of Util Classes*/}
/**
@@ -136,7 +134,7 @@ public class RdfResourceUtils {
JAVA_OBJECT_XSD_DATATYPE_MAPPING = Collections.unmodifiableMap(objectMappings);
}
- private static final Logger log = LoggerFactory.getLogger(RdfResourceUtils.class);
+// private static final Logger log = LoggerFactory.getLogger(RdfResourceUtils.class);
private static final LiteralFactory literalFactory = LiteralFactory.getInstance();
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java Wed Mar 16 18:43:57 2011
@@ -28,7 +28,7 @@ public class RdfText implements Text, Cl
protected RdfText(String text, String lang) {
if(text == null){
- throw new NullPointerException("The parsed text MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed text MUST NOT be NULL");
} else if(text.isEmpty()){
throw new IllegalArgumentException("Tha parsed Text MUST NOT be empty!");
}
@@ -61,7 +61,7 @@ public class RdfText implements Text, Cl
}
@Override
- public Object clone() {
+ public RdfText clone() {
Language language = isPlain ? ((PlainLiteral) literal).getLanguage() : null;
return new RdfText(new PlainLiteralImpl(literal.getLexicalForm(), language));
}
@@ -73,7 +73,7 @@ public class RdfText implements Text, Cl
@Override
public boolean equals(Object obj) {
- if (obj != null && obj instanceof Text && ((Text) obj).getText().equals(getText())) {
+ if (obj instanceof Text && ((Text) obj).getText().equals(getText())) {
return (getLanguage() == null && ((Text) obj).getLanguage() == null)
|| (getLanguage() != null && getLanguage().equals(((Text) obj).getLanguage()));
} else {
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java Wed Mar 16 18:43:57 2011
@@ -33,7 +33,7 @@ import org.apache.stanbol.entityhub.serv
* @author Rupert Westenthaler
*
*/
-public class RdfValueFactory implements ValueFactory {
+public final class RdfValueFactory implements ValueFactory {
private static RdfValueFactory instance;
/**
@@ -55,7 +55,7 @@ public class RdfValueFactory implements
@Override
public RdfReference createReference(Object value) {
if (value == null) {
- throw new NullPointerException("The parsed value MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed value MUST NOT be NULL");
} else if (value instanceof UriRef) {
return new RdfReference((UriRef) value);
} else {
@@ -66,7 +66,7 @@ public class RdfValueFactory implements
@Override
public RdfText createText(Object value) {
if (value == null) {
- throw new NullPointerException("The parsed value MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed value MUST NOT be NULL");
} else if (value instanceof Literal) {
return new RdfText((Literal) value);
} else {
@@ -82,7 +82,7 @@ public class RdfValueFactory implements
@Override
public RdfRepresentation createRepresentation(String id) {
if (id == null){
- throw new NullPointerException("The parsed id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed id MUST NOT be NULL!");
} else if(id.isEmpty()){
throw new IllegalArgumentException("The parsed id MUST NOT be empty!");
} else {
@@ -102,10 +102,10 @@ public class RdfValueFactory implements
*/
public RdfRepresentation createRdfRepresentation(UriRef node, TripleCollection graph) {
if (node == null) {
- throw new NullPointerException("The parsed id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed id MUST NOT be NULL!");
}
if(graph == null){
- throw new NullPointerException("The parsed graph MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed graph MUST NOT be NULL!");
}
return new RdfRepresentation(node, graph);
}
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java Wed Mar 16 18:43:57 2011
@@ -60,9 +60,9 @@ public class Literal2TextAdapter<T exten
/**
* Unmodifiable set of the active languages
*/
- protected final Set<String> languages;
+ private final Set<String> languages;
private final boolean containsNull;
- protected final RdfValueFactory valueFactory = RdfValueFactory.getInstance();
+ private final RdfValueFactory valueFactory = RdfValueFactory.getInstance();
/**
* Filters Literals in the parsed Iterator based on the parsed languages and
@@ -84,7 +84,7 @@ public class Literal2TextAdapter<T exten
}
@Override
- public Text adapt(T value, Class<Text> type) {
+ public final Text adapt(T value, Class<Text> type) {
if(value instanceof PlainLiteral){
String literalLang = ((PlainLiteral) value).getLanguage() == null ?
null : ((PlainLiteral) value).getLanguage().toString();
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java Wed Mar 16 18:43:57 2011
@@ -48,14 +48,14 @@ import org.slf4j.LoggerFactory;
*/
public class LiteralAdapter<T extends Literal,A> implements Adapter<T, A> {
- static Logger log = LoggerFactory.getLogger(LiteralAdapter.class);
+ private static Logger log = LoggerFactory.getLogger(LiteralAdapter.class);
- LiteralFactory lf = LiteralFactory.getInstance();
- RdfValueFactory valueFactory = RdfValueFactory.getInstance();
+ private LiteralFactory lf = LiteralFactory.getInstance();
+ private RdfValueFactory valueFactory = RdfValueFactory.getInstance();
@SuppressWarnings("unchecked")
@Override
- public A adapt(T value, Class<A> type) {
+ public final A adapt(T value, Class<A> type) {
// NOTE: (Rupert Westenthaler 12.01.2011)
// Converting everything to String is not an intended functionality. When
// someone parsed String.class he rather assumes that he gets only string
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java Wed Mar 16 18:43:57 2011
@@ -50,13 +50,13 @@ import org.slf4j.LoggerFactory;
*
*/
public class NaturalTextFilter implements Filter<Literal> {
- Logger log = LoggerFactory.getLogger(NaturalTextFilter.class);
+ private Logger log = LoggerFactory.getLogger(NaturalTextFilter.class);
/**
* The xsd:string data type constant used for TypedLiterals to check if the
* represent an string value!
*/
private static UriRef xsdString = new UriRef(DataTypeEnum.String.getUri());
- protected final Set<String> languages;
+ private final Set<String> languages;
private final boolean containsNull;
public NaturalTextFilter(String...languages){
@@ -77,7 +77,7 @@ public class NaturalTextFilter implement
}
}
@Override
- public boolean isValid(Literal value) {
+ public final boolean isValid(Literal value) {
if (value instanceof PlainLiteral){
if(languages == null) { //no language restrictions
return true; //return any Plain Literal
Copied: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java (from r1074432, incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java?p2=incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java&p1=incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java&r1=1074432&r2=1082257&rev=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java Wed Mar 16 18:43:57 2011
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.stanbol.entityhub.model.clerezza.utils;
+package org.apache.stanbol.entityhub.model.clerezza.impl;
import org.apache.clerezza.rdf.core.Literal;
import org.apache.clerezza.rdf.core.Resource;
@@ -32,7 +32,7 @@ import org.apache.stanbol.entityhub.core
public class Resource2StringAdapter<T extends Resource> implements Adapter<T, String> {
@Override
- public String adapt(T value, Class<String> type) {
+ public final String adapt(T value, Class<String> type) {
if (value == null) {
return null;
} else if (value instanceof UriRef) {
Propchange: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2StringAdapter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java Wed Mar 16 18:43:57 2011
@@ -39,15 +39,15 @@ import org.slf4j.LoggerFactory;
*/
public class Resource2ValueAdapter<T extends Resource> implements Adapter<T, Object> {
- Logger log = LoggerFactory.getLogger(Resource2ValueAdapter.class);
+ private static Logger log = LoggerFactory.getLogger(Resource2ValueAdapter.class);
- protected final LiteralFactory literalFactory = LiteralFactory.getInstance();
+ private final LiteralFactory literalFactory = LiteralFactory.getInstance();
- RdfValueFactory valueFactory = RdfValueFactory.getInstance();
+ private RdfValueFactory valueFactory = RdfValueFactory.getInstance();
@Override
- public Object adapt(T value, Class<Object> type) {
+ public final Object adapt(T value, Class<Object> type) {
if(value instanceof UriRef){
return valueFactory.createReference((UriRef)value);
} else if(value instanceof PlainLiteral){
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java Wed Mar 16 18:43:57 2011
@@ -33,7 +33,7 @@ public class UriRef2ReferenceAdapter imp
private final RdfValueFactory valueFactory = RdfValueFactory.getInstance();
@Override
- public Reference adapt(UriRef value, Class<Reference> type) {
+ public final Reference adapt(UriRef value, Class<Reference> type) {
return valueFactory.createReference(value);
}
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java Wed Mar 16 18:43:57 2011
@@ -29,11 +29,11 @@ import org.slf4j.LoggerFactory;
public class UriRefAdapter<A> implements Adapter<UriRef, A> {
- static Logger log = LoggerFactory.getLogger(UriRefAdapter.class);
+ private static Logger log = LoggerFactory.getLogger(UriRefAdapter.class);
@SuppressWarnings("unchecked")
@Override
- public A adapt(UriRef value, Class<A> type) {
+ public final A adapt(UriRef value, Class<A> type) {
if(type.equals(URI.class)){
try {
return (A) new URI(value.getUnicodeString());
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java Wed Mar 16 18:43:57 2011
@@ -33,8 +33,6 @@ import org.apache.clerezza.rdf.core.Lite
import org.apache.clerezza.rdf.core.PlainLiteral;
import org.apache.clerezza.rdf.core.TypedLiteral;
import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation;
-import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.model.Text;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
Modified: incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java (original)
+++ incubator/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java Wed Mar 16 18:43:57 2011
@@ -18,7 +18,6 @@ package org.apache.stanbol.entityhub.mod
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
import org.apache.stanbol.entityhub.test.model.ValueFactoryTest;
import org.junit.Before;
@@ -48,12 +47,12 @@ public class RdfValueFactoryTest extends
protected ValueFactory getValueFactory() {
return valueFactory;
}
- @Test(expected=NullPointerException.class)
+ @Test(expected=IllegalArgumentException.class)
public void testNullNodeRepresentation() {
SimpleMGraph graph = new SimpleMGraph();
valueFactory.createRdfRepresentation(null, graph);
}
- @Test(expected=NullPointerException.class)
+ @Test(expected=IllegalArgumentException.class)
public void testNullGraphRepresentation() {
UriRef rootNode = new UriRef("urn:test.rootNode");
valueFactory.createRdfRepresentation(rootNode, null);
Modified: incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java (original)
+++ incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java Wed Mar 16 18:43:57 2011
@@ -49,24 +49,24 @@ public class RdfQueryResultList implemen
SparqlQueryUtils.parseQueryResultsFromMGraph(resultGraph)));
}
@Override
- public FieldQuery getQuery() {
+ public final FieldQuery getQuery() {
return query;
}
@Override
- public Set<String> getSelectedFields() {
+ public final Set<String> getSelectedFields() {
return query.getSelectedFields();
}
@Override
- public boolean isEmpty() {
+ public final boolean isEmpty() {
return results.isEmpty();
}
@Override
- public Iterator<Representation> iterator() {
+ public final Iterator<Representation> iterator() {
return new Iterator<Representation>() {
- Iterator<RdfRepresentation> it = results.iterator();
+ private Iterator<RdfRepresentation> it = results.iterator();
@Override
public boolean hasNext() { return it.hasNext(); }
@Override
@@ -77,18 +77,18 @@ public class RdfQueryResultList implemen
}
@Override
- public int size() {
+ public final int size() {
return results.size();
}
/**
* Getter for the RDF Graph holding the Results of the Query
* @return the RDF Graph with the Results
*/
- public MGraph getResultGraph() {
+ public final MGraph getResultGraph() {
return resultGraph;
}
@Override
- public Class<Representation> getType() {
+ public final Class<Representation> getType() {
return Representation.class;
}
Modified: incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlFieldQuery.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlFieldQuery.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlFieldQuery.java (original)
+++ incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlFieldQuery.java Wed Mar 16 18:43:57 2011
@@ -37,9 +37,9 @@ public class SparqlFieldQuery extends Fi
private static final String FIELD_VAR_PREFIX = "v_";
private static final String ROOT_VAR_NAME = "id";
private int varNum;
- protected final Map<String,String> field2VarMappings;
+ private final Map<String,String> field2VarMappings;
private final Map<String, String> unmodField2VarMappings;
- protected EndpointTypeEnum endpointType;
+ private EndpointTypeEnum endpointType;
protected SparqlFieldQuery() {
this(null);
}
@@ -135,7 +135,7 @@ public class SparqlFieldQuery extends Fi
}
@Override
public int hashCode() {
- return super.hashCode();
+ return super.hashCode()+field2VarMappings.hashCode()+varNum+endpointType.ordinal();
}
/**
@@ -152,7 +152,8 @@ public class SparqlFieldQuery extends Fi
public boolean equals(Object obj) {
return super.equals(obj) && obj instanceof SparqlFieldQuery &&
((SparqlFieldQuery)obj).field2VarMappings.equals(field2VarMappings) &&
- ((SparqlFieldQuery)obj).varNum == varNum;
+ ((SparqlFieldQuery)obj).varNum == varNum &&
+ ((SparqlFieldQuery)obj).endpointType == endpointType;
}
/**
* Getter for the SPARQL SELECT representation of this FieldQuery
Modified: incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java Wed Mar 16 18:43:57 2011
@@ -39,7 +39,6 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.model.rdf.RdfResourceEnum;
import org.apache.stanbol.entityhub.servicesapi.query.Constraint;
import org.apache.stanbol.entityhub.servicesapi.query.RangeConstraint;
-import org.apache.stanbol.entityhub.servicesapi.query.ReferenceConstraint;
import org.apache.stanbol.entityhub.servicesapi.query.TextConstraint;
import org.apache.stanbol.entityhub.servicesapi.query.ValueConstraint;
import org.apache.stanbol.entityhub.servicesapi.query.TextConstraint.PatternType;
@@ -57,6 +56,9 @@ import org.slf4j.LoggerFactory;
*
*/
public final class SparqlQueryUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(SparqlQueryUtils.class);
+
public static enum EndpointTypeEnum {
Standard,
Virtuoso,
@@ -66,7 +68,6 @@ public final class SparqlQueryUtils {
private static final String XSD_DATE_TIME = "http://www.w3.org/2001/XMLSchema#dateTime";
private static final DateFormat DATE_FORMAT = new W3CDateFormat();
- private static final Logger log = LoggerFactory.getLogger(SparqlQueryUtils.class);
private static final RdfValueFactory valueFavtory = RdfValueFactory.getInstance();
/**
* {@link UriRef} constant for {@link RdfResourceEnum#queryResult}
@@ -650,7 +651,7 @@ public final class SparqlQueryUtils {
}
- public static void main(String[] args) {
+/* public static void main(String[] args) {
SparqlFieldQuery query = SparqlFieldQueryFactory.getInstance().createFieldQuery();
query.setConstraint("urn:field1", new ReferenceConstraint("urn:testReference"));
query.setConstraint("urn:field1a", new ValueConstraint(null, Arrays.asList(
@@ -686,7 +687,7 @@ public final class SparqlQueryUtils {
System.out.println(createSparqlSelectQuery(query,true,0,EndpointTypeEnum.Standard));
System.out.println();
System.out.println(createSparqlConstructQuery(query,0,EndpointTypeEnum.Virtuoso));
- }
+ }*/
/**
* @param query
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/pom.xml?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/pom.xml Wed Mar 16 18:43:57 2011
@@ -63,9 +63,6 @@
<Private-Package>
org.apache.stanbol.entityhub.site.linkedData.impl;version=${pom.version},
</Private-Package>
- <Embed-Dependency> <!-- TODO: remove as soon as possible -->
- json
- </Embed-Dependency>
</instructions>
</configuration>
</plugin>
@@ -121,11 +118,11 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20090211</version>
- </dependency>
- <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/CoolUriDereferencer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/CoolUriDereferencer.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/CoolUriDereferencer.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/CoolUriDereferencer.java Wed Mar 16 18:43:57 2011
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
)
public class CoolUriDereferencer extends AbstractEntityDereferencer implements EntityDereferencer{
@Reference
- protected Parser parser;
+ private Parser parser;
private final RdfValueFactory valueFactory = RdfValueFactory.getInstance();
@@ -55,7 +55,7 @@ public class CoolUriDereferencer extends
}
@Override
- public InputStream dereference(String uri, String contentType) throws IOException{
+ public final InputStream dereference(String uri, String contentType) throws IOException{
if(uri!=null){
final URL url = new URL(uri);
final URLConnection con = url.openConnection();
@@ -67,7 +67,7 @@ public class CoolUriDereferencer extends
}
@Override
- public Representation dereference(String uri) throws IOException{
+ public final Representation dereference(String uri) throws IOException{
long start = System.currentTimeMillis();
String format = SupportedFormat.RDF_XML;
InputStream in = dereference(uri, format);
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/LarqSearcher.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/LarqSearcher.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/LarqSearcher.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/LarqSearcher.java Wed Mar 16 18:43:57 2011
@@ -52,10 +52,10 @@ public class LarqSearcher extends Abstra
super(LoggerFactory.getLogger(LarqSearcher.class));
}
@Reference
- protected Parser parser;
+ private Parser parser;
@Override
- public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
+ public final QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
long start = System.currentTimeMillis();
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
query.setEndpointType(EndpointTypeEnum.LARQ);
@@ -83,7 +83,7 @@ public class LarqSearcher extends Abstra
}
@Override
- public QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
+ public final QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
query.setEndpointType(EndpointTypeEnum.LARQ);
String sparqlQuery = query.toSparqlSelect(false);