- From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 19 Sep 2008 18:57:14 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/contract In directory hutz:/tmp/cvs-serv10640/org/w3c/unicorn/contract Modified Files: InputMethod.java Observer.java WADLUnmarshaller.java WADLUnmarshallerXPath.java Removed Files: RDFContractUnmarshaller.java RDFContractUnmarshallerJena.java Log Message: MimeTypes work again for DirectInput Index: Observer.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/Observer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Observer.java 17 Jun 2008 13:41:12 -0000 1.5 +++ Observer.java 19 Sep 2008 18:57:11 -0000 1.6 @@ -71,6 +71,8 @@ */ private Map<EnumInputMethod, InputMethod> mapOfInputMethod; + private List<MimeType> supportedMimeTypes; + /** * Creates the observer * @@ -149,7 +151,7 @@ * Prints the object */ public String toString() { - final int sbSize = 1000; + final int sbSize = 1000; final String sVariableSeparator = "\n"; final StringBuffer aStringBuffer = new StringBuffer(sbSize); @@ -174,7 +176,7 @@ .append("]"); return aStringBuffer.toString(); - } + } public final Map<EnumInputMethod, InputMethod> getMapOfInputMethod() { return this.mapOfInputMethod; @@ -199,59 +201,58 @@ return this.mapOfInputMethod.get(aEnumInputMethod); } + public InputMethod getBestInputMethod(final EnumInputMethod preferred) { + // First try to get what caller would like + InputMethod im = getInputMethod(preferred); + if(im != null) { + return im; + } + + // If not possible, grab another one + for (final EnumInputMethod aEIM : EnumInputMethod.values()) { + im = getInputMethod(aEIM); + if(im != null) { + return im; + } + } + + // we should not arrive here (that would mean an observer doesn't + // have any input method + return null; + } + public CallMethod getCallMethod(final EnumInputMethod aEnumInputMethod) { return this.getInputMethod(aEnumInputMethod).getCallMethod(); } - public void addMimeType(final EnumInputMethod aEnumInputMethod, - final MimeType aMimeType) { - this.mapOfInputMethod.get(aEnumInputMethod).addMimeType(aMimeType); + public void addMimeType(final MimeType aMimeType) { + this.supportedMimeTypes.add(aMimeType); } /** - * Tells of the mime-type is handled + * Returns <code>true</code> if the mime-type is supported + * by this observer * * @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); - if (null == aInputMethod) { - return false; - } - return aInputMethod.canHandleMimeType(aMimeType); + public boolean canHandleMimeType(final MimeType aMimeType) { + //return this.supportedMimeTypes.contains(aMimeType); + // equals and thus contains doesn't work :( + for (final MimeType mt : this.supportedMimeTypes) { + if(mt.match(aMimeType)) return true; + } + return false; } - /** - * Return a list of EnumInputMethod with this observer handler mime type - * given in parameter. - * - * @param 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); - if (null == aInputMethod) { - Observer.logger.warn("Input method of type " + aEnumInputMethod - + " does not exist for observer " + this.getID() + "."); - continue; - } - if (aInputMethod.canHandleMimeType(aMimeType)) { - return true; - } - } - return false; - } + public void setSupportedMimeTypes(List<MimeType> mimeTypes) { + this.supportedMimeTypes = mimeTypes; + } + + public List<MimeType> getSupportedMimeTypes() { + return this.supportedMimeTypes; + } public String getResponseType() { return responseType; --- RDFContractUnmarshaller.java DELETED --- --- RDFContractUnmarshallerJena.java DELETED --- Index: WADLUnmarshallerXPath.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- WADLUnmarshallerXPath.java 8 Sep 2008 12:48:38 -0000 1.8 +++ WADLUnmarshallerXPath.java 19 Sep 2008 18:57:12 -0000 1.9 @@ -341,12 +341,10 @@ } } - InputMethod aInputMethod = new InputMethod(); + InputMethod aInputMethod = new InputMethod(sInputMethod); aInputMethod.setCallMethod(aCallMethod); aInputMethod.setCallParameter(aCallMethod .getCallParameterByName(sInputParamName)); - aInputMethod.setListOfMimeType(this.listOfMimeType); - // aInputMethod.setCallParameter(aInputMethod.getCallMethod().getMapOfCallParameter().get(sParameterName)); if ("URI".equals(sInputMethod)) { this.mapOfInputMethod.put(EnumInputMethod.URI, aInputMethod); } else if ("UPLOAD".equals(sInputMethod)) { @@ -432,6 +430,10 @@ return responseType; } + public List<MimeType> getSupportedMimeTypes() { + return this.listOfMimeType; + } + /** * Main method of the class only for testing purpose * Index: InputMethod.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/InputMethod.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- InputMethod.java 17 Jun 2008 13:41:12 -0000 1.4 +++ InputMethod.java 19 Sep 2008 18:57:11 -0000 1.5 @@ -7,8 +7,6 @@ import java.util.ArrayList; import java.util.List; -import javax.activation.MimeType; - /** * @author Damien LEROY * @@ -25,17 +23,25 @@ */ private CallParameter aCallParameter = null; - /** - * List of the mime-types of the calls - */ - private List<MimeType> listOfMimeType = null; + private EnumInputMethod method; - /** - * Set the list of mime-types - */ - public InputMethod() { - this.listOfMimeType = new ArrayList<MimeType>(); - } + public InputMethod(EnumInputMethod method) { + this.method = method; + } + + public InputMethod(String method) { + if ("URI".equals(method)) { + this.method = EnumInputMethod.URI; + } else if ("UPLOAD".equals(method)) { + this.method = EnumInputMethod.UPLOAD; + } else if ("DIRECT".equals(method)) { + this.method = EnumInputMethod.DIRECT; + } + } + + public EnumInputMethod getMethod() { + return this.method; + } /** * Get the current calling method @@ -87,42 +93,6 @@ } /** - * Add a mime-type - * - * @param aMimeType - * mime-type to add - */ - public void addMimeType(final MimeType aMimeType) { - this.listOfMimeType.add(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; - } - } - return false; - } - - /** - * Set the list of the MIME-Types - * - * @param listOfMimeType - * list of the mime-type - */ - public void setListOfMimeType(List<MimeType> listOfMimeType) { - this.listOfMimeType = listOfMimeType; - } - - /** * Prints the object */ public final String toString() { @@ -137,9 +107,6 @@ aStringBuffer.append("CallParameter:{").append(this.aCallParameter) .append("}"); aStringBuffer.append(sVariableSeparator); - aStringBuffer.append("MimeType:{").append(this.listOfMimeType).append( - "}"); - aStringBuffer.append(sVariableSeparator); aStringBuffer.append("/EndInputMethod/"); return aStringBuffer.toString(); Index: WADLUnmarshaller.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/contract/WADLUnmarshaller.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- WADLUnmarshaller.java 17 Jun 2008 13:41:12 -0000 1.4 +++ WADLUnmarshaller.java 19 Sep 2008 18:57:11 -0000 1.5 @@ -10,6 +10,8 @@ import org.w3c.unicorn.util.LocalizedString; import org.w3c.unicorn.util.Unmarshaller; +import javax.activation.MimeType; + /** * WADLUnmarshallerXPath<br /> * Created: May 24, 2006 12:34:38 PM<br /> @@ -37,4 +39,6 @@ public String getResponseType(); -} \ No newline at end of file + public List<MimeType> getSupportedMimeTypes(); + +}
Received on Friday, 19 September 2008 18:57:49 UTC