Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.stanbol.entityhub.core.model;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.stanbol.entityhub.servicesapi.model.Reference;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.apache.stanbol.entityhub.servicesapi.model.Text;
import org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
import org.apache.stanbol.entityhub.servicesapi.util.ModelUtils;
import org.apache.stanbol.entityhub.servicesapi.util.TextIterator;
import org.apache.stanbol.entityhub.servicesapi.util.TypeSafeIterator;
public class InMemoryRepresentation implements Representation,Cloneable {
//private final Logger log = LoggerFactory.getLogger(InMemoryRepresentation.class);
private static ValueFactory valueFactory = new InMemoryValueFactory();
private final Map representation;
private final Map unmodRepresentation;
private final String id;
/**
* creates a new InMemoryRepresentation for the parsed ID
* @param id the id of the representation
*/
protected InMemoryRepresentation(String id){
this(id,null);
}
/**
* Initialise a new InMemoryRepresenation with the parsed map. Note that the
* parsed map is directly used to store the data. That means that callers
* MUST keep in minds that changes to that map will influence the internal
* state of this instance.
* The intension of this constructor is to allow also to define the actual
* map implementation used to store the data.
* If one also wants to directly parse data already contained within an
* other representation one MUST first create deep copy of the according
* map!
* @param id the id for the Representation
* @param representation the map used by this representation to store it's data
*/
protected InMemoryRepresentation(String id, Map representation){
if(id == null){
throw new IllegalArgumentException("The id of a Representation instance MUST NOT be NULL!");
}
this.id = id;
if(representation == null){
this.representation = new HashMap();
} else {
this.representation = representation;
}
unmodRepresentation = Collections.unmodifiableMap(this.representation);
}
@SuppressWarnings("unchecked")
@Override
public void add(String field, Object parsedValue) {
if(field == 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");
}
if(parsedValue == null){
throw new IllegalArgumentException("NULL values are not supported by Representations");
}
Collection