W3C home > Mailing lists > Public > public-ddwg@w3.org > February 2008

RE: Preview of full latest Java Interface

From: Rotan Hanrahan <rotan.hanrahan@mobileaware.com>
Date: Tue, 26 Feb 2008 11:27:26 -0500
Message-ID: <D5306DC72D165F488F56A9E43F2045D3017E2D9F@FTO.mobileaware.com>
To: <public-ddwg@w3.org>

Thanks Jo. For convenience, the text of all the code minus, the
exceptions, as it looks at this moment in time is pasted below.

---Rotan






package org.w3c.ddr.simple;

/**
 * An interface representing evidence that is to be supplied to
getSimplePropertyValue 
 * or getSimplePropertyValues methods of {@link SimpleService}
 * 
 * @author jo
 *
 */

public interface SimpleEvidence {
	/**
	 * Add a key / value pair
	 * @param key The key
	 * @param value The value
	 */
	public void put(String key, String value);
	
	/**
	 * True if a key exists
	 * @param key
	 * @return
	 */
	public Boolean exists(String key);
	
	/**
	 * Get the value corresponding to the key
	 * @param key
	 * @return
	 */
	public String getValue(String key);
}



package org.w3c.ddr.simple;

public interface SimplePropertyName {
	/**
	 * The name of the property
	 * 
	 * @return
	 */
	public String getPropertyName();

	/**
	 * The namespace of the property 
	 * 
	 * @return
	 * 
	 */
	//TODO Worry about whether an IRI class is needed

	public String getNamespace();

	/**
	 * Factory to create a SimplePropertyRef with the specified
aspect referring to this property
	 * 
	 * @param aspect
	 * @return
	 */
	public SimplePropertyRef newSimplePropertyRef (String aspect);
}



package org.w3c.ddr.simple;

/**
 * Represents a property / aspect combination
 * 
 * @author jo 
 * 
 * 
 */
public interface SimplePropertyRef {
	
	public static final String NULL_ASPECT = "__NULL";

	/**
	 * The name of the property
	 * 
	 * @return
	 */
	public String getPropertyName();

	/**
	 * The name of the aspect
	 * 
	 * @return
	 */
	public String getAspectName();

	/**
	 * The namespace of the property and aspect
	 * 
	 * @return
	 * 
	 */
	//TODO Worry about whether an IRI class is needed
	public String getNamespace();
	
	/**
	 * Factory to create a SimplePropertyName referring to the
Property encapsulated
	 * by this SimplePropertyRef
	 * 
	 * @return
	 */
	public SimplePropertyName newSimplePropertyName ();
}



package org.w3c.ddr.simple;

import org.w3c.ddr.simple.exception.ValueException;

/**
 * Represents the value of a property
 * 
 * @author jmcf
 * 
 */
public interface SimplePropertyValue {

	/**
	 * 
	 * Returns the value as double in the default units of the
property
	 * 
	 * If the value cannot be represented as a double an exception
will be
	 * thrown
	 * 
	 * 
	 */
	public double getDouble() throws ValueException;

	/**
	 * 
	 * Returns the value as a long in the default units of the
property
	 * 
	 * An exception will be thrown if the value cannot be
represented as a long
	 * 
	 * @return
	 * @throws ValueException
	 */
	public long getLong() throws ValueException;

	/**
	 * 
	 * Returns the value of the property as a String
	 * 
	 * This method will return
	 * 
	 * @return
	 */
	public String getString() throws ValueException;

	/**
	 * Returns the actual value as a boolean
	 * 
	 * If the value cannot be represented as a boolean an exception
will be
	 * thrown
	 * 
	 * @return
	 * @throws SimpleException
	 */
	public boolean getBoolean() throws ValueException;

	/**
	 * 
	 * Returns the value as an integer in the default units of the
property
	 * 
	 * An exception will be thrown if the value cannot be
represented as an
	 * Integer
	 * 
	 * @return
	 * @throws SimpleException
	 */
	public int getInteger() throws ValueException;

	/**
	 * 
	 * Returns the value as an enumeration
	 * 
	 * If the value cannot be represented as an enumeration an
exception will be
	 * thrown
	 * 
	 * 
	 * @return
	 * @throws SimpleException
	 */
	public String[] getEnumeration() throws ValueException;

	/**
	 * 
	 * Returns the value in the specified unit as a float
	 * 
	 * If the value cannot be represented as a float an exception
will be thrown
	 * 
	 * 
	 * 
	 */
	public float getFloat() throws ValueException;

	/**
	 * @return
	 */
	public SimplePropertyRef getPropertyRef();

	/**
	 * @return
	 */
	public boolean exists();
}



package org.w3c.ddr.simple;

import org.w3c.ddr.simple.exception.NameException;
import org.w3c.ddr.simple.exception.SystemException;

public interface SimplePropertyValues  {
		
	public SimplePropertyValue[] getAll() throws SystemException;
	
	public SimplePropertyValue getValue(SimplePropertyRef prop)
throws SystemException, NameException;
}



package org.w3c.ddr.simple;

import java.util.Map;
import java.util.Properties;

import org.w3c.ddr.simple.exception.NameException;
import org.w3c.ddr.simple.exception.SystemException;

public interface SimpleService {
	/**
	 * Called by {@link SimpleServiceFactory} to initialize the API
following construction
	 * 
	 * @param defaultVocabularyIRI the IRI of the default vocabulary
namespace
	 * @param props Implementation dependent properties
	 * @throws SystemException
	 */
	public void initialize(String defaultVocabularyIRI, Properties
props)
			throws SystemException;

	/**
	 * 
	 * @return A string indicating the revision level of the API
	 */
	public String getAPIVersion();

	/**
	 * 
	 * @return A String indicating the revision level of the data
	 */
	public String getDataVersion();

	/**
	 * List all the PropertyRefs the API knows about
	 * @return
	 * @throws SystemException
	 */
	public SimplePropertyRef[] listSimplePropertyRefs() throws
SystemException;
	
	
	
	public SimplePropertyValue getSimplePropertyValue(SimpleEvidence
evidence,
			SimplePropertyRef propertyRef) throws
NameException,
			SystemException;

	public SimplePropertyValue getSimplePropertyValue(SimpleEvidence
evidence,
			String propertyName) throws NameException,
SystemException;

	public SimplePropertyValue getSimplePropertyValue(SimpleEvidence
evidence,
			String aspect, String propertyName) throws
NameException,
			SystemException;
	
	public SimplePropertyValue getSimplePropertyValue
(SimpleEvidence evidence,
			SimplePropertyName simplePropertyName) throws
NameException,
			SystemException;
	

	public SimplePropertyValues
getSimplePropertyValues(SimpleEvidence evidence)
			throws SystemException;

	public SimplePropertyValues
getSimplePropertyValues(SimpleEvidence evidence,
			SimplePropertyRef[] properties) throws
NameException,
			SystemException;

	public SimplePropertyValues
getSimplePropertyValues(SimpleEvidence evidence,
			String aspectName) throws NameException,
SystemException;

	public SimplePropertyValues
getSimplePropertyValues(SimpleEvidence evidence,
			String aspectIRI, String aspectName) throws
NameException,
			SystemException;


	public SimplePropertyRef newSimplePropertyRef(String
localPropertyName)
			throws NameException, SystemException;

	public SimplePropertyRef newSimplePropertyRef(String
localAspectName,
			String localPropertyName) throws NameException,
SystemException;

	public SimplePropertyRef newSimplePropertyRef(String
vocabularyIRI,
			String localAspectName, String
localPropertyName)
			throws NameException, SystemException;
	
	public SimplePropertyRef newSimplePropertyRef(String
localAspectName, 
			SimplePropertyName simplePropertyName)
			throws NameException, SystemException;

	/**
	 * Create a SimpleEvidence using the Map consisting of HTTP
Header Names and Values
	 * @param map
	 * @return
	 */
	public SimpleEvidence newHTTPEvidence(Map map);

}




package org.w3c.ddr.simple;

import java.util.Properties;

import org.w3c.ddr.simple.exception.NameException;
import org.w3c.ddr.simple.exception.SystemException;

public class SimpleServiceFactory {
	public static SimpleService newSimpleService(String clazz,
			String defaultVocabulary, Properties
configuration)
			throws SystemException, NameException {
		SimpleService theService = null;
		try {
			// Instantiation
			theService = (SimpleService)
Class.forName(clazz).newInstance();

			// Initialization
			theService.initialize(defaultVocabulary,
configuration);
		} catch (Throwable thr) {
			// TODO: Capture the exceptions properly
			throw new
SystemException(SystemException.INITIALIZATION, thr);
		}

		return theService;
	}

	public static SimpleService newSimpleService(String
defaultVocabulary,
			Properties configuration) throws
SystemException, NameException {

		return null;
	}
}
Received on Tuesday, 26 February 2008 16:31:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 12:13:53 GMT