- From: Florent Batard via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 17 Jun 2008 13:41:14 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/contract In directory hutz:/tmp/cvs-serv11946/org/w3c/unicorn/contract Modified Files: EnumInputMethod.java CallMethod.java InputMethod.java Observer.java WADLUnmarshaller.java CallParameter.java RDFContractUnmarshallerJena.java WADLUnmarshallerXPath.java RDFContractUnmarshaller.java Log Message: Updating the javadoc for all the project Index: EnumInputMethod.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/EnumInputMethod.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- EnumInputMethod.java 31 Aug 2006 09:09:20 -0000 1.1.1.1 +++ EnumInputMethod.java 17 Jun 2008 13:41:12 -0000 1.2 @@ -5,31 +5,32 @@ package org.w3c.unicorn.contract; /** + * Enumeration for the input methods + * * @author Damien LEROY */ public enum EnumInputMethod { - URI("uri"), - UPLOAD("upload"), - DIRECT("direct"); + URI("uri"), UPLOAD("upload"), DIRECT("direct"); private final String sValue; - - private EnumInputMethod (final String sValue) { + + private EnumInputMethod(final String sValue) { this.sValue = sValue; } - - public final String value () { + + public final String value() { return this.sValue; } - - public static EnumInputMethod fromValue (final String sValue) { + + public static EnumInputMethod fromValue(final String sValue) { for (final EnumInputMethod aEnumInputMethod : EnumInputMethod.values()) { if (aEnumInputMethod.sValue.equals(sValue)) { return aEnumInputMethod; } } - throw new IllegalArgumentException("Unknow input method : "+sValue.toString()+"."); + throw new IllegalArgumentException("Unknow input method : " + + sValue.toString() + "."); } } Index: Observer.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/Observer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Observer.java 18 Apr 2008 12:35:21 -0000 1.4 +++ Observer.java 17 Jun 2008 13:41:12 -0000 1.5 @@ -16,6 +16,7 @@ /** * Observer<br /> * Created: May 22, 2006 2:56:07 PM<br /> + * * @author Jean-Guilhem Rouel */ public class Observer { @@ -25,13 +26,39 @@ */ private static final Log logger = LogFactory.getLog(Observer.class); + /** + * ID of the observer + */ private String sID; - + + /** + * Name of the observer + */ private LocalizedString aLocalizedStringName = null; + + /** + * Description of the observer + */ private LocalizedString aLocalizedStringDescription = null; + + /** + * An help for the location of the observer + */ private LocalizedString aLocalizedStringHelpLocation = null; + + /** + * A string provider for the observer + */ private LocalizedString aLocalizedStringProvider = null; + + /** + * The name of the language for the observer + */ private String sParamLangName = null; + + /** + * The response type of the observer + */ private String responseType = null; /** @@ -45,42 +72,83 @@ private Map<EnumInputMethod, InputMethod> mapOfInputMethod; /** - * @param url - * @throws Exception + * Creates the observer + * */ - public Observer () { + public Observer() { Observer.logger.trace("Constructor"); } - public String getID () {return this.sID;} - public String getName (final String sLang) {return this.aLocalizedStringName.getLocalization(sLang);} - public String getDescription (final String sLang) {return this.aLocalizedStringDescription.getLocalization(sLang);} - public String getHelpLocation (final String sLang) {return this.aLocalizedStringHelpLocation.getLocalization(sLang);} - public String getProvider (final String sLang) {return this.aLocalizedStringProvider.getLocalization(sLang);} - public String getParamLangName () {return this.sParamLangName;} + public String getID() { + return this.sID; + } - /* (non-Javadoc) + public String getName(final String sLang) { + return this.aLocalizedStringName.getLocalization(sLang); + } + + public String getDescription(final String sLang) { + return this.aLocalizedStringDescription.getLocalization(sLang); + } + + public String getHelpLocation(final String sLang) { + return this.aLocalizedStringHelpLocation.getLocalization(sLang); + } + + public String getProvider(final String sLang) { + return this.aLocalizedStringProvider.getLocalization(sLang); + } + + public String getParamLangName() { + return this.sParamLangName; + } + + /* + * (non-Javadoc) + * * @see org.w3c.unicorn.contract.Observer#getMethods() */ public List<CallMethod> getListOfCallMethod() { return this.listOfCallMethod; } - public void setID (final String sID) {this.sID = sID;} - public void setName (final LocalizedString aLocalizedString) {this.aLocalizedStringName = aLocalizedString;} - public void setDescription (final LocalizedString aLocalizedString) {this.aLocalizedStringDescription = aLocalizedString;} - public void setHelpLocation (final LocalizedString aLocalizedString) {this.aLocalizedStringHelpLocation = aLocalizedString;} - public void setProvider (final LocalizedString aLocalizedString) {this.aLocalizedStringProvider = aLocalizedString;} - public void setParamLangName (final String sParamLangName) {this.sParamLangName = sParamLangName;} - - /* (non-Javadoc) + public void setID(final String sID) { + this.sID = sID; + } + + public void setName(final LocalizedString aLocalizedString) { + this.aLocalizedStringName = aLocalizedString; + } + + public void setDescription(final LocalizedString aLocalizedString) { + this.aLocalizedStringDescription = aLocalizedString; + } + + public void setHelpLocation(final LocalizedString aLocalizedString) { + this.aLocalizedStringHelpLocation = aLocalizedString; + } + + public void setProvider(final LocalizedString aLocalizedString) { + this.aLocalizedStringProvider = aLocalizedString; + } + + public void setParamLangName(final String sParamLangName) { + this.sParamLangName = sParamLangName; + } + + /* + * (non-Javadoc) + * * @see org.w3c.unicorn.contract.Observer#setMethods(java.util.ArrayList) */ - public void setListOfCallMethod (final List<CallMethod> listOfCallMethod) { + public void setListOfCallMethod(final List<CallMethod> listOfCallMethod) { this.listOfCallMethod = listOfCallMethod; } - public String toString () { + /** + * Prints the object + */ + public String toString() { final int sbSize = 1000; final String sVariableSeparator = "\n"; final StringBuffer aStringBuffer = new StringBuffer(sbSize); @@ -89,17 +157,21 @@ aStringBuffer.append(sVariableSeparator); aStringBuffer.append("Name:").append(this.aLocalizedStringName); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("Description:").append(this.aLocalizedStringDescription); + aStringBuffer.append("Description:").append( + this.aLocalizedStringDescription); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("HelpLocation:").append(this.aLocalizedStringHelpLocation); + aStringBuffer.append("HelpLocation:").append( + this.aLocalizedStringHelpLocation); aStringBuffer.append(sVariableSeparator); aStringBuffer.append("Provider:").append(this.aLocalizedStringProvider); aStringBuffer.append(sVariableSeparator); - //aStringBuffer.append("Description:[").append(this.aObserverDescription).append("]"); - //aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("Methods:[").append(this.listOfCallMethod).append("]"); + // aStringBuffer.append("Description:[").append(this.aObserverDescription).append("]"); + // aStringBuffer.append(sVariableSeparator); + aStringBuffer.append("Methods:[").append(this.listOfCallMethod).append( + "]"); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("InputMethods:[").append(this.mapOfInputMethod).append("]"); + aStringBuffer.append("InputMethods:[").append(this.mapOfInputMethod) + .append("]"); return aStringBuffer.toString(); } @@ -108,60 +180,70 @@ return this.mapOfInputMethod; } - public void setMapOfInputMethod (final Map<EnumInputMethod, InputMethod> mapOfInputMethod) { + public void setMapOfInputMethod( + final Map<EnumInputMethod, InputMethod> mapOfInputMethod) { this.mapOfInputMethod = mapOfInputMethod; } - public void addInputMethod ( - final EnumInputMethod aEnumInputMethod, + public void addInputMethod(final EnumInputMethod aEnumInputMethod, final InputMethod aInputMethod) { this.mapOfInputMethod.put(aEnumInputMethod, aInputMethod); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.w3c.unicorn.contract.Observer#getInputMethod(org.w3c.unicorn.contract.methods.EnumInputMethod) */ - public InputMethod getInputMethod (final EnumInputMethod aEnumInputMethod) { + public InputMethod getInputMethod(final EnumInputMethod aEnumInputMethod) { return this.mapOfInputMethod.get(aEnumInputMethod); } - public CallMethod getCallMethod (final EnumInputMethod aEnumInputMethod) { + public CallMethod getCallMethod(final EnumInputMethod aEnumInputMethod) { return this.getInputMethod(aEnumInputMethod).getCallMethod(); } - public void addMimeType ( - final EnumInputMethod aEnumInputMethod, + public void addMimeType(final EnumInputMethod aEnumInputMethod, final MimeType aMimeType) { this.mapOfInputMethod.get(aEnumInputMethod).addMimeType(aMimeType); } - public boolean canHandleMimeType ( - final MimeType aMimeType, + /** + * Tells of the mime-type is handled + * + * @param aMimeType + * mime-type to check + * @param aEnumInputMethod + * the input method for the observer + * @return whether or not the mime-type is handled + */ + public boolean canHandleMimeType(final MimeType aMimeType, final EnumInputMethod aEnumInputMethod) { - final InputMethod aInputMethod = this.mapOfInputMethod.get(aEnumInputMethod); + final InputMethod aInputMethod = this.mapOfInputMethod + .get(aEnumInputMethod); if (null == aInputMethod) { return false; } - return aInputMethod.canHandleMimeType(aMimeType); + return aInputMethod.canHandleMimeType(aMimeType); } /** * Return a list of EnumInputMethod with this observer handler mime type * given in parameter. + * + * @param aMimeType */ - public boolean canHandleMimeType (final MimeType aMimeType) { + public boolean canHandleMimeType(final MimeType aMimeType) { Observer.logger.trace("canHandleMimeType(MimeType)"); if (Observer.logger.isDebugEnabled()) { Observer.logger.debug("Mime type : " + aMimeType + "."); } for (final EnumInputMethod aEnumInputMethod : EnumInputMethod.values()) { - final InputMethod aInputMethod = this.mapOfInputMethod.get(aEnumInputMethod); + final InputMethod aInputMethod = this.mapOfInputMethod + .get(aEnumInputMethod); if (null == aInputMethod) { - Observer.logger.warn( - "Input method of type " + - aEnumInputMethod + - " does not exist for observer " + - this.getID() + "."); + Observer.logger.warn("Input method of type " + aEnumInputMethod + + " does not exist for observer " + this.getID() + "."); continue; } if (aInputMethod.canHandleMimeType(aMimeType)) { Index: CallParameter.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/CallParameter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CallParameter.java 19 Feb 2008 12:49:08 -0000 1.3 +++ CallParameter.java 17 Jun 2008 13:41:12 -0000 1.4 @@ -16,36 +16,82 @@ */ public class CallParameter { - private static final Log logger = LogFactory.getLog("org.w3c.unicorn.contract"); + /** + * Object for complex logging purpose + */ + private static final Log logger = LogFactory + .getLog("org.w3c.unicorn.contract"); - // Attributes of the parameter - private String sName = null; + // Attributes of the parameter + /** + * Name of the parameter + */ + private String sName = null; + + /** + * Style of the parameter + */ private String sStyle = null; + + /** + * ID of the parameter + */ private String sID = null; + + /** + * Type of the parameter + */ private String sType = null; + + /** + * Default value for the parameter + */ private String sDefaultValue; - private boolean bRequired; // Is this parameter mandatory + + /** + * Defines whether or not the parameter is mandatory + */ + private boolean bRequired; // Is this parameter mandatory + + /** + * Defines whether or not the parameter can be repeated + */ private boolean bRepeating; // Can this parameter be repeated - private String sFixed = null; // Indicates if the parameter can be manually set or not + + /** + * Indicates if the parameter can be manually set or not + */ + private String sFixed = null; // Indicates if the parameter can be + + // manually set or not + + /** + * Defines the path of the parameter + */ private String sPath = null; - // Possible values for this parameter - private List<String> listOfPossibleValue = null; - /** + * Possible values for this parameter + */ + private List<String> listOfPossibleValue = null; + + /** + * Constructor for a parameter + * * @param sName + * Name of the parameter * @param listOfPossibleValue + * all the possibles values * @param sFixed + * Indicates if the parameter can be manually set or not */ - public CallParameter ( - final String sName, - final List<String> listOfValue, - final String sFixed, - final boolean bRequired, + public CallParameter(final String sName, final List<String> listOfValue, + final String sFixed, final boolean bRequired, final boolean bRepeating) { super(); - CallParameter.logger.trace("Constructor(String, List<String>, String, boolean, boolean)"); + CallParameter.logger + .trace("Constructor(String, List<String>, String, boolean, boolean)"); if (CallParameter.logger.isDebugEnabled()) { CallParameter.logger.debug("Name : " + sName + "."); CallParameter.logger.debug("List of value : " + listOfValue + "."); @@ -60,45 +106,53 @@ this.bRequired = bRequired; this.bRepeating = bRepeating; } - - public CallParameter (final String sName) { + + /** + * Various constructor with only the name and default value + * + * @param sName + * name of the parameter + */ + public CallParameter(final String sName) { this(sName, new ArrayList<String>(), null, false, false); CallParameter.logger.trace("Constructor(String)"); } - public CallParameter () { + /** + * Various constructor with empty name + */ + public CallParameter() { this("", new ArrayList<String>(), null, false, false); CallParameter.logger.trace("Constructor()"); } - - //=================== - //===== GETTERS ===== - //=================== + // =================== + // ===== GETTERS ===== + // =================== public String getName() { return this.sName; } - + public String getStyle() { return this.sStyle; } - + public String getID() { return this.sID; } - + public String getType() { return this.sType; } - + public String getDefaultValue() { return this.sDefaultValue; } - + public boolean isRequired() { return this.bRequired; } - + public boolean isRepeating() { return this.bRepeating; } @@ -106,90 +160,87 @@ public boolean isFixed() { return this.sFixed != null; } - + public String getFixed() { return this.sFixed; } - + public String getPath() { return this.sPath; - } - - public List<String> getListOfPossibleValue () { + } + + public List<String> getListOfPossibleValue() { return listOfPossibleValue; } - - //================== - //===== SETTERS ==== - //================== - public void setName (final String sName) { + // ================== + // ===== SETTERS ==== + // ================== + public void setName(final String sName) { this.sName = sName; } public void setStyle(String style) { this.sStyle = style; } - + public void setID(String sid) { this.sID = sid; } - + public void setType(String type) { this.sType = type; } - + public void setDefaultValue(String defaultValue) { this.sDefaultValue = defaultValue; } - - public void setRequired (final boolean bRequired) { + + public void setRequired(final boolean bRequired) { this.bRequired = bRequired; } - - public void setRepeating (final boolean bRepeating) { + + public void setRepeating(final boolean bRepeating) { this.bRepeating = bRepeating; } - - public void setFixed (final String sFixed) { + + public void setFixed(final String sFixed) { this.sFixed = sFixed; } - - public void setPath (final String sPath) { + + public void setPath(final String sPath) { this.sPath = sPath; } - - - - public void setPossibleValues (final List<String> listOfValue) { + + public void setPossibleValues(final List<String> listOfValue) { this.listOfPossibleValue = listOfValue; } - - public void addValue (final String sValue) { + + public void addValue(final String sValue) { if (this.listOfPossibleValue == null) { this.listOfPossibleValue = new ArrayList<String>(); } this.listOfPossibleValue.add(sValue); } - - public Object getValue (final int iPosition) { + + public Object getValue(final int iPosition) { return this.listOfPossibleValue.get(iPosition); } - - public boolean contains (final String sValue) { - return this.listOfPossibleValue.contains(sValue) || - (this.listOfPossibleValue.size() == 1 && this.listOfPossibleValue.contains("")); + + public boolean contains(final String sValue) { + return this.listOfPossibleValue.contains(sValue) + || (this.listOfPossibleValue.size() == 1 && this.listOfPossibleValue + .contains("")); } - - + /** - * {@inheritDoc} + * Prints the object */ public String toString() { final int iSize = 1000; final String sVariableSeparator = "\n"; final StringBuffer aStringBuffer = new StringBuffer(iSize); - + aStringBuffer.append("[begin CallParameter]\n"); aStringBuffer.append("name:=").append(sName); aStringBuffer.append(sVariableSeparator); @@ -211,10 +262,8 @@ aStringBuffer.append(sVariableSeparator); aStringBuffer.append("default:=").append(sDefaultValue); aStringBuffer.append("[end CallParameter]\n"); - + return aStringBuffer.toString(); } - -} - +} Index: RDFContractUnmarshaller.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/RDFContractUnmarshaller.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RDFContractUnmarshaller.java 22 Jan 2008 13:52:05 -0000 1.2 +++ RDFContractUnmarshaller.java 17 Jun 2008 13:41:12 -0000 1.3 @@ -11,23 +11,22 @@ /** * Interface to unmarshall RDF file. + * * @author Damien LEROY */ public interface RDFContractUnmarshaller extends Unmarshaller { - public String getID (); + public String getID(); - public LocalizedString getName (); + public LocalizedString getName(); - public LocalizedString getDescription (); + public LocalizedString getDescription(); - public LocalizedString getHelpLocation (); - - public LocalizedString getProvider (); - - public String getNameOfLangParameter (); + public LocalizedString getHelpLocation(); - //ObserverDescription getDescription(); + public LocalizedString getProvider(); + + public String getNameOfLangParameter(); Map<EnumInputMethod, InputMethod> getMapOfInputMethod(); Index: RDFContractUnmarshallerJena.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/RDFContractUnmarshallerJena.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RDFContractUnmarshallerJena.java 22 Jan 2008 13:51:50 -0000 1.2 +++ RDFContractUnmarshallerJena.java 17 Jun 2008 13:41:12 -0000 1.3 @@ -24,6 +24,7 @@ /** * This class allow to read and parse a RDF file about a observer contract. + * * @author Damien LEROY */ public class RDFContractUnmarshallerJena implements RDFContractUnmarshaller { @@ -31,100 +32,151 @@ /** * Use to log any information during use of this class. */ - private static final Log logger = LogFactory.getLog("org.w3c.unicorn.contract"); + private static final Log logger = LogFactory + .getLog("org.w3c.unicorn.contract"); + /** + * Model Object + */ private static final Model MODEL = ModelFactory.createDefaultModel(); + /** + * The namespace used for unicorn + */ private static final String UCN_NAMESPACE = "http://www.w3.org/unicorn#"; private static Resource RESOURCE_OBSERVER = null; + private static Resource RESOURCE_PARAMETER_URI = null; + private static Resource RESOURCE_PARAMETER_UPLOAD = null; + private static Resource RESOURCE_PARAMETER_DIRECT = null; private static Property PROPERTY_NAME = null; + private static Property PROPERTY_DESCRIPTION = null; + private static Property PROPERTY_HELP = null; + private static Property PROPERTY_PROVIDER = null; + private static Property PROPERTY_MIMETYPE = null; + private static Property PROPERTY_INPUTMETHOD = null; + private static Property PROPERTY_METHODNAME = null; + private static Property PROPERTY_PARAMETERNAME = null; + private static Property PROPERTY_REFERENCE = null; + private static Property PROPERTY_TYPE = null; + private static Property PROPERTY_LANG = null; + /** + * Description of a observer to complete with information from a RDF file. + */ static { try { - RDFContractUnmarshallerJena.MODEL.read( - new URL(org.w3c.unicorn.util.Property.get("OBSERVER_RDF_MODEL")).openStream(), - null); + RDFContractUnmarshallerJena.MODEL.read(new URL( + org.w3c.unicorn.util.Property.get("OBSERVER_RDF_MODEL")) + .openStream(), null); // define resource use to find information into the RDF graph - RDFContractUnmarshallerJena.RESOURCE_OBSERVER = RDFContractUnmarshallerJena.MODEL.getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE+"Observer"); - RDFContractUnmarshallerJena.RESOURCE_PARAMETER_URI = RDFContractUnmarshallerJena.MODEL.getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE+"ParameterURI"); - RDFContractUnmarshallerJena.RESOURCE_PARAMETER_UPLOAD = RDFContractUnmarshallerJena.MODEL.getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE+"ParameterUpload"); - RDFContractUnmarshallerJena.RESOURCE_PARAMETER_DIRECT = RDFContractUnmarshallerJena.MODEL.getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE+"ParameterDirectInput"); + RDFContractUnmarshallerJena.RESOURCE_OBSERVER = RDFContractUnmarshallerJena.MODEL + .getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "Observer"); + RDFContractUnmarshallerJena.RESOURCE_PARAMETER_URI = RDFContractUnmarshallerJena.MODEL + .getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "ParameterURI"); + RDFContractUnmarshallerJena.RESOURCE_PARAMETER_UPLOAD = RDFContractUnmarshallerJena.MODEL + .getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "ParameterUpload"); + RDFContractUnmarshallerJena.RESOURCE_PARAMETER_DIRECT = RDFContractUnmarshallerJena.MODEL + .getResource(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "ParameterDirectInput"); // define property use to find information into the RDF graph - RDFContractUnmarshallerJena.PROPERTY_DESCRIPTION = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"description"); - RDFContractUnmarshallerJena.PROPERTY_HELP = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"help"); - RDFContractUnmarshallerJena.PROPERTY_INPUTMETHOD = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"inputMethod"); - RDFContractUnmarshallerJena.PROPERTY_METHODNAME = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"methodName"); - RDFContractUnmarshallerJena.PROPERTY_MIMETYPE = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"mimetype"); - RDFContractUnmarshallerJena.PROPERTY_NAME = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"name"); - RDFContractUnmarshallerJena.PROPERTY_PARAMETERNAME = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"parameterName"); - RDFContractUnmarshallerJena.PROPERTY_PROVIDER = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"provider"); - RDFContractUnmarshallerJena.PROPERTY_REFERENCE = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"reference"); - RDFContractUnmarshallerJena.PROPERTY_TYPE = RDFContractUnmarshallerJena.MODEL.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); - RDFContractUnmarshallerJena.PROPERTY_LANG = RDFContractUnmarshallerJena.MODEL.getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE+"lang"); - + RDFContractUnmarshallerJena.PROPERTY_DESCRIPTION = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "description"); + RDFContractUnmarshallerJena.PROPERTY_HELP = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "help"); + RDFContractUnmarshallerJena.PROPERTY_INPUTMETHOD = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "inputMethod"); + RDFContractUnmarshallerJena.PROPERTY_METHODNAME = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "methodName"); + RDFContractUnmarshallerJena.PROPERTY_MIMETYPE = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "mimetype"); + RDFContractUnmarshallerJena.PROPERTY_NAME = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "name"); + RDFContractUnmarshallerJena.PROPERTY_PARAMETERNAME = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "parameterName"); + RDFContractUnmarshallerJena.PROPERTY_PROVIDER = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "provider"); + RDFContractUnmarshallerJena.PROPERTY_REFERENCE = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "reference"); + RDFContractUnmarshallerJena.PROPERTY_TYPE = RDFContractUnmarshallerJena.MODEL + .getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); + RDFContractUnmarshallerJena.PROPERTY_LANG = RDFContractUnmarshallerJena.MODEL + .getProperty(RDFContractUnmarshallerJena.UCN_NAMESPACE + + "lang"); } catch (final MalformedURLException e) { - RDFContractUnmarshallerJena.logger.error("MalformedURLException : "+e.getMessage(), e); + RDFContractUnmarshallerJena.logger.error("MalformedURLException : " + + e.getMessage(), e); e.printStackTrace(); } catch (final IOException e) { - RDFContractUnmarshallerJena.logger.error("IOException : "+e.getMessage(), e); + RDFContractUnmarshallerJena.logger.error("IOException : " + + e.getMessage(), e); e.printStackTrace(); } } - /** - * Description of a observer to complete with information from a RDF file. - */ - //private ObserverDescription aObserverDescription = null; - private String sID = null; - + private LocalizedString aLocalizedStringName = null; + private LocalizedString aLocalizedStringDescription = null; + private LocalizedString aLocalizedStringHelpLocation = null; + private LocalizedString aLocalizedStringProvider = null; - + // name of parameter lang if observer has one private String nameOfLangParameter = null; - public String getID () { + public String getID() { return this.sID; } - public LocalizedString getName () { + public LocalizedString getName() { return this.aLocalizedStringName; } - public LocalizedString getDescription () { + public LocalizedString getDescription() { return this.aLocalizedStringDescription; } - public LocalizedString getHelpLocation () { + public LocalizedString getHelpLocation() { return this.aLocalizedStringHelpLocation; } - - public LocalizedString getProvider () { + + public LocalizedString getProvider() { return this.aLocalizedStringProvider; } - - public String getNameOfLangParameter () { + + public String getNameOfLangParameter() { return this.nameOfLangParameter; } @@ -134,8 +186,8 @@ private Map<EnumInputMethod, InputMethod> mapOfInputMethod = null; /** - * List of all method who can be used to call the observer. - * This list is from the parsing of a WADL file. + * List of all method who can be used to call the observer. This list is + * from the parsing of a WADL file. */ private List<CallMethod> listOfCallMethod = null; @@ -146,10 +198,12 @@ /** * Constructor of the RDFUnmarshallerJena class. - * @param listOfCallMethod List of all method who can be used to call the observer. + * + * @param listOfCallMethod + * List of all method who can be used to call the observer. */ - public RDFContractUnmarshallerJena (final List<CallMethod> listOfCallMethod) { - //this.aObserverDescription = new ObserverDescription(); + public RDFContractUnmarshallerJena(final List<CallMethod> listOfCallMethod) { + // this.aObserverDescription = new ObserverDescription(); this.aLocalizedStringName = new LocalizedString(); this.aLocalizedStringDescription = new LocalizedString(); this.aLocalizedStringHelpLocation = new LocalizedString(); @@ -160,23 +214,16 @@ } /** - * Return The description of an observer build from the parsing of a RDF file. - *//* - public ObserverDescription getDescription() { - return this.aObserverDescription; - }*/ - - /** * Return map of different input method handle by the observer. */ public Map<EnumInputMethod, InputMethod> getMapOfInputMethod() { return this.mapOfInputMethod; } - public void addURL (final URL aURL) throws IOException { + public void addURL(final URL aURL) throws IOException { RDFContractUnmarshallerJena.logger.trace("addURL"); if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { - RDFContractUnmarshallerJena.logger.debug("URL : "+aURL+"."); + RDFContractUnmarshallerJena.logger.debug("URL : " + aURL + "."); } // read the RDF file final Model aModel = ModelFactory.createDefaultModel(); @@ -190,92 +237,107 @@ * @param aURLRDF * The URL of the RDF file. */ - public void unmarshal () throws IOException, MimeTypeParseException { + public void unmarshal() throws IOException, MimeTypeParseException { RDFContractUnmarshallerJena.logger.trace("unmarshal"); // find Observer into the RDF graph - for ( - StmtIterator siObserver = this.aModel.listStatements( - null, - RDFContractUnmarshallerJena.PROPERTY_TYPE, - RDFContractUnmarshallerJena.RESOURCE_OBSERVER); - siObserver.hasNext();) { + for (StmtIterator siObserver = this.aModel.listStatements(null, + RDFContractUnmarshallerJena.PROPERTY_TYPE, + RDFContractUnmarshallerJena.RESOURCE_OBSERVER); siObserver + .hasNext();) { final Resource subject = siObserver.nextStatement().getSubject(); // log if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { RDFContractUnmarshallerJena.logger.debug("Observer " + subject); } - this.sID = subject.getProperty(RDFContractUnmarshallerJena.PROPERTY_REFERENCE).getLiteral().getString(); + this.sID = subject.getProperty( + RDFContractUnmarshallerJena.PROPERTY_REFERENCE) + .getLiteral().getString(); - // find and add lang - for (StmtIterator si = subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_LANG); si.hasNext();) { + for (StmtIterator si = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_LANG); si + .hasNext();) { final Literal l = si.nextStatement().getLiteral(); - this.nameOfLangParameter=l.getString(); + this.nameOfLangParameter = l.getString(); } - + // find and add input method - for ( - StmtIterator aStatementIterator = - subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_INPUTMETHOD); - aStatementIterator.hasNext();) { + for (StmtIterator aStatementIterator = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_INPUTMETHOD); aStatementIterator + .hasNext();) { - final Resource aResourceParameter = (Resource) aStatementIterator.nextStatement().getObject(); + final Resource aResourceParameter = (Resource) aStatementIterator + .nextStatement().getObject(); - final String sMethodName = aResourceParameter.getProperty(RDFContractUnmarshallerJena.PROPERTY_METHODNAME).getLiteral().getString(); + final String sMethodName = aResourceParameter.getProperty( + RDFContractUnmarshallerJena.PROPERTY_METHODNAME) + .getLiteral().getString(); // log - RDFContractUnmarshallerJena.logger.debug("Method name = " + sMethodName); + RDFContractUnmarshallerJena.logger.debug("Method name = " + + sMethodName); - final String sParameterName = aResourceParameter.getProperty(RDFContractUnmarshallerJena.PROPERTY_PARAMETERNAME).getLiteral().getString(); + final String sParameterName = aResourceParameter.getProperty( + RDFContractUnmarshallerJena.PROPERTY_PARAMETERNAME) + .getLiteral().getString(); // log - RDFContractUnmarshallerJena.logger.debug("Parameter name = " + sParameterName); + RDFContractUnmarshallerJena.logger.debug("Parameter name = " + + sParameterName); final InputMethod aInputMethod = new InputMethod(); // find method - for (Iterator iter = this.listOfCallMethod.iterator(); iter.hasNext();) { + for (Iterator iter = this.listOfCallMethod.iterator(); iter + .hasNext();) { final CallMethod aCallMethod = (CallMethod) iter.next(); if (aCallMethod.getID().equals(sMethodName)) { // log if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { - RDFContractUnmarshallerJena.logger.debug( - "setMethod : " + - aCallMethod.getID()); + RDFContractUnmarshallerJena.logger + .debug("setMethod : " + aCallMethod.getID()); } aInputMethod.setCallMethod(aCallMethod); } } - aInputMethod.setCallParameter(aInputMethod.getCallMethod().getMapOfCallParameter().get(sParameterName)); + aInputMethod.setCallParameter(aInputMethod.getCallMethod() + .getMapOfCallParameter().get(sParameterName)); // log if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { - RDFContractUnmarshallerJena.logger.debug( - "setParameter : " + - aInputMethod.getCallParameter().getName()); + RDFContractUnmarshallerJena.logger.debug("setParameter : " + + aInputMethod.getCallParameter().getName()); } if (aResourceParameter.hasProperty( RDFContractUnmarshallerJena.PROPERTY_TYPE, RDFContractUnmarshallerJena.RESOURCE_PARAMETER_URI)) { - this.mapOfInputMethod.put(EnumInputMethod.URI, aInputMethod); + this.mapOfInputMethod + .put(EnumInputMethod.URI, aInputMethod); } else if (aResourceParameter.hasProperty( RDFContractUnmarshallerJena.PROPERTY_TYPE, RDFContractUnmarshallerJena.RESOURCE_PARAMETER_UPLOAD)) { - this.mapOfInputMethod.put(EnumInputMethod.UPLOAD, aInputMethod); + this.mapOfInputMethod.put(EnumInputMethod.UPLOAD, + aInputMethod); } else if (aResourceParameter.hasProperty( RDFContractUnmarshallerJena.PROPERTY_TYPE, RDFContractUnmarshallerJena.RESOURCE_PARAMETER_DIRECT)) { - this.mapOfInputMethod.put(EnumInputMethod.DIRECT, aInputMethod); + this.mapOfInputMethod.put(EnumInputMethod.DIRECT, + aInputMethod); } else { - RDFContractUnmarshallerJena.logger.error("InputMethod has not specific type."); + RDFContractUnmarshallerJena.logger + .error("InputMethod has not specific type."); } // find and add mimetype handle by the observer - for (StmtIterator si = aResourceParameter.listProperties(RDFContractUnmarshallerJena.PROPERTY_MIMETYPE); si.hasNext();) { - final String s = si.nextStatement().getLiteral().getString(); + for (StmtIterator si = aResourceParameter + .listProperties(RDFContractUnmarshallerJena.PROPERTY_MIMETYPE); si + .hasNext();) { + final String s = si.nextStatement().getLiteral() + .getString(); if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { - RDFContractUnmarshallerJena.logger.debug("MimeType : " + s + "."); + RDFContractUnmarshallerJena.logger.debug("MimeType : " + + s + "."); } aInputMethod.addMimeType(new MimeType(s)); } @@ -283,41 +345,51 @@ } // find and add localized name - for ( - StmtIterator aStatementIterator = subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_NAME); - aStatementIterator.hasNext();) { - final Literal l = aStatementIterator.nextStatement().getLiteral(); - RDFContractUnmarshallerJena.logger.debug("Name : lang=" + l.getLanguage() + " text=" + l.getString()); - this.aLocalizedStringName.addLocalization(l.getLanguage(), l.getString()); + for (StmtIterator aStatementIterator = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_NAME); aStatementIterator + .hasNext();) { + final Literal l = aStatementIterator.nextStatement() + .getLiteral(); + RDFContractUnmarshallerJena.logger.debug("Name : lang=" + + l.getLanguage() + " text=" + l.getString()); + this.aLocalizedStringName.addLocalization(l.getLanguage(), l + .getString()); } // find and add localized description - for (StmtIterator si = subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_DESCRIPTION); si.hasNext();) { + for (StmtIterator si = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_DESCRIPTION); si + .hasNext();) { final Literal l = si.nextStatement().getLiteral(); - RDFContractUnmarshallerJena.logger.debug("Description : lang=" + l.getLanguage() + " text=" + l.getString()); - this.aLocalizedStringDescription.addLocalization(l.getLanguage(), l.getString()); + RDFContractUnmarshallerJena.logger.debug("Description : lang=" + + l.getLanguage() + " text=" + l.getString()); + this.aLocalizedStringDescription.addLocalization(l + .getLanguage(), l.getString()); } // find and add localized provider - for (StmtIterator si = subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_PROVIDER); si.hasNext();) { + for (StmtIterator si = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_PROVIDER); si + .hasNext();) { final Literal l = si.nextStatement().getLiteral(); - RDFContractUnmarshallerJena.logger.debug("Provider : lang=" + l.getLanguage() + " text=" + l.getString()); - this.aLocalizedStringProvider.addLocalization(l.getLanguage(), l.getString()); + RDFContractUnmarshallerJena.logger.debug("Provider : lang=" + + l.getLanguage() + " text=" + l.getString()); + this.aLocalizedStringProvider.addLocalization(l.getLanguage(), + l.getString()); } // find and add localized help - for (StmtIterator si = subject.listProperties(RDFContractUnmarshallerJena.PROPERTY_HELP); si.hasNext();) { + for (StmtIterator si = subject + .listProperties(RDFContractUnmarshallerJena.PROPERTY_HELP); si + .hasNext();) { final Literal l = si.nextStatement().getLiteral(); if (RDFContractUnmarshallerJena.logger.isDebugEnabled()) { - RDFContractUnmarshallerJena.logger.debug( - "Help : lang=" + - l.getLanguage() + - " text=" + - l.getString()); + RDFContractUnmarshallerJena.logger.debug("Help : lang=" + + l.getLanguage() + " text=" + l.getString()); } - this.aLocalizedStringHelpLocation.addLocalization(l.getLanguage(), l.getString()); + this.aLocalizedStringHelpLocation.addLocalization(l + .getLanguage(), l.getString()); } - } // find Observer into the RDF graph Index: CallMethod.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/CallMethod.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- CallMethod.java 31 Aug 2006 09:09:20 -0000 1.1.1.1 +++ CallMethod.java 17 Jun 2008 13:41:12 -0000 1.2 @@ -11,25 +11,57 @@ import org.apache.commons.logging.LogFactory; /** - * CallMethod<br /> - * Created: May 23, 2006 11:46:50 AM<br /> + * CallMethod Created: May 23, 2006 11:46:50 AM */ public class CallMethod { - private static final Log logger = LogFactory.getLog("org.w3c.unicorn.contract"); + /** + * Object for complex logging purpose + */ + private static final Log logger = LogFactory + .getLog("org.w3c.unicorn.contract"); + /** + * + */ private URL aURL; // GET or POST + /** + * The url to call + */ private String sName; + + /** + * The name to call + */ private String sID; + + /** + * the ID of the call + */ private boolean bPost; + + /** + * whether the call is sent or not + */ private Map<String, CallParameter> mapOfCallParameter; - public CallMethod ( - final URL aURL, - final boolean bPost, - final String sName, + /** + * Set the parameter for the object call + * + * @param aURL + * the url to call + * @param bPost + * whether or not the call is post + * @param sName + * the name to call + * @param sID + * the id of the call + * @param mapOfCallParameter + * the parameter of the call + */ + public CallMethod(final URL aURL, final boolean bPost, final String sName, final String sID, final Map<String, CallParameter> mapOfCallParameter) { CallMethod.logger.trace("Constructor"); @@ -38,7 +70,8 @@ CallMethod.logger.debug("Post : " + bPost + "."); CallMethod.logger.debug("Name : " + sName + "."); CallMethod.logger.debug("ID : " + sID + "."); - CallMethod.logger.debug("Map of call parameter : " + mapOfCallParameter + "."); + CallMethod.logger.debug("Map of call parameter : " + + mapOfCallParameter + "."); } this.aURL = aURL; @@ -49,45 +82,75 @@ } /** + * Returns all the parameters of the call + * * @return Returns the parameters. */ - public Map<String, CallParameter> getMapOfCallParameter () { + public Map<String, CallParameter> getMapOfCallParameter() { return this.mapOfCallParameter; } - - public void addParameter (final CallParameter aCallParameter) { + /** + * Add a parameter to the call + * + * @param aCallParameter + * a parameter to add + */ + public void addParameter(final CallParameter aCallParameter) { this.mapOfCallParameter.put(aCallParameter.getName(), aCallParameter); } /** + * Gets the parameter by its name + * * @param sName - * @return + * name of the parameter to get + * @return the Call parameter researched */ - public CallParameter getCallParameterByName (final String sName) { + public CallParameter getCallParameterByName(final String sName) { return this.mapOfCallParameter.get(sName); } /** + * Returns if the call is post + * * @return Returns the post. */ - public boolean isPost () {return this.bPost;} + public boolean isPost() { + return this.bPost; + } /** + * Returns the URI + * * @return Returns the uri. */ - public URL getURL () {return this.aURL;} + public URL getURL() { + return this.aURL; + } /** + * Returns the ID + * * @return Returns the id. */ - public String getID () {return this.sID;} - public String getName () {return this.sName;} + public String getID() { + return this.sID; + } /** - * {@inheritDoc} + * Get the name of the call + * + * @return the name of the call */ - public String toString () { + public String getName() { + return this.sName; + } + + /** + * Print the object + */ + public String toString() { final int iSize = 1000; final String sVariableSeparator = "\n"; final StringBuffer aStringBuffer = new StringBuffer(iSize); @@ -99,7 +162,8 @@ aStringBuffer.append("post=").append(this.bPost); aStringBuffer.append(sVariableSeparator); aStringBuffer.append("parameters=\n"); - aStringBuffer.append(this.mapOfCallParameter).append(sVariableSeparator); + aStringBuffer.append(this.mapOfCallParameter) + .append(sVariableSeparator); return aStringBuffer.toString(); } Index: WADLUnmarshallerXPath.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- WADLUnmarshallerXPath.java 18 Apr 2008 12:35:22 -0000 1.4 +++ WADLUnmarshallerXPath.java 17 Jun 2008 13:41:12 -0000 1.5 @@ -36,90 +36,140 @@ /** * WADLUnmarshallerXPath<br /> * Created: May 22, 2006 6:01:14 PM<br /> + * * @author Jean-Guilhem ROUEL */ public class WADLUnmarshallerXPath implements WADLUnmarshaller { + /** + * Object for complex logging purpose + */ private static final Log logger = LogFactory.getLog(WADLUnmarshaller.class); + /** + * Namespace for the context + */ private static NamespaceContext aNamespaceContext; + /** + * List of the different call method + */ private List<CallMethod> listOfCallMethod = new ArrayList<CallMethod>(); + /** + * Factory to build Document + */ private DocumentBuilderFactory aDocumentBuilderFactory; + + /** + * Document builder + */ private DocumentBuilder aDocumentBuilder; + + /** + * Document XML + */ private Document aDocument; - private XPath aXPath; - - + /** - * Description of a observer to complete with information from a RDF file. + * Path for the document */ - //private ObserverDescription aObserverDescription = null; + private XPath aXPath; + /** + * Description of a observer to complete with information from a WADL file. + */ private String sID = new String(); + private LocalizedString aLocalizedStringName = new LocalizedString(); + private LocalizedString aLocalizedStringDescription = new LocalizedString(); + private LocalizedString aLocalizedStringHelpLocation = new LocalizedString(); + private LocalizedString aLocalizedStringProvider = new LocalizedString(); + private List<MimeType> listOfMimeType = new ArrayList<MimeType>(); + private String responseType; - - //name of parameter lang if observer has one + + /** + * name of parameter lang if observer has one + */ private String nameOfLangParameter = null; - + /** * Map of different input method handle by the observer. */ private Map<EnumInputMethod, InputMethod> mapOfInputMethod = new LinkedHashMap<EnumInputMethod, InputMethod>(); - - public WADLUnmarshallerXPath () throws ParserConfigurationException { + /** + * Create the object to Unmarshall WADL with XPATH + * + * @throws ParserConfigurationException + */ + public WADLUnmarshallerXPath() throws ParserConfigurationException { WADLUnmarshallerXPath.logger.trace("Constructor"); this.aDocumentBuilderFactory = DocumentBuilderFactory.newInstance(); - this.aDocumentBuilder = this.aDocumentBuilderFactory.newDocumentBuilder(); + this.aDocumentBuilder = this.aDocumentBuilderFactory + .newDocumentBuilder(); this.aXPath = XPathFactory.newInstance().newXPath(); - this.aXPath.setNamespaceContext(WADLUnmarshallerXPath.aNamespaceContext); + this.aXPath + .setNamespaceContext(WADLUnmarshallerXPath.aNamespaceContext); } - public void addURL (final URL aURL) throws SAXException, IOException { + /** + * Get the document from an URL + */ + public void addURL(final URL aURL) throws SAXException, IOException { WADLUnmarshallerXPath.logger.trace("addURL"); if (WADLUnmarshallerXPath.logger.isDebugEnabled()) { WADLUnmarshallerXPath.logger.debug("URL : " + aURL + "."); } this.aDocument = this.aDocumentBuilder.parse(aURL.openStream()); - + } - - - - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.w3c.unicorn.contract.WADLUnmarshaller#unmarshal(java.net.URL) */ public void unmarshal() throws XPathExpressionException, - ParserConfigurationException, SAXException, IOException, MimeTypeParseException { + ParserConfigurationException, SAXException, IOException, + MimeTypeParseException { WADLUnmarshallerXPath.logger.trace("unmarshal"); this.parseDocsHeader(); this.parseMethods(); } - private void parseDocsHeader() throws XPathExpressionException, MimeTypeParseException { - final Node aNodeResource = this.aDocument.getElementsByTagName("resources").item(0); - XPathExpression aXPathExpression = this.aXPath.compile("//resource/doc"); - NodeList aNodeListResult = (NodeList) aXPathExpression.evaluate(aNodeResource,XPathConstants.NODESET); - for (int i=0; i<aNodeListResult.getLength(); i++) { + /** + * Parse the header of the WADL file + * + * @throws XPathExpressionException + * error in the XPATH browsing of the document + * @throws MimeTypeParseException + * error in the mime-type of the document + */ + private void parseDocsHeader() throws XPathExpressionException, + MimeTypeParseException { + final Node aNodeResource = this.aDocument.getElementsByTagName( + "resources").item(0); + XPathExpression aXPathExpression = this.aXPath + .compile("//resource/doc"); + NodeList aNodeListResult = (NodeList) aXPathExpression.evaluate( + aNodeResource, XPathConstants.NODESET); + for (int i = 0; i < aNodeListResult.getLength(); i++) { Node nodeDoc = aNodeListResult.item(i); - + String vText = nodeDoc.getTextContent(); - - //parcours les attrb d un doc + + // parcours les attrb d un doc String vTitle = null; String vLang = null; NamedNodeMap nnm = nodeDoc.getAttributes(); - for (int j=0; j<nnm.getLength(); j++) { + for (int j = 0; j < nnm.getLength(); j++) { String attrName = nnm.item(j).getNodeName(); String attrValue = nnm.item(j).getNodeValue(); if ("title".equals(attrName)) { @@ -128,7 +178,7 @@ vLang = attrValue; } } - + if ("name".equals(vTitle)) { aLocalizedStringName.addLocalization(vLang, vText); } else if ("description".equals(vTitle)) { @@ -138,24 +188,38 @@ } else if ("provider".equals(vTitle)) { aLocalizedStringProvider.addLocalization(vLang, vText); } else if ("paramLang".equals(vTitle)) { - nameOfLangParameter=vText; + nameOfLangParameter = vText; } else if ("mimetype".equals(vTitle)) { listOfMimeType.add(new MimeType(vText)); } else if ("reference".equals(vTitle)) { - sID=vText; + sID = vText; } else if ("responseType".equals(vTitle)) { - responseType=vText; + responseType = vText; } } } - + + /** + * Parse all the methods of the document + * + * @throws ParserConfigurationException + * Error in the configuration of the parser + * @throws SAXException + * error in the XML DOM + * @throws IOException + * error in the input/output + * @throws XPathExpressionException + * error in the evaluation of the XPATH query + */ private void parseMethods() throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { WADLUnmarshallerXPath.logger.trace("parseMethods"); // base uri - final Node aNodeResource = this.aDocument.getElementsByTagName("resources").item(0); - final String sBaseURI = aNodeResource.getAttributes().getNamedItem("base").getNodeValue(); + final Node aNodeResource = this.aDocument.getElementsByTagName( + "resources").item(0); + final String sBaseURI = aNodeResource.getAttributes().getNamedItem( + "base").getNodeValue(); final NodeList aNodeListMethod = this.aDocument .getElementsByTagName("method"); @@ -168,36 +232,47 @@ // URI of the resource (will be appended to the base URI) final String sResourceURI; - sResourceURI = aNodeMethod.getParentNode().getAttributes().getNamedItem("path").getNodeValue(); + sResourceURI = aNodeMethod.getParentNode().getAttributes() + .getNamedItem("path").getNodeValue(); // Type : GET/POST and id of the method - final NamedNodeMap aNamedNodeMapAttribute = aNodeMethod.getAttributes(); - final String sName = aNamedNodeMapAttribute.getNamedItem("name").getNodeValue(); + final NamedNodeMap aNamedNodeMapAttribute = aNodeMethod + .getAttributes(); + final String sName = aNamedNodeMapAttribute.getNamedItem("name") + .getNodeValue(); final boolean bPost = "POST".equals(sName.trim()); - final String sMethodID = aNamedNodeMapAttribute.getNamedItem("id").getNodeValue().trim(); + final String sMethodID = aNamedNodeMapAttribute.getNamedItem("id") + .getNodeValue().trim(); // Query variables - XPathExpression aXPathExpression = this.aXPath.compile("//method[@id='" + sMethodID + "']//param"); - NodeList aNodeListResult = (NodeList) aXPathExpression.evaluate(aNodeMethod,XPathConstants.NODESET); - + XPathExpression aXPathExpression = this.aXPath + .compile("//method[@id='" + sMethodID + "']//param"); + NodeList aNodeListResult = (NodeList) aXPathExpression.evaluate( + aNodeMethod, XPathConstants.NODESET); + // iterate over param list for (int j = 0; j < aNodeListResult.getLength(); j++) { - final NamedNodeMap aNamedNodeMap = aNodeListResult.item(j).getAttributes(); + final NamedNodeMap aNamedNodeMap = aNodeListResult.item(j) + .getAttributes(); final CallParameter aCallParameter = new CallParameter(); - + // iterate over attributes for (int k = 0; k < aNamedNodeMap.getLength(); k++) { final Node aNodeCurrentAttribute = aNamedNodeMap.item(k); - final String sAttributeName = aNodeCurrentAttribute.getNodeName(); - final String sAttributeValue = aNodeCurrentAttribute.getNodeValue(); + final String sAttributeName = aNodeCurrentAttribute + .getNodeName(); + final String sAttributeValue = aNodeCurrentAttribute + .getNodeValue(); if ("name".equals(sAttributeName)) { aCallParameter.setName(sAttributeValue); } else if ("required".equals(sAttributeName)) { - aCallParameter.setRequired("true".equals(sAttributeValue)); + aCallParameter.setRequired("true" + .equals(sAttributeValue)); } else if ("repeating".equals(sAttributeName)) { - aCallParameter.setRepeating("true".equals(sAttributeValue)); + aCallParameter.setRepeating("true" + .equals(sAttributeValue)); } else if ("fixed".equals(sAttributeName)) { aCallParameter.setFixed(sAttributeValue); } else if ("style".equals(sAttributeName)) { @@ -210,38 +285,44 @@ aCallParameter.setDefaultValue(sAttributeValue); } } // iterate over attributes - + // read option type - - XPathExpression aOptionXPathExpression = this.aXPath.compile("//method[@id='"+sMethodID+"']//request//param[@name='"+aCallParameter.getName()+"']//option"); - NodeList aOptionNodeListResult = (NodeList) aOptionXPathExpression.evaluate(aNodeMethod,XPathConstants.NODESET); - - for (int k=0; k < aOptionNodeListResult.getLength(); k++) { - aCallParameter.addValue(aOptionNodeListResult.item(k).getAttributes().item(0).getNodeValue()); + + XPathExpression aOptionXPathExpression = this.aXPath + .compile("//method[@id='" + sMethodID + + "']//request//param[@name='" + + aCallParameter.getName() + "']//option"); + NodeList aOptionNodeListResult = (NodeList) aOptionXPathExpression + .evaluate(aNodeMethod, XPathConstants.NODESET); + + for (int k = 0; k < aOptionNodeListResult.getLength(); k++) { + aCallParameter.addValue(aOptionNodeListResult.item(k) + .getAttributes().item(0).getNodeValue()); } - - mapOfCallParameter.put(new String(aCallParameter.getName()),aCallParameter); - + + mapOfCallParameter.put(new String(aCallParameter.getName()), + aCallParameter); + } // iterate over query_variable list - - + final CallMethod aCallMethod = new CallMethod(new URL(sBaseURI + sResourceURI), bPost, sName, sMethodID, mapOfCallParameter); this.listOfCallMethod.add(aCallMethod); - - - //remplir mapOfInputMethod - + + // remplir mapOfInputMethod + NodeList listChildMethod = aNodeMethod.getChildNodes(); - String sInputMethod=null; - String sInputParamName=null; + String sInputMethod = null; + String sInputParamName = null; for (int j = 0; j < listChildMethod.getLength(); j++) { Node childMethod = listChildMethod.item(j); if ("doc".equals(childMethod.getNodeName())) { - String firstAttrName = childMethod.getAttributes().item(0).getNodeName(); + String firstAttrName = childMethod.getAttributes().item(0) + .getNodeName(); if ("title".equals(firstAttrName)) { - String firstAttrValue = childMethod.getAttributes().item(0).getNodeValue(); + String firstAttrValue = childMethod.getAttributes() + .item(0).getNodeValue(); if ("inputMethod".equals(firstAttrValue)) sInputMethod = childMethod.getTextContent(); else if ("inputParamName".equals(firstAttrValue)) @@ -249,86 +330,60 @@ } } } - + InputMethod aInputMethod = new InputMethod(); aInputMethod.setCallMethod(aCallMethod); - aInputMethod.setCallParameter(aCallMethod.getCallParameterByName(sInputParamName)); + aInputMethod.setCallParameter(aCallMethod + .getCallParameterByName(sInputParamName)); aInputMethod.setListOfMimeType(this.listOfMimeType); - //aInputMethod.setCallParameter(aInputMethod.getCallMethod().getMapOfCallParameter().get(sParameterName)); + // aInputMethod.setCallParameter(aInputMethod.getCallMethod().getMapOfCallParameter().get(sParameterName)); if ("URI".equals(sInputMethod)) { this.mapOfInputMethod.put(EnumInputMethod.URI, aInputMethod); - } else if ("UPLOAD".equals(sInputMethod)){ + } else if ("UPLOAD".equals(sInputMethod)) { this.mapOfInputMethod.put(EnumInputMethod.UPLOAD, aInputMethod); - } else if ("DIRECT".equals(sInputMethod)){ - this.mapOfInputMethod.put(EnumInputMethod.DIRECT, aInputMethod); + } else if ("DIRECT".equals(sInputMethod)) { + this.mapOfInputMethod.put(EnumInputMethod.DIRECT, aInputMethod); } - - - - - + } } - - - - - - - - - - - - - - - - - - - - - - - - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.w3c.unicorn.contract.WADLUnmarshaller#getMethods() */ public List<CallMethod> getListOfCallMethod() { return this.listOfCallMethod; } + /** + * Gets the Namespace URI and the prefix + */ static { WADLUnmarshallerXPath.aNamespaceContext = new NamespaceContext() { public String getNamespaceURI(final String sPrefix) { if ("xs".equals(sPrefix)) { return "http://www.w3.org/2001/XMLSchema"; - } - else if ("uco".equals(sPrefix)) { + } else if ("uco".equals(sPrefix)) { return "http://www.w3.org/unicorn/observationresponse"; - } - else { + } else { return null; } } - public String getPrefix (final String sNamespaceURI) { - if ("http://www.w3.org/2001/XMLSchema" - .equals(sNamespaceURI)) { + public String getPrefix(final String sNamespaceURI) { + if ("http://www.w3.org/2001/XMLSchema".equals(sNamespaceURI)) { return "xs"; - } - else if ("http://www.w3.org/unicorn/observationresponse" + } else if ("http://www.w3.org/unicorn/observationresponse" .equals(sNamespaceURI)) { return "uco"; - } - else { + } else { return null; } } - public Iterator getPrefixes (final String sNamespaceURI) { + public Iterator getPrefixes(final String sNamespaceURI) { return null; } @@ -362,19 +417,23 @@ public LocalizedString getProvider() { return this.aLocalizedStringProvider; } - - public static void main (final String[] args) throws Exception { + + public String getResponseType() { + return responseType; + } + + /** + * Main method of the class only for testing purpose + * + * @param args + * @throws Exception + */ + public static void main(final String[] args) throws Exception { final WADLUnmarshaller t = new WADLUnmarshallerXPath(); t.addURL(new URL("http://localhost/css.wadl")); t.unmarshal(); System.out.println(t.getID()); - - /* - for (CallMethod cm : t.getListOfCallMethod()) { - System.out.println(cm); - System.out.println("---------------------------------"); - } - */ + System.out.println(t.getMapOfInputMethod()); System.out.println("***************************************"); for (InputMethod im : t.getMapOfInputMethod().values()) { @@ -383,7 +442,4 @@ } } - public String getResponseType() { - return responseType; - } } Index: InputMethod.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/InputMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- InputMethod.java 20 Feb 2008 15:37:13 -0000 1.3 +++ InputMethod.java 17 Jun 2008 13:41:12 -0000 1.4 @@ -9,46 +9,101 @@ import javax.activation.MimeType; - /** * @author Damien LEROY - * + * */ public class InputMethod { + /** + * Method of the call + */ private CallMethod aCallMethod = null; + + /** + * Parameter of the call + */ private CallParameter aCallParameter = null; + + /** + * List of the mime-types of the calls + */ private List<MimeType> listOfMimeType = null; - public InputMethod () { + /** + * Set the list of mime-types + */ + public InputMethod() { this.listOfMimeType = new ArrayList<MimeType>(); } - public CallMethod getCallMethod () { + /** + * Get the current calling method + * + * @return current calling method + */ + public CallMethod getCallMethod() { return this.aCallMethod; } - public void setCallMethod (final CallMethod aCallMethod) { + /** + * Set the method of the call + * + * @param aCallMethod + * new calling method to add + */ + public void setCallMethod(final CallMethod aCallMethod) { this.aCallMethod = aCallMethod; } - public CallParameter getCallParameter () { + /** + * Get the current call parameter + * + * @return the current call parameter + */ + public CallParameter getCallParameter() { return this.aCallParameter; } - public void setCallParameter (final CallParameter aCallParameter) { + /** + * Set the current Call parameter + * + * @param aCallParameter + * call parameter to set + */ + public void setCallParameter(final CallParameter aCallParameter) { this.aCallParameter = aCallParameter; } - public CallParameter getCallParameterByName (final String sCallParameterName) { + /** + * Get a parameter by its name + * + * @param sCallParameterName + * name of the parameter to look for + * @return the parameter researched + */ + public CallParameter getCallParameterByName(final String sCallParameterName) { return aCallMethod.getCallParameterByName(sCallParameterName); } - public void addMimeType (final MimeType aMimeType) { + /** + * Add a mime-type + * + * @param aMimeType + * mime-type to add + */ + public void addMimeType(final MimeType aMimeType) { this.listOfMimeType.add(aMimeType); } - public boolean canHandleMimeType (final MimeType aMimeType) { + /** + * Tells if the mime-types can be handled + * + * @param aMimeType + * mime-type to check + * @return true if the mime type is handled + */ + public boolean canHandleMimeType(final MimeType aMimeType) { for (final MimeType handler : this.listOfMimeType) { if (handler.match(aMimeType)) { return true; @@ -57,29 +112,37 @@ return false; } - /* (non-Javadoc) - * @see java.lang.Object#toString() + /** + * Set the list of the MIME-Types + * + * @param listOfMimeType + * list of the mime-type */ - public final String toString () { + public void setListOfMimeType(List<MimeType> listOfMimeType) { + this.listOfMimeType = listOfMimeType; + } + + /** + * Prints the object + */ + public final String toString() { final int iStringBufferSize = 1000; final String sVariableSeparator = "\n"; final StringBuffer aStringBuffer = new StringBuffer(iStringBufferSize); aStringBuffer.append("/BeginInputMethod/"); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("CallMethod:{").append(this.aCallMethod).append("}"); + aStringBuffer.append("CallMethod:{").append(this.aCallMethod).append( + "}"); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("CallParameter:{").append(this.aCallParameter).append("}"); + aStringBuffer.append("CallParameter:{").append(this.aCallParameter) + .append("}"); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("MimeType:{").append(this.listOfMimeType).append("}"); + aStringBuffer.append("MimeType:{").append(this.listOfMimeType).append( + "}"); aStringBuffer.append(sVariableSeparator); aStringBuffer.append("/EndInputMethod/"); - - return aStringBuffer.toString(); - } - public void setListOfMimeType(List<MimeType> listOfMimeType) { - this.listOfMimeType = listOfMimeType; + return aStringBuffer.toString(); } - } Index: WADLUnmarshaller.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/WADLUnmarshaller.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WADLUnmarshaller.java 20 Feb 2008 15:19:58 -0000 1.3 +++ WADLUnmarshaller.java 17 Jun 2008 13:41:12 -0000 1.4 @@ -22,19 +22,19 @@ public abstract List<CallMethod> getListOfCallMethod(); Map<EnumInputMethod, InputMethod> getMapOfInputMethod(); - - public String getID (); - public LocalizedString getName (); + public String getID(); - public LocalizedString getDescription (); + public LocalizedString getName(); + + public LocalizedString getDescription(); + + public LocalizedString getHelpLocation(); + + public LocalizedString getProvider(); + + public String getNameOfLangParameter(); - public LocalizedString getHelpLocation (); - - public LocalizedString getProvider (); - - public String getNameOfLangParameter (); - public String getResponseType(); } \ No newline at end of file
Received on Tuesday, 17 June 2008 13:41:51 UTC