commit d8c0f69ad42c803d2363cfcfb7d138aa3933be61 Author: rpidikiti Date: Wed Jul 6 07:45:16 2011 -0700 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..e676162d04f --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +java/wordnik*.zip +java/*.ipr +java/*.iml +java/*.iws +java/dist/ +java/build/ +java/lib/*.jar +java/META-INF/ +java/web/ +java/index +java/reports/ +java/lib/*.zip +java/logs +java/src/main/java/com/wordnik/env/Version.scala +java/lib/*.pom +java/version.properties +java/out +android/codegen/build/ +*.iml +out/ +*.ipr +*.iws +version.properties +android/codegen/lib/ +android/driver/lib/ +android/driver/build/ +android/driver-test/build/ +android/driver-test/lib/*.jar diff --git a/README b/README new file mode 100644 index 00000000000..e69de29bb2d diff --git a/android/codegen/README b/android/codegen/README new file mode 100644 index 00000000000..e69de29bb2d diff --git a/android/codegen/build.xml b/android/codegen/build.xml new file mode 100644 index 00000000000..b5ea187ea2f --- /dev/null +++ b/android/codegen/build.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/codegen/conf/templates/ModelObject.st b/android/codegen/conf/templates/ModelObject.st new file mode 100644 index 00000000000..ebaeadc9827 --- /dev/null +++ b/android/codegen/conf/templates/ModelObject.st @@ -0,0 +1,38 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +$imports:{ import | +import $import$; +}$ + +/** + * $model.description$ + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class $className$ extends WordnikObject { + + $fields:{ field | + //$field.description$ + private $field.attributeDefinition.returnType$ $field.attributeDefinition.name$ $field.attributeDefinition.initialization$; + }$ + + $fields:{ field | + //$field.description$ + $if(field.required)$ + @Required $endif$ + $if(field.allowableValues)$ + @AllowableValues(value="$field.allowableValues$")$endif$ + public $field.attributeDefinition.returnType$ get$field.attributeDefinition.NameForMethod$() { + return $field.attributeDefinition.name$; + } + + public void set$field.attributeDefinition.NameForMethod$($field.attributeDefinition.returnType$ $field.attributeDefinition.name$) { + this.$field.attributeDefinition.name$ = $field.attributeDefinition.name$; + } + }$ +} \ No newline at end of file diff --git a/android/codegen/conf/templates/ModelObjectNew.st b/android/codegen/conf/templates/ModelObjectNew.st new file mode 100644 index 00000000000..888995d4e64 --- /dev/null +++ b/android/codegen/conf/templates/ModelObjectNew.st @@ -0,0 +1,74 @@ +package com.wordnik.model; + +import org.json.JSONObject +import org.json.JSONArray +import org.json.JSONException +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +$imports:{ import | +import $import$; +}$ + +/** + * $model.description$ + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class $className$ extends WordnikObject { + + $fields:{ field | + //$field.description$ + private $field.attributeDefinition.returnType$ $field.attributeDefinition.name$ $field.attributeDefinition.initialization$; + }$ + + $fields:{ field | + //$field.description$ + $if(field.required)$ + @Required $endif$ + $if(field.allowableValues)$ + @AllowableValues(value="$field.allowableValues$")$endif$ + public $field.attributeDefinition.returnType$ get$field.attributeDefinition.NameForMethod$() { + return $field.attributeDefinition.name$; + } + + public void set$field.attributeDefinition.NameForMethod$($field.attributeDefinition.returnType$ $field.attributeDefinition.name$) { + this.$field.attributeDefinition.name$ = $field.attributeDefinition.name$; + } + }$ + + public $className$ fromJSON(String json) { + JSONObject jso; + try { + jso = new JSONObject(json); + } catch(Exception e) { + // ignore for now + } + + try { + $fields:{ field | + if($field.attributeDefinition.returnType$.equals("Int")) { + jso.getInt("$field.attributeDefinition.name$"); + } else if($field.attributeDefinition.returnType$.equals("Long")) { + jso.getLong("$field.attributeDefinition.name$"); + } else if($field.attributeDefinition.returnType$.equals("Double")) { + jso.getDouble("$field.attributeDefinition.name$"); + } else if($field.attributeDefinition.returnType$.equals("String")) { + jso.getString("$field.attributeDefinition.name$"); + } else if($field.attributeDefinition.returnType$.equals("Boolean")) { + jso.getBoolean("$field.attributeDefinition.name$"); + } else if($field.attributeDefinition.returnType$.startsWith("List[")) { + // JSONArray + } else if($field.attributeDefinition.returnType$.startsWith("Map[")) { + // JSONArray + } else { + // JSONObject + } + }$ + } catch (JSONException e) { + // ignore for now + } + } +} \ No newline at end of file diff --git a/android/codegen/conf/templates/ResourceObject.st b/android/codegen/conf/templates/ResourceObject.st new file mode 100644 index 00000000000..e46bee3e3ec --- /dev/null +++ b/android/codegen/conf/templates/ResourceObject.st @@ -0,0 +1,121 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class $resource$ extends $extends$ { + +$methods:{ method | + /** + * $method.description$ +$method.arguments:{ argument | + * @param $argument.name$ $argument.description$ +$if(argument.allowedValues)$ + * Allowed values are - $argument.allowedValues$ +$endif$ +}$ + * + * @return $method.returnValue$ {@link $method.returnClassName$} + * @throws WordnikAPIException $method.exceptionDescription$ + */ +$if(method.hasArguments)$ + @MethodArgumentNames(value="$method.argumentNames; separator=", "$") +$endif$ + + public static $method.returnValue$ $method.name$($method.argumentDefinitions; separator=", "$) throws WordnikAPIException { + +$if(method.authToken)$ + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } +$endif$ + + //parse inputs + String resourcePath = "$method.resourcePath$"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "$method.methodType$"; + Map queryParams = new HashMap(); +$if(!method.inputModel)$ +$method.queryParameters:{ argument | + if( $argument.name$ != null) { + queryParams.put("$argument.name$", $argument.name$); + } +}$ +$method.pathParameters:{ argument | + if( $argument.name$ != null) { + resourcePath = resourcePath.replace("{$argument.name$}", $argument.name$); + } +}$ +$endif$ +$if(method.inputModel)$ +$method.queryParameters:{ argument | + if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) { + queryParams.put("$argument.name$", $argument.methodNameFromModelClass$); + } +}$ +$method.pathParameters:{ argument | + if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) { + resourcePath = resourcePath.replace("{$argument.name$}", $argument.methodNameFromModelClass$); + } +}$ +$endif$ + //make the API Call +$if(method.postObject)$ +$if(method.authToken)$ + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); +$endif$ +$if(!method.authToken)$ + String response = invokeAPI(null, resourcePath, method, queryParams, postObject); +$endif$ +$endif$ + +$if(!method.postObject)$ +$if(method.authToken)$ + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); +$endif$ +$if(!method.authToken)$ + String response = invokeAPI(null, resourcePath, method, queryParams, null); +$endif$ +$endif$ + + //create output objects if the response has more than one object +$if(!method.responseVoid)$ + if(response == null || response.length() == 0){ + return null; + } +$if(!method.returnValueList)$ + $method.returnValue$ responseObject = ($method.returnValue$)deserialize(response, $method.returnClassName$.class); + return responseObject; +$endif$ +$if(method.returnValueList)$ + TypeReference> typeRef = new TypeReference>() { + }; + try { + List<$method.returnClassName$> responseObject = (List<$method.returnClassName$>) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } +$endif$ +$endif$ + } + + +}$ +} diff --git a/android/codegen/conf/templates/VersionChecker.st b/android/codegen/conf/templates/VersionChecker.st new file mode 100644 index 00000000000..69365de2aca --- /dev/null +++ b/android/codegen/conf/templates/VersionChecker.st @@ -0,0 +1,18 @@ +package com.wordnik.api; + +/** + * Maintains the compatible server version against which the drive is written + * @author ramesh + * + */ +public class VersionChecker { + + private String compatibleVersion = "$apiVersion$"; + + /** + * Gets the version against which the driver code was written + */ + public String getCompatibleVersion() { + return compatibleVersion; + } +} \ No newline at end of file diff --git a/android/codegen/ivy.xml b/android/codegen/ivy.xml new file mode 100644 index 00000000000..d53a4644f9e --- /dev/null +++ b/android/codegen/ivy.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/codegen/src/main/java/com/wordnik/android/codegen/DriverCodeGenerator.java b/android/codegen/src/main/java/com/wordnik/android/codegen/DriverCodeGenerator.java new file mode 100644 index 00000000000..4252ff35957 --- /dev/null +++ b/android/codegen/src/main/java/com/wordnik/android/codegen/DriverCodeGenerator.java @@ -0,0 +1,367 @@ +package com.wordnik.codegen; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.wordnik.exception.CodeGenerationException; + +import org.antlr.stringtemplate.StringTemplate; +import org.antlr.stringtemplate.StringTemplateGroup; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.DeserializationConfig.Feature; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +/** + * Created by IntelliJ IDEA. + * User: ramesh + * Date: 3/30/11 + * Time: 6:59 PM + * To change this template use File | Settings | File Templates. + */ +public class DriverCodeGenerator { + + private static String HEADER_NAME_API_VERSION = "Wordnik-Api-Version"; + private static String VERSION_OBJECT_TEMPLATE = "VersionChecker"; + private static String MODEL_OBJECT_TEMPLATE = "ModelObject"; + private static String API_OBJECT_TEMPLATE = "ResourceObject"; + + public static void main(String[] args) { + DriverCodeGenerator codeGenerator = new DriverCodeGenerator(); + codeGenerator.generateCode(); + } + + /** + * Generate classes needed for the model and API invocation + */ + public void generateCode() { + //read resources and get their documentation + List resources = this.readResourceDocumentation( + "http://beta.wordnik.com/v4/", "word.json,words.json,wordList.json,wordLists.json,account.json"); + StringTemplateGroup aTemplateGroup = new StringTemplateGroup("templates","conf/templates"); + if(resources.size() > 0) { + generateVersionHelper(resources.get(0).getVersion(), aTemplateGroup); + } + generateModelClasses(resources, aTemplateGroup); + generateAssemblerClassesForOutput(resources, aTemplateGroup); + generateModelClassesForInput(resources, aTemplateGroup); + generateAPIClasses(resources, aTemplateGroup); + } + + /** + * Reads the documentation of the resources and constructs the resource object that can be used + * for generating the driver related classes. The resource list string should be "," separated + */ + private List readResourceDocumentation(String baseUrl, String resourceList) { + + List resourceDocs = new ArrayList(); + + //valid for input + if (baseUrl == null || resourceList == null || + baseUrl.trim().length() == 0 || + resourceList.trim().length() == 0) { + throw new CodeGenerationException("Base URL or Resource list input is null"); + } + + + //create list of resource URL + String[] resources = resourceList.split(","); + List resourceURLs = new ArrayList(); + for (String resource : resources) { + resourceURLs.add(baseUrl + resource); + } + + //make connection to resource and get the documentation + for (String resourceURL : resourceURLs) { + Client apiClient = Client.create(); + WebResource aResource = apiClient.resource(resourceURL); + ClientResponse clientResponse = aResource.get(ClientResponse.class); + String version = clientResponse.getHeaders().get(HEADER_NAME_API_VERSION).get(0); + String response = clientResponse.getEntity(String.class); + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + Resource aResourceDoc = (Resource) mapper.readValue(response, Resource.class); + aResourceDoc.setVersion(version); + resourceDocs.add(aResourceDoc); + } catch (IOException ioe) { + throw new CodeGenerationException("Erro in coversting response json value to java object"); + } + } + return resourceDocs; + + } + + /** + * Generates version file based on the version number received from the doc calls. This version file is used + * while making the API calls to make sure Client and back end are compatible. + * @param version + */ + private void generateVersionHelper(String version, StringTemplateGroup templateGroup) { + StringTemplate template = templateGroup.getInstanceOf(VERSION_OBJECT_TEMPLATE); + template.setAttribute("apiVersion", version); + File aFile = new File("../driver/src/main/java/com/wordnik/api/VersionChecker.java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the versioned file: " + ioe.getMessage()); + } + } + + /** + * Generates model classes. If the class is already generated then ignores the same. + */ + private void generateModelClasses(List resources, StringTemplateGroup templateGroup) { + List generatedClassNames = new ArrayList(); + + for(Resource resource: resources) { + for(Model model : resource.getModels()){ + if(!generatedClassNames.contains(model.getName())){ + List imports = new ArrayList(); + imports.add("com.wordnik.common.WordListType"); + for(Parameter param : model.getFields()){ + for(String importDef : param.getAttributeDefinition().getImportDefinitions()){ + if(!imports.contains(importDef)){ + imports.add(importDef); + } + } + } + StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE); + template.setAttribute("fields", model.getFields()); + template.setAttribute("imports", imports); + template.setAttribute("className", model.getGenratedClassName()); + File aFile = new File("../driver/src/main/java/com/wordnik/model/"+model.getGenratedClassName()+".java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the model classes : " + ioe.getMessage()); + } + generatedClassNames.add(model.getName()); + } + } + } + + generateWrapperClassForTestData(generatedClassNames, templateGroup); + } + + /** + * Generates assembler classes if the API returns more than one objects. + * @param resources + * @param templateGroup + */ + private void generateAssemblerClassesForOutput(List resources, StringTemplateGroup templateGroup) { + List generatedClasses = new ArrayList(); + for(Resource resource : resources) { + if(resource.getEndPoints() != null) { + for(Endpoint endpoint : resource.getEndPoints()){ + if(endpoint.getOperations() != null) { + for(EndpointOperation operation : endpoint.getOperations()){ + Model model = operation.getModelObjectForAggregateObject(endpoint); + if(model != null){ + if(!generatedClasses.contains(model.getName())) { + List imports = new ArrayList(); + imports.add("com.wordnik.common.WordListType"); + for(Parameter param : model.getFields()){ + for(String importDef : param.getAttributeDefinition().getImportDefinitions()){ + if(!imports.contains(importDef)){ + imports.add(importDef); + } + } + } + StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE); + template.setAttribute("fields", model.getFields()); + template.setAttribute("imports", imports); + template.setAttribute("className", model.getGenratedClassName()); + File aFile = new File("../driver/src/main/java/com/wordnik/model/"+model.getGenratedClassName()+".java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the assemble classes : " + ioe.getMessage()); + } + generatedClasses.add(model.getName()); + } + } + } + } + } + } + } + } + + /** + * Generates assembler classes if the API returns more than one objects. + * @param resources + * @param templateGroup + */ + private void generateModelClassesForInput(List resources, StringTemplateGroup templateGroup) { + List generatedClasses = new ArrayList(); + for(Resource resource : resources) { + if(resource.getEndPoints() != null) { + for(Endpoint endpoint : resource.getEndPoints()){ + if(endpoint.getOperations() != null) { + for(EndpointOperation operation : endpoint.getOperations()){ + Method method = operation.generateMethod(endpoint, resource);; + if(method.getInputModel() != null) { + Model model = method.getInputModel(); + if(model != null){ + if(!generatedClasses.contains(model.getName())) { + List imports = new ArrayList(); + imports.add("com.wordnik.common.WordListType"); + for(Parameter param : model.getFields()){ + for(String importDef : param.getAttributeDefinition().getImportDefinitions()){ + if(!imports.contains(importDef)){ + imports.add(importDef); + } + } + } + StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE); + + template.setAttribute("fields", model.getFields()); + template.setAttribute("imports", imports); + template.setAttribute("className", model.getGenratedClassName()); + File aFile = new File("../driver/src/main/java/com/wordnik/model/"+model.getGenratedClassName()+".java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the input model classes " + ioe.getMessage()); + } + generatedClasses.add(model.getName()); + } + } + } + } + } + } + } + } + } + + /** + * Generates one API class for each resource and each end point in the resource is translated as method. + * @param resources + * @param templateGroup + */ + private void generateAPIClasses(List resources, StringTemplateGroup templateGroup) { + + for(Resource resource : resources) { + List methods = new ArrayList(); + methods = resource.generateMethods(resource); + StringTemplate template = templateGroup.getInstanceOf(API_OBJECT_TEMPLATE); + String className = resource.generateClassName(); + List filteredMethods = new ArrayList(); + for(Method method:methods){ + if(!CodeGenOverridingRules.isMethodIgnored(className, method.getName())){ + filteredMethods.add(method); + } + } + template.setAttribute("resource", className); + template.setAttribute("methods", filteredMethods); + template.setAttribute("extends", CodeGenOverridingRules.getServiceExtendingClass(className)); + + File aFile = new File("../driver/src/main/java/com/wordnik/api/"+ resource.generateClassName() +".java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the API classes : " + ioe.getMessage()); + } + } + } + + /** + * Creates a wrapper model class that contains all model classes as list of objects. + * This class is used for storing test data + */ + private void generateWrapperClassForTestData(List generatedClassNames, StringTemplateGroup templateGroup) { + Model model = new Model(); + model.setName("TestData"); + model.setDescription("CLass used to store all the test data. Thsi should not be used for any development"); + List parameters = new ArrayList(); + model.setFields(parameters); + for(String className : generatedClassNames){ + Parameter aParam = new Parameter(); + aParam.setName(convertFirstCharToSmall(className)+"List"); + aParam.setParamType("List["+className+"]"); + parameters.add(aParam); + } + + //add missing class from models + Parameter aParam = new Parameter(); + aParam.setName("StringValueList"); + aParam.setParamType("List[StringValue]"); + parameters.add(aParam); + + List imports = new ArrayList(); + imports.add("com.wordnik.common.WordListType"); + imports.add("com.wordnik.common.StringValue"); + + for(Parameter param : model.getFields()){ + for(String importDef : param.getAttributeDefinition().getImportDefinitions()){ + if(!imports.contains(importDef)){ + imports.add(importDef); + } + } + } + StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE); + template.setAttribute("fields", model.getFields()); + template.setAttribute("imports", imports); + template.setAttribute("className", model.getGenratedClassName()); + File aFile = new File("../driver/src/main/java/com/wordnik/model/"+model.getGenratedClassName()+".java"); + try{ + FileWriter aWriter = new FileWriter(aFile); + BufferedWriter bufWriter = new BufferedWriter(aWriter); + bufWriter.write(template.toString()); + bufWriter.close(); + }catch(IOException ioe){ + throw new CodeGenerationException("Error generating the wrapper classes for test data file : " + ioe.getMessage()); + } + } + + /** + * Converts the first character of the input into string. + * Example: If the input is word, the return value will be Word + * @param input + * @return + */ + public static String convertFirstCharToCaps(String input) { + if(input != null && input.length() > 0) { + return input.substring(0,1).toUpperCase() + input.substring(1); + }else{ + throw new CodeGenerationException("Error converting input to first letter caps becuase of null input"); + } + } + + /** + * Converts the first character of the input into string. + * Example: If the input is word, the return value will be Word + * @param input + * @return + */ + public static String convertFirstCharToSmall(String input) { + if(input != null && input.length() > 0) { + return input.substring(0,1).toLowerCase() + input.substring(1); + }else{ + throw new CodeGenerationException("Error converting input to first letter to lower because of null input"); + } + } +} diff --git a/android/driver-test/bin/runandroid.sh b/android/driver-test/bin/runandroid.sh new file mode 100755 index 00000000000..454db86c955 --- /dev/null +++ b/android/driver-test/bin/runandroid.sh @@ -0,0 +1,17 @@ +#!/bin/bash +echo "" > classpath.txt +for file in `ls lib`; + do echo -n 'lib/' >> classpath.txt; + echo -n $file >> classpath.txt; + echo -n ':' >> classpath.txt; +done +for file in `ls build`; + do echo -n 'build/' >> classpath.txt; + echo -n $file >> classpath.txt; + echo -n ':' >> classpath.txt; +done + +export CLASSPATH=$(cat classpath.txt) +export JAVA_OPTS="${JAVA_OPTS} -DrulePath=data -Dproperty=Xmx2g -DloggerPath=$BUILD_COMMON/test-config/log4j.properties" +scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH "$@" + diff --git a/android/driver-test/build.xml b/android/driver-test/build.xml new file mode 100644 index 00000000000..148fd488254 --- /dev/null +++ b/android/driver-test/build.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/driver-test/ivy.xml b/android/driver-test/ivy.xml new file mode 100644 index 00000000000..cf338b359e2 --- /dev/null +++ b/android/driver-test/ivy.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/driver-test/lib/ext/wordnik-java-driver-4.04.0.jar b/android/driver-test/lib/ext/wordnik-java-driver-4.04.0.jar new file mode 100644 index 00000000000..ca8a56361d5 Binary files /dev/null and b/android/driver-test/lib/ext/wordnik-java-driver-4.04.0.jar differ diff --git a/android/driver-test/src/test/java/com/wordnik/test/TestCaseExecutor.java b/android/driver-test/src/test/java/com/wordnik/test/TestCaseExecutor.java new file mode 100644 index 00000000000..6b04abc232e --- /dev/null +++ b/android/driver-test/src/test/java/com/wordnik/test/TestCaseExecutor.java @@ -0,0 +1,275 @@ +package com.wordnik.test; + +import com.wordnik.annotations.MethodArgumentNames; +import com.wordnik.api.WordAPI; +import com.wordnik.common.WordnikAPI; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.exception.WordnikExceptionCodes; +import org.apache.commons.beanutils.BeanUtils; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.type.TypeFactory; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Instance of this class runs single test case + * User: ramesh + * Date: 4/22/11 + * Time: 7:32 AM + */ +public class TestCaseExecutor { + + private static ObjectMapper mapper = new ObjectMapper(); + + /** + * Follow the following argument pattern + * First argument is api + * Second argument is auth token + * Third argument will be name of resource + * Fourth argument will be HTTP method name + * Fifth argument will be suggested methdo name + * 6th argument is for query and path parameters, if not available then gets empty string + * 7th argument is for post data, if not available get empty string + * + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + WordAPI.initialize("c23b746d074135dc9500c0a61300a3cb7647e53ec2b9b658e", "http://beta.wordnik.com/v4/", false); + TestCaseExecutor runner = new TestCaseExecutor(); + String apiKey = args[0]; + String authToken = args[1]; + String resource = args[2]; + String method = args[3]; + String suggestedMethodName = args[4]; + Map queryAndPathParameters = new HashMap(); + String postData = null; + if(args.length > 5 && args[5].length() > 0){ + String[] qpTuple = args[5].split("~"); + for(String tuple: qpTuple){ + String[] nameValue = tuple.split("="); + queryAndPathParameters.put(nameValue[0], nameValue[1]); + } + } + if(args.length > 6 ){ + postData = args[6]; + } + queryAndPathParameters.put("authToken", authToken); + runner.executeTestCase(resource, method, suggestedMethodName, apiKey, authToken, queryAndPathParameters, + postData); + + } + + + private void executeTestCase(String resourceName, String httpMethod, String suggestedName, String apiKey, + String authToken, Map queryAndPathParameters, String postData) { + + String className = getAPIClassName(resourceName); + String methodName = suggestedName; + + //3 + try { + Class apiClass = Class.forName("com.wordnik.api." + className); + Method[] methods = apiClass.getMethods(); + Method methodToExecute = null; + for(Method method : methods){ + if(method.getName().equals(methodName)){ + methodToExecute = method; + break; + } + } + + if(methodToExecute != null) { + //4 + Object[] arguments = populateArgumentsForTestCaseExecution(methodToExecute, queryAndPathParameters, + postData); + Object output = null; + if(arguments != null && arguments.length > 0){ + //5 + output = methodToExecute.invoke(null, arguments); + }else{ + //5 + output = methodToExecute.invoke(null); + } + //6 + System.out.println("SUCCESS"); + System.out.println(convertObjectToJSONString(output)); + + } + }catch(WordnikAPIException e){ + System.out.println("ERROR"); + try{ + System.out.println(convertObjectToJSONString(e)); + }catch(Exception ex){ + ex.printStackTrace(); + } + } catch(Exception e){ + System.out.println("ERROR"); + try{ + WordnikAPIException apiException = new WordnikAPIException(WordnikExceptionCodes.SYSTEM_EXCEPTION, + e.getMessage()); + System.out.println(convertObjectToJSONString(apiException)); + }catch(Exception ex){ + ex.printStackTrace(); + } + } + } + + /** + * Gets the list of input query and path parameters and post data vlues and covenrt them to arguments that + * can be used for calling the method. This logic will be different in each driver language depends on how method + * input arguments are created. + */ + private Object[] populateArgumentsForTestCaseExecution(Method methodToExecute, Map queryAndPathParameters, + String postData) throws Exception { + MethodArgumentNames argNames = methodToExecute.getAnnotation(MethodArgumentNames.class); + String[] argNamesArray = null; + if(argNames != null && argNames.value().length() > 0) { + argNamesArray = argNames.value().split(","); + } + Class[] argTypesArray = methodToExecute.getParameterTypes(); + Object output = null; + + if(argNamesArray != null && argNamesArray.length > 0){ + Object[] arguments = new Object[argNamesArray.length]; + + for(int i=0; i < argNamesArray.length; i++){ + Object argument = null; + String canonicalName = argTypesArray[i].getCanonicalName(); + Class superclass = (Class)argTypesArray[i].getGenericSuperclass(); + //if the input argument is of type wordnik object then it is posisble that the object could be either + // post data or input wrapper object created by code generator. If it is wrpper object then use the + // individual query and path parameters to create the wrapper object. If it is post data directly + // convert input JSON string to post data object + if(superclass != null && superclass.getSimpleName().equalsIgnoreCase("WordnikObject")){ + if(argNamesArray[i].trim().equals("postData")){ + argument = convertJSONStringToObject(postData, argTypesArray[i]); + }else{ + argument = populateWordnikInputModelObject(argTypesArray[i], queryAndPathParameters); + } + }else{ + //the aruments can be primitive types for query and path data and for post data it could be either + //a object or collection of objects. Hence we need to identify the input is single or colection + //based on that un-marshal the string + if(argNamesArray[i].trim().equals("postData")){ + argument = convertJSONStringToObject(postData, argTypesArray[i]); + }else{ + argument = queryAndPathParameters.get(argNamesArray[i].trim()); + } + } + arguments[i] = argument; + } + return arguments; + } + return null; + } + + /** + * Populates the wordnik inout object. + * The definitions for the input will refer the attribute name directly as the input object is more of java driver concept + * hence the test script can not create the input with reference to input object. Test scirpt will only use attribute name. + * Example: If we are looking for a attribute called limit inside an WordExampleInput the input definitions in test script + * will have an entry as "input":10 (please note that there is no reference to input object) + * @param inputDefinitions + * @return + */ + private Object populateWordnikInputModelObject(Class wordnikClass, Map inputDefinitions) throws Exception { + Object object = wordnikClass.getConstructor().newInstance(); + Method[] methods = wordnikClass.getMethods(); + for(Method method : methods){ + if(method.getName().startsWith("get")){ + String methodName = method.getName(); + String fieldName = methodName.substring(3); + fieldName = convertFirstCharToSmall(fieldName); + Object value = inputDefinitions.get(fieldName); + BeanUtils.setProperty(object, fieldName, value); + } + } + return object; + } + + /** + * Converts the first character of the input into string. + * Example: If the input is word, the return value will be Word + * @param input + * @return + */ + public static String convertFirstCharToCaps(String input) { + if(input != null && input.length() > 0) { + return input.substring(0,1).toUpperCase() + input.substring(1); + } else { + throw new RuntimeException("Error converting input to first letter caps becuase of null input"); + } + } + + /** + * Converts the first character of the input into string. + * Example: If the input is word, the return value will be Word + * @param input + * @return + */ + public static String convertFirstCharToSmall(String input) { + if(input != null && input.length() > 0) { + return input.substring(0,1).toLowerCase() + input.substring(1); + }else{ + throw new RuntimeException("Error converting input to first letter to lower because of null input"); + } + } + + public static String getAPIClassName(String resourcePath) { + String className = null; + int index = resourcePath.indexOf("."); + if(index >= 0) { + String resourceName = resourcePath.substring(1,index); + className = convertFirstCharToCaps(resourceName)+"API"; + }else{ + String[] paths = resourcePath.split("/"); + for(String path : paths) { + if(path != null && path.length() > 0) { + className = convertFirstCharToCaps(path)+"API"; + break; + } + } + } + return className; + } + + /** + * Converts JSON string to object. + */ + public Object convertJSONStringToObject(String inputJSON, Class objectType) throws Exception { + boolean isArray = false; + boolean isList = false; + Class className = objectType; + String ObjectTypeName = objectType.getName(); + + //identify if the input is a array + if(ObjectTypeName.startsWith("[")){ + isArray = true; + className = objectType.getComponentType(); + } + + //identify if the input is a list + if(List.class.isAssignableFrom(objectType)){ + isList = true; + } + + if(isArray || isList){ + Object responseObject = mapper.readValue(inputJSON, TypeFactory.type(objectType)); + return responseObject; + }else{ + return WordnikAPI.deserialize(inputJSON, className); + } + } + + /** + * Converts JSON string to object. + */ + public static String convertObjectToJSONString(Object input) throws Exception { + return WordnikAPI.serialize(input); + } + +} diff --git a/android/driver/build.xml b/android/driver/build.xml new file mode 100644 index 00000000000..d0ab17b1e6a --- /dev/null +++ b/android/driver/build.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/driver/ivy.xml b/android/driver/ivy.xml new file mode 100644 index 00000000000..7bc23721ea6 --- /dev/null +++ b/android/driver/ivy.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/android/driver/src/main/java/com/wordnik/api/AccountAPI.java b/android/driver/src/main/java/com/wordnik/api/AccountAPI.java new file mode 100644 index 00000000000..bc6136081ea --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/AccountAPI.java @@ -0,0 +1,290 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class AccountAPI extends WordnikAPI { + + /** + * Authenticates a User + + * @param username A confirmed Wordnik username + + * @param password The user's password + + + * + * @return AuthenticationToken {@link AuthenticationToken} + * @throws WordnikAPIException 403 - Account not available. 404 - User not found. + */ + @MethodArgumentNames(value="username, password") + public static AuthenticationToken authenticate(String username, String password) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/account.{format}/authenticate/{username}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( password != null) { + queryParams.put("password", password); + } + + if( username != null) { + resourcePath = resourcePath.replace("{username}", username); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + AuthenticationToken responseObject = (AuthenticationToken)deserialize(response, AuthenticationToken.class); + return responseObject; + + } + + + /** + * Returns usage statistics for the API account. + + * + * @return ApiTokenStatus {@link ApiTokenStatus} + * @throws WordnikAPIException 400 - No token supplied. 404 - No API account with supplied token. + */ + public static ApiTokenStatus getApiTokenStatus() throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/account.{format}/apiTokenStatus"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + ApiTokenStatus responseObject = (ApiTokenStatus)deserialize(response, ApiTokenStatus.class); + return responseObject; + + } + + + /** + * Returns an ApiResponse indicating whether or not a username is available + + * @param username Username + + + * + * @return ApiResponse {@link ApiResponse} + * @throws WordnikAPIException 400 - Invalid username supplied. 404 - No activation code available. + */ + @MethodArgumentNames(value="username") + public static ApiResponse getUsernameAvailable(String username) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/account.{format}/usernameAvailable/{username}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( username != null) { + resourcePath = resourcePath.replace("{username}", username); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + ApiResponse responseObject = (ApiResponse)deserialize(response, ApiResponse.class); + return responseObject; + + } + + + /** + * Regenerates an API Token. Currently not supported or tested. + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid token supplied. + */ + public static void createApiAccount() throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/account.{format}/regenerateApiToken"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + + } + + + /** + * Authenticates a user + + * @param username A confirmed Wordnik username + + * @param postObject The user's password + + + * + * @return AuthenticationToken {@link AuthenticationToken} + * @throws WordnikAPIException 403 - Account not available. 404 - User not found. + */ + @MethodArgumentNames(value="username, postObject") + public static AuthenticationToken authenticatePost(String username, String postObject) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/account.{format}/authenticate/{username}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + if( username != null) { + resourcePath = resourcePath.replace("{username}", username); + } + + + //make the API Call + + + String response = invokeAPI(null, resourcePath, method, queryParams, postObject); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + AuthenticationToken responseObject = (AuthenticationToken)deserialize(response, AuthenticationToken.class); + return responseObject; + + } + + + /** + * Returns the logged-in User + Requires a valid auth_token to be set. + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return User {@link User} + * @throws WordnikAPIException 403 - Not logged in. 404 - User not found. + */ + @MethodArgumentNames(value="authToken") + public static User getLoggedInUser(String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/account.{format}/user"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + + //make the API Call + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + User responseObject = (User)deserialize(response, User.class); + return responseObject; + + } + + + /** + * Fetches WordList objects for the logged-in user. + + * @param authToken auth_token of logged-in user + + * @param skip Results to skip + + * @param limit Maximum number of results to return + + + * + * @return List {@link WordList} + * @throws WordnikAPIException 403 - Not authenticated. 404 - User account not found. + */ + @MethodArgumentNames(value="authToken, skip, limit") + public static List getWordListsForCurrentUser(String authToken, String skip, String limit) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/account.{format}/wordLists"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( skip != null) { + queryParams.put("skip", skip); + } + if( limit != null) { + queryParams.put("limit", limit); + } + + + + //make the API Call + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/api/VersionChecker.java b/android/driver/src/main/java/com/wordnik/api/VersionChecker.java new file mode 100644 index 00000000000..943f97a6cdd --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/VersionChecker.java @@ -0,0 +1,18 @@ +package com.wordnik.api; + +/** + * Maintains the compatible server version against which the drive is written + * @author ramesh + * + */ +public class VersionChecker { + + private String compatibleVersion = "4.05.30"; + + /** + * Gets the version against which the driver code was written + */ + public String getCompatibleVersion() { + return compatibleVersion; + } +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/api/WordAPI.java b/android/driver/src/main/java/com/wordnik/api/WordAPI.java new file mode 100644 index 00000000000..2a0ba14d7a8 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/WordAPI.java @@ -0,0 +1,635 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class WordAPI extends AbstractWordAPI { + + /** + * Given a word as a string, returns the WordObject that represents it + + * @param word String value of WordObject to return + + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + + * @param includeSuggestions Return suggestions (for correct spelling, case variants, etc.) + + + * + * @return WordObject {@link WordObject} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="word, useCanonical, includeSuggestions") + public static WordObject getWord(String word, String useCanonical, String includeSuggestions) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( useCanonical != null) { + queryParams.put("useCanonical", useCanonical); + } + if( includeSuggestions != null) { + queryParams.put("includeSuggestions", includeSuggestions); + } + + if( word != null) { + resourcePath = resourcePath.replace("{word}", word); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordObject responseObject = (WordObject)deserialize(response, WordObject.class); + return responseObject; + + } + + + /** + * Returns examples for a word + + * @param wordExamplesInput + + + * + * @return ExampleSearchResults {@link ExampleSearchResults} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="wordExamplesInput") + public static ExampleSearchResults getExamples(WordExamplesInput wordExamplesInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/examples"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordExamplesInput != null && wordExamplesInput.getLimit() != null) { + queryParams.put("limit", wordExamplesInput.getLimit()); + } + if( wordExamplesInput != null && wordExamplesInput.getIncludeDuplicates() != null) { + queryParams.put("includeDuplicates", wordExamplesInput.getIncludeDuplicates()); + } + if( wordExamplesInput != null && wordExamplesInput.getContentProvider() != null) { + queryParams.put("contentProvider", wordExamplesInput.getContentProvider()); + } + if( wordExamplesInput != null && wordExamplesInput.getUseCanonical() != null) { + queryParams.put("useCanonical", wordExamplesInput.getUseCanonical()); + } + if( wordExamplesInput != null && wordExamplesInput.getSkip() != null) { + queryParams.put("skip", wordExamplesInput.getSkip()); + } + + if( wordExamplesInput != null && wordExamplesInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordExamplesInput.getWord()); + } + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + ExampleSearchResults responseObject = (ExampleSearchResults)deserialize(response, ExampleSearchResults.class); + return responseObject; + + } + + + /** + * Return definitions for a word + + * @param wordDefinitionsInput + + + * + * @return List {@link Definition} + * @throws WordnikAPIException 400 - Invalid word supplied. 404 - No definitions found. + */ + @MethodArgumentNames(value="wordDefinitionsInput") + public static List getDefinitions(WordDefinitionsInput wordDefinitionsInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/definitions"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordDefinitionsInput != null && wordDefinitionsInput.getLimit() != null) { + queryParams.put("limit", wordDefinitionsInput.getLimit()); + } + if( wordDefinitionsInput != null && wordDefinitionsInput.getPartOfSpeech() != null) { + queryParams.put("partOfSpeech", wordDefinitionsInput.getPartOfSpeech()); + } + if( wordDefinitionsInput != null && wordDefinitionsInput.getIncludeRelated() != null) { + queryParams.put("includeRelated", wordDefinitionsInput.getIncludeRelated()); + } + if( wordDefinitionsInput != null && wordDefinitionsInput.getSourceDictionaries() != null) { + queryParams.put("sourceDictionaries", wordDefinitionsInput.getSourceDictionaries()); + } + if( wordDefinitionsInput != null && wordDefinitionsInput.getUseCanonical() != null) { + queryParams.put("useCanonical", wordDefinitionsInput.getUseCanonical()); + } + if( wordDefinitionsInput != null && wordDefinitionsInput.getIncludeTags() != null) { + queryParams.put("includeTags", wordDefinitionsInput.getIncludeTags()); + } + + if( wordDefinitionsInput != null && wordDefinitionsInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordDefinitionsInput.getWord()); + } + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Returns a top example for a word + + * @param word Word to fetch examples for + + * @param contentProvider Return results from a specific ContentProvider + + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + + + * + * @return Example {@link Example} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="word, contentProvider, useCanonical") + public static Example getTopExample(String word, String contentProvider, String useCanonical) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/topExample"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( contentProvider != null) { + queryParams.put("contentProvider", contentProvider); + } + if( useCanonical != null) { + queryParams.put("useCanonical", useCanonical); + } + + if( word != null) { + resourcePath = resourcePath.replace("{word}", word); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + Example responseObject = (Example)deserialize(response, Example.class); + return responseObject; + + } + + + /** + * Return related words (thesaurus data) for a word + + * @param wordRelatedInput + + + * + * @return List {@link Related} + * @throws WordnikAPIException 400 - Invalid word supplied. 404 - No definitions found. + */ + @MethodArgumentNames(value="wordRelatedInput") + public static List getRelatedWords(WordRelatedInput wordRelatedInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/related"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordRelatedInput != null && wordRelatedInput.getPartOfSpeech() != null) { + queryParams.put("partOfSpeech", wordRelatedInput.getPartOfSpeech()); + } + if( wordRelatedInput != null && wordRelatedInput.getSourceDictionary() != null) { + queryParams.put("sourceDictionary", wordRelatedInput.getSourceDictionary()); + } + if( wordRelatedInput != null && wordRelatedInput.getLimit() != null) { + queryParams.put("limit", wordRelatedInput.getLimit()); + } + if( wordRelatedInput != null && wordRelatedInput.getUseCanonical() != null) { + queryParams.put("useCanonical", wordRelatedInput.getUseCanonical()); + } + if( wordRelatedInput != null && wordRelatedInput.getType() != null) { + queryParams.put("type", wordRelatedInput.getType()); + } + + if( wordRelatedInput != null && wordRelatedInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordRelatedInput.getWord()); + } + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Fetches bi-gram phrases for a word + + * @param word Word to fetch phrases for + + * @param limit Maximum number of results to return + + * @param wlmi Minimum WLMI for the phrase + + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + + + * + * @return List {@link Bigram} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="word, limit, wlmi, useCanonical") + public static List getPhrases(String word, String limit, String wlmi, String useCanonical) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/phrases"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( limit != null) { + queryParams.put("limit", limit); + } + if( wlmi != null) { + queryParams.put("wlmi", wlmi); + } + if( useCanonical != null) { + queryParams.put("useCanonical", useCanonical); + } + + if( word != null) { + resourcePath = resourcePath.replace("{word}", word); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Returns syllable information for a word + + * @param word Word to get syllables for + + * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + + * @param sourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. + + * @param limit Maximum number of results to return + + + * + * @return List {@link Syllable} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="word, useCanonical, sourceDictionary, limit") + public static List getHyphenation(String word, String useCanonical, String sourceDictionary, String limit) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/hyphenation"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( useCanonical != null) { + queryParams.put("useCanonical", useCanonical); + } + if( sourceDictionary != null) { + queryParams.put("sourceDictionary", sourceDictionary); + } + if( limit != null) { + queryParams.put("limit", limit); + } + + if( word != null) { + resourcePath = resourcePath.replace("{word}", word); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Returns text pronunciations for a given word + + * @param wordPronunciationsInput + + + * + * @return List {@link TextPron} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="wordPronunciationsInput") + public static List getTextPronunciations(WordPronunciationsInput wordPronunciationsInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/pronunciations"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordPronunciationsInput != null && wordPronunciationsInput.getUseCanonical() != null) { + queryParams.put("useCanonical", wordPronunciationsInput.getUseCanonical()); + } + if( wordPronunciationsInput != null && wordPronunciationsInput.getSourceDictionary() != null) { + queryParams.put("sourceDictionary", wordPronunciationsInput.getSourceDictionary()); + } + if( wordPronunciationsInput != null && wordPronunciationsInput.getTypeFormat() != null) { + queryParams.put("typeFormat", wordPronunciationsInput.getTypeFormat()); + } + if( wordPronunciationsInput != null && wordPronunciationsInput.getLimit() != null) { + queryParams.put("limit", wordPronunciationsInput.getLimit()); + } + + if( wordPronunciationsInput != null && wordPronunciationsInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordPronunciationsInput.getWord()); + } + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Returns other forms of a word + + * @param word Word to fetch forms for + + * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + + + * + * @return RelationshipMap {@link RelationshipMap} + * @throws WordnikAPIException 400 - Invalid word supplied. 404 - No results. + */ + @MethodArgumentNames(value="word, useCanonical") + public static RelationshipMap getWordForms(String word, String useCanonical) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/wordForms"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( useCanonical != null) { + queryParams.put("useCanonical", useCanonical); + } + + if( word != null) { + resourcePath = resourcePath.replace("{word}", word); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + RelationshipMap responseObject = (RelationshipMap)deserialize(response, RelationshipMap.class); + return responseObject; + + } + + + /** + * Returns definitions for a word based on the sentence in which it is found + Use the offset parameter when the word occurs more than once in the sentence + * @param wordContextualLookupInput + + + * + * @return DefinitionSearchResults {@link DefinitionSearchResults} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="wordContextualLookupInput") + public static DefinitionSearchResults contextualLookup(WordContextualLookupInput wordContextualLookupInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/contextualLookup"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordContextualLookupInput != null && wordContextualLookupInput.getSentence() != null) { + queryParams.put("sentence", wordContextualLookupInput.getSentence()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getOffset() != null) { + queryParams.put("offset", wordContextualLookupInput.getOffset()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getExpandTerms() != null) { + queryParams.put("expandTerms", wordContextualLookupInput.getExpandTerms()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getIncludeSourceDictionaries() != null) { + queryParams.put("includeSourceDictionaries", wordContextualLookupInput.getIncludeSourceDictionaries()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getExcludeSourceDictionaries() != null) { + queryParams.put("excludeSourceDictionaries", wordContextualLookupInput.getExcludeSourceDictionaries()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getSkip() != null) { + queryParams.put("skip", wordContextualLookupInput.getSkip()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getLimit() != null) { + queryParams.put("limit", wordContextualLookupInput.getLimit()); + } + + if( wordContextualLookupInput != null && wordContextualLookupInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordContextualLookupInput.getWord()); + } + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + DefinitionSearchResults responseObject = (DefinitionSearchResults)deserialize(response, DefinitionSearchResults.class); + return responseObject; + + } + + + /** + * Returns definitions for a word based on the sentence in which it is found + Use the offset parameter when the word occurs more than once in the sentence + * @param postObject The sentence in which the word occurs + + * @param wordContextualLookupInput + + + * + * @return DefinitionSearchResults {@link DefinitionSearchResults} + * @throws WordnikAPIException 400 - Invalid term supplied. + */ + @MethodArgumentNames(value="postObject, wordContextualLookupInput") + public static DefinitionSearchResults contextualLookupPost(String postObject, WordContextualLookupInput wordContextualLookupInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/word.{format}/{word}/contextualLookup"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + + if( wordContextualLookupInput != null && wordContextualLookupInput.getOffset() != null) { + queryParams.put("offset", wordContextualLookupInput.getOffset()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getExpandTerms() != null) { + queryParams.put("expandTerms", wordContextualLookupInput.getExpandTerms()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getIncludeSourceDictionaries() != null) { + queryParams.put("includeSourceDictionaries", wordContextualLookupInput.getIncludeSourceDictionaries()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getExcludeSourceDictionaries() != null) { + queryParams.put("excludeSourceDictionaries", wordContextualLookupInput.getExcludeSourceDictionaries()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getSkip() != null) { + queryParams.put("skip", wordContextualLookupInput.getSkip()); + } + if( wordContextualLookupInput != null && wordContextualLookupInput.getLimit() != null) { + queryParams.put("limit", wordContextualLookupInput.getLimit()); + } + + if( wordContextualLookupInput != null && wordContextualLookupInput.getWord() != null) { + resourcePath = resourcePath.replace("{word}", wordContextualLookupInput.getWord()); + } + + //make the API Call + + + String response = invokeAPI(null, resourcePath, method, queryParams, postObject); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + DefinitionSearchResults responseObject = (DefinitionSearchResults)deserialize(response, DefinitionSearchResults.class); + return responseObject; + + } + + + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/api/WordListAPI.java b/android/driver/src/main/java/com/wordnik/api/WordListAPI.java new file mode 100644 index 00000000000..a1089045ad0 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/WordListAPI.java @@ -0,0 +1,282 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class WordListAPI extends WordnikAPI { + + /** + * Fetches a WordList by ID + + * @param wordListId ID of WordList to fetch + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return WordList {@link WordList} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to access WordList 404 - WordList not found + */ + @MethodArgumentNames(value="wordListId, authToken") + public static WordList getWordListById(String wordListId, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( wordListId != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListId); + } + + + //make the API Call + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordList responseObject = (WordList)deserialize(response, WordList.class); + return responseObject; + + } + + + /** + * Fetches words in a WordList + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + * @param wordListWordsInput + + + * + * @return List {@link WordListWord} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to access WordList 404 - WordList not found + */ + @MethodArgumentNames(value="authToken, wordListWordsInput") + public static List getWordListWords(String authToken, WordListWordsInput wordListWordsInput) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}/words"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordListWordsInput != null && wordListWordsInput.getSortBy() != null) { + queryParams.put("sortBy", wordListWordsInput.getSortBy()); + } + if( wordListWordsInput != null && wordListWordsInput.getSortOrder() != null) { + queryParams.put("sortOrder", wordListWordsInput.getSortOrder()); + } + if( wordListWordsInput != null && wordListWordsInput.getSkip() != null) { + queryParams.put("skip", wordListWordsInput.getSkip()); + } + if( wordListWordsInput != null && wordListWordsInput.getLimit() != null) { + queryParams.put("limit", wordListWordsInput.getLimit()); + } + + if( wordListWordsInput != null && wordListWordsInput.getWordListId() != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListWordsInput.getWordListId()); + } + + //make the API Call + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Adds words to a WordList + + * @param wordListId ID of WordList to user + + * @param postObject Words to add to WordList + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to access WordList 404 - WordList not found + */ + @MethodArgumentNames(value="wordListId, postObject, authToken") + public static void addWordsToWordList(String wordListId, StringValue[] postObject, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}/words"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + if( wordListId != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListId); + } + + + //make the API Call + + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); + + //create output objects if the response has more than one object + + } + + + /** + * Updates an existing WordList + + * @param wordListId ID of WordList to update + + * @param postObject Updated WordList + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to update WordList 404 - WordList not found + */ + @MethodArgumentNames(value="wordListId, postObject, authToken") + public static void updateWordList(String wordListId, WordList postObject, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "PUT"; + Map queryParams = new HashMap(); + + if( wordListId != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListId); + } + + + //make the API Call + + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); + + //create output objects if the response has more than one object + + } + + + /** + * Deletes an existing WordList + + * @param wordListId ID of WordList to delete + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to delete WordList 404 - WordList not found + */ + @MethodArgumentNames(value="wordListId, authToken") + public static void deleteWordList(String wordListId, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "DELETE"; + Map queryParams = new HashMap(); + + if( wordListId != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListId); + } + + + //make the API Call + String response = invokeAPI(authToken, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + + } + + + /** + * Removes words from a WordList + + * @param wordListId ID of WordList to use + + * @param postObject Words to remove from WordList + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not Authorized to modify WordList 404 - WordList not found + */ + @MethodArgumentNames(value="wordListId, postObject, authToken") + public static void deleteWordsFromWordList(String wordListId, StringValue[] postObject, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordList.{format}/{wordListId}/deleteWords"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + if( wordListId != null) { + resourcePath = resourcePath.replace("{wordListId}", wordListId); + } + + + //make the API Call + + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); + + //create output objects if the response has more than one object + + } + + + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/api/WordListsAPI.java b/android/driver/src/main/java/com/wordnik/api/WordListsAPI.java new file mode 100644 index 00000000000..c348d598670 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/WordListsAPI.java @@ -0,0 +1,94 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class WordListsAPI extends WordnikAPI { + + /** + * Returns information about API parameters + + * + * @return Doc {@link Doc} + * @throws WordnikAPIException 404 - No data available + */ + public static Doc getHelp() throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/wordLists.{format}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + Doc responseObject = (Doc)deserialize(response, Doc.class); + return responseObject; + + } + + + /** + * Creates a WordList. + + * @param postObject WordList to create + + * @param authToken The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) + + + * + * @return WordList {@link WordList} + * @throws WordnikAPIException 400 - Invalid WordList supplied or mandatory fields are missing. 403 - Not authenticated. 404 - WordList owner not found. + */ + @MethodArgumentNames(value="postObject, authToken") + public static WordList createWordList(WordList postObject, String authToken) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/wordLists.{format}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + + + //make the API Call + + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); + + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordList responseObject = (WordList)deserialize(response, WordList.class); + return responseObject; + + } + + + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/api/WordsAPI.java b/android/driver/src/main/java/com/wordnik/api/WordsAPI.java new file mode 100644 index 00000000000..47ee4a47eef --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/api/WordsAPI.java @@ -0,0 +1,848 @@ +package com.wordnik.api; + + +import com.wordnik.common.*; +import com.wordnik.common.ext.*; +import com.wordnik.exception.WordnikExceptionCodes; +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.model.*; +import java.util.*; +import com.wordnik.annotations.MethodArgumentNames; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import java.io.IOException; + +/** + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class WordsAPI extends WordnikAPI { + + /** + * Returns a single random WordObject, in the format specified by the URL + + * @param wordsRandomWordInput + + + * + * @return WordObject {@link WordObject} + * @throws WordnikAPIException 404 - No word found. + */ + @MethodArgumentNames(value="wordsRandomWordInput") + public static WordObject getRandomWord(WordsRandomWordInput wordsRandomWordInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/randomWord"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordsRandomWordInput != null && wordsRandomWordInput.getHasDictionaryDef() != null) { + queryParams.put("hasDictionaryDef", wordsRandomWordInput.getHasDictionaryDef()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getIncludePartOfSpeech() != null) { + queryParams.put("includePartOfSpeech", wordsRandomWordInput.getIncludePartOfSpeech()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getExcludePartOfSpeech() != null) { + queryParams.put("excludePartOfSpeech", wordsRandomWordInput.getExcludePartOfSpeech()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMinCorpusCount() != null) { + queryParams.put("minCorpusCount", wordsRandomWordInput.getMinCorpusCount()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMaxCorpusCount() != null) { + queryParams.put("maxCorpusCount", wordsRandomWordInput.getMaxCorpusCount()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMinDictionaryCount() != null) { + queryParams.put("minDictionaryCount", wordsRandomWordInput.getMinDictionaryCount()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMaxDictionaryCount() != null) { + queryParams.put("maxDictionaryCount", wordsRandomWordInput.getMaxDictionaryCount()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMinLength() != null) { + queryParams.put("minLength", wordsRandomWordInput.getMinLength()); + } + if( wordsRandomWordInput != null && wordsRandomWordInput.getMaxLength() != null) { + queryParams.put("maxLength", wordsRandomWordInput.getMaxLength()); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordObject responseObject = (WordObject)deserialize(response, WordObject.class); + return responseObject; + + } + + + /** + * Returns an array of random WordObjects, in the format specified by the URL + + * @param wordsRandomWordsInput + + + * + * @return List {@link WordObject} + * @throws WordnikAPIException 400 - Invalid term supplied. 404 - No results. + */ + @MethodArgumentNames(value="wordsRandomWordsInput") + public static List getRandomWords(WordsRandomWordsInput wordsRandomWordsInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/randomWords"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getHasDictionaryDef() != null) { + queryParams.put("hasDictionaryDef", wordsRandomWordsInput.getHasDictionaryDef()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getIncludePartOfSpeech() != null) { + queryParams.put("includePartOfSpeech", wordsRandomWordsInput.getIncludePartOfSpeech()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getExcludePartOfSpeech() != null) { + queryParams.put("excludePartOfSpeech", wordsRandomWordsInput.getExcludePartOfSpeech()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMinCorpusCount() != null) { + queryParams.put("minCorpusCount", wordsRandomWordsInput.getMinCorpusCount()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMaxCorpusCount() != null) { + queryParams.put("maxCorpusCount", wordsRandomWordsInput.getMaxCorpusCount()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMinDictionaryCount() != null) { + queryParams.put("minDictionaryCount", wordsRandomWordsInput.getMinDictionaryCount()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMaxDictionaryCount() != null) { + queryParams.put("maxDictionaryCount", wordsRandomWordsInput.getMaxDictionaryCount()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMinLength() != null) { + queryParams.put("minLength", wordsRandomWordsInput.getMinLength()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getMaxLength() != null) { + queryParams.put("maxLength", wordsRandomWordsInput.getMaxLength()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getSortBy() != null) { + queryParams.put("sortBy", wordsRandomWordsInput.getSortBy()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getSortOrder() != null) { + queryParams.put("sortOrder", wordsRandomWordsInput.getSortOrder()); + } + if( wordsRandomWordsInput != null && wordsRandomWordsInput.getLimit() != null) { + queryParams.put("limit", wordsRandomWordsInput.getLimit()); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Searches words. + + * @param wordsSearchInput + + + * + * @return List {@link WordFrequency} + * @throws WordnikAPIException 400 - Invalid term supplied. 404 - No results. + */ + @MethodArgumentNames(value="wordsSearchInput") + public static List searchWords(WordsSearchInput wordsSearchInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/search"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordsSearchInput != null && wordsSearchInput.getQuery() != null) { + queryParams.put("query", wordsSearchInput.getQuery()); + } + if( wordsSearchInput != null && wordsSearchInput.getCaseSensitive() != null) { + queryParams.put("caseSensitive", wordsSearchInput.getCaseSensitive()); + } + if( wordsSearchInput != null && wordsSearchInput.getIncludePartOfSpeech() != null) { + queryParams.put("includePartOfSpeech", wordsSearchInput.getIncludePartOfSpeech()); + } + if( wordsSearchInput != null && wordsSearchInput.getExcludePartOfSpeech() != null) { + queryParams.put("excludePartOfSpeech", wordsSearchInput.getExcludePartOfSpeech()); + } + if( wordsSearchInput != null && wordsSearchInput.getMinCorpusCount() != null) { + queryParams.put("minCorpusCount", wordsSearchInput.getMinCorpusCount()); + } + if( wordsSearchInput != null && wordsSearchInput.getMaxCorpusCount() != null) { + queryParams.put("maxCorpusCount", wordsSearchInput.getMaxCorpusCount()); + } + if( wordsSearchInput != null && wordsSearchInput.getMinDictionaryCount() != null) { + queryParams.put("minDictionaryCount", wordsSearchInput.getMinDictionaryCount()); + } + if( wordsSearchInput != null && wordsSearchInput.getMaxDictionaryCount() != null) { + queryParams.put("maxDictionaryCount", wordsSearchInput.getMaxDictionaryCount()); + } + if( wordsSearchInput != null && wordsSearchInput.getMinLength() != null) { + queryParams.put("minLength", wordsSearchInput.getMinLength()); + } + if( wordsSearchInput != null && wordsSearchInput.getMaxLength() != null) { + queryParams.put("maxLength", wordsSearchInput.getMaxLength()); + } + if( wordsSearchInput != null && wordsSearchInput.getSkip() != null) { + queryParams.put("skip", wordsSearchInput.getSkip()); + } + if( wordsSearchInput != null && wordsSearchInput.getLimit() != null) { + queryParams.put("limit", wordsSearchInput.getLimit()); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Fetches an array of WordOfTheDayList basd on a criteria + + * @param containsWord Lists must contain a specific word + + * @param subscriberCount Lists must have the specified number of subscribers + + * @param itemCount Lists must have the specified number of items + + * @param includeAll Returns future WordOfTheDay items + + + * + * @return List {@link WordOfTheDayList} + * @throws WordnikAPIException 400 - Invalid word supplied. + */ + @MethodArgumentNames(value="containsWord, subscriberCount, itemCount, includeAll") + public static List getWordOfTheDayListsContainingWord(String containsWord, String subscriberCount, String itemCount, String includeAll) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayLists"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( containsWord != null) { + queryParams.put("containsWord", containsWord); + } + if( subscriberCount != null) { + queryParams.put("subscriberCount", subscriberCount); + } + if( itemCount != null) { + queryParams.put("itemCount", itemCount); + } + if( includeAll != null) { + queryParams.put("includeAll", includeAll); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Fetches WordOfTheDay objects for a specific date + + * @param date ID of WordOfTheDayList + + * @param includeAll Returns future WordOfTheDay items + + + * + * @return List {@link WordOfTheDay} + * @throws WordnikAPIException 400 - Invalid ID supplied 404 - WordOfTheDayList or User not found + */ + @MethodArgumentNames(value="date, includeAll") + public static List getWordOfTheDayListsForDate(String date, String includeAll) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayLists/{date}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( includeAll != null) { + queryParams.put("includeAll", includeAll); + } + + if( date != null) { + resourcePath = resourcePath.replace("{date}", date); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Subscribes a user to a WordOfTheDayList + + * @param authToken auth_token of logged-in user + + * @param permalink ID of WordOfTheDayList + + * @param medium Medium to subscribe with + + * @param postObject Username to subscribe + + + * + * @return void {@link Void} + * @throws WordnikAPIException 400 - Invalid ID supplied 403 - Not authorized to subscribe 404 - WordOfTheDayList or User not found + */ + @MethodArgumentNames(value="authToken, permalink, medium, postObject") + public static void subscribeToList(String authToken, String permalink, String medium, String postObject) throws WordnikAPIException { + + if(authToken == null || authToken.length() == 0) { + throw new WordnikAPIException(WordnikExceptionCodes.AUTH_TOKEN_NOT_VALID); + } + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayList/{permalink}/subscription"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "POST"; + Map queryParams = new HashMap(); + + if( medium != null) { + queryParams.put("medium", medium); + } + + if( permalink != null) { + resourcePath = resourcePath.replace("{permalink}", permalink); + } + + + //make the API Call + + String response = invokeAPI(authToken, resourcePath, method, queryParams, postObject); + + //create output objects if the response has more than one object + + } + + + /** + * Searches definitions. + + * @param wordsSearchDefinitionsInput + + + * + * @return DefinitionSearchResults {@link DefinitionSearchResults} + * @throws WordnikAPIException 400 - Invalid term supplied. + */ + @MethodArgumentNames(value="wordsSearchDefinitionsInput") + public static DefinitionSearchResults searchDefinitions(WordsSearchDefinitionsInput wordsSearchDefinitionsInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/searchDefinitions"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getQuery() != null) { + queryParams.put("query", wordsSearchDefinitionsInput.getQuery()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getDefinedWordSearchTerm() != null) { + queryParams.put("definedWordSearchTerm", wordsSearchDefinitionsInput.getDefinedWordSearchTerm()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getIncludeSourceDictionaries() != null) { + queryParams.put("includeSourceDictionaries", wordsSearchDefinitionsInput.getIncludeSourceDictionaries()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getExcludeSourceDictionaries() != null) { + queryParams.put("excludeSourceDictionaries", wordsSearchDefinitionsInput.getExcludeSourceDictionaries()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getIncludePartOfSpeech() != null) { + queryParams.put("includePartOfSpeech", wordsSearchDefinitionsInput.getIncludePartOfSpeech()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getExcludePartOfSpeech() != null) { + queryParams.put("excludePartOfSpeech", wordsSearchDefinitionsInput.getExcludePartOfSpeech()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getMinCorpusCount() != null) { + queryParams.put("minCorpusCount", wordsSearchDefinitionsInput.getMinCorpusCount()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getMaxCorpusCount() != null) { + queryParams.put("maxCorpusCount", wordsSearchDefinitionsInput.getMaxCorpusCount()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getMinLength() != null) { + queryParams.put("minLength", wordsSearchDefinitionsInput.getMinLength()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getMaxLength() != null) { + queryParams.put("maxLength", wordsSearchDefinitionsInput.getMaxLength()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getExpandTerms() != null) { + queryParams.put("expandTerms", wordsSearchDefinitionsInput.getExpandTerms()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getWordTypes() != null) { + queryParams.put("wordTypes", wordsSearchDefinitionsInput.getWordTypes()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getIncludeTags() != null) { + queryParams.put("includeTags", wordsSearchDefinitionsInput.getIncludeTags()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getSortBy() != null) { + queryParams.put("sortBy", wordsSearchDefinitionsInput.getSortBy()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getSortOrder() != null) { + queryParams.put("sortOrder", wordsSearchDefinitionsInput.getSortOrder()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getSkip() != null) { + queryParams.put("skip", wordsSearchDefinitionsInput.getSkip()); + } + if( wordsSearchDefinitionsInput != null && wordsSearchDefinitionsInput.getLimit() != null) { + queryParams.put("limit", wordsSearchDefinitionsInput.getLimit()); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + DefinitionSearchResults responseObject = (DefinitionSearchResults)deserialize(response, DefinitionSearchResults.class); + return responseObject; + + } + + + /** + * Searches dictionary entries. + + * @param query Search term + + * @param skip Results to skip + * Allowed values are - 0 to 1000 + * @param limit Maximum number of results to return + * Allowed values are - 1 to 1000 + + * + * @return EntrySearchResults {@link EntrySearchResults} + * @throws WordnikAPIException 400 - Invalid term supplied. + */ + @MethodArgumentNames(value="query, skip, limit") + public static EntrySearchResults searchEntries(String query, String skip, String limit) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/searchEntries"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( query != null) { + queryParams.put("query", query); + } + if( skip != null) { + queryParams.put("skip", skip); + } + if( limit != null) { + queryParams.put("limit", limit); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + EntrySearchResults responseObject = (EntrySearchResults)deserialize(response, EntrySearchResults.class); + return responseObject; + + } + + + /** + * Fetches surface forms of a word + + * @param term Word to get surface forms for. + + + * + * @return String {@link String} + * @throws WordnikAPIException 400 - Invalid term supplied. + */ + @MethodArgumentNames(value="term") + public static String getSurfaceForms(String term) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/surfaceForms"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( term != null) { + queryParams.put("term", term); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + String responseObject = (String)deserialize(response, String.class); + return responseObject; + + } + + + /** + * Returns a specific WordOfTheDay + + * @param date Fetches by date in yyyy-MM-dd + + * @param category Filters response by category + + * @param creator Filters response by username + + + * + * @return WordOfTheDay {@link WordOfTheDay} + * @throws WordnikAPIException 404 - No data available + */ + @MethodArgumentNames(value="date, category, creator") + public static WordOfTheDay getWordOfTheDay(String date, String category, String creator) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDay"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( date != null) { + queryParams.put("date", date); + } + if( category != null) { + queryParams.put("category", category); + } + if( creator != null) { + queryParams.put("creator", creator); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordOfTheDay responseObject = (WordOfTheDay)deserialize(response, WordOfTheDay.class); + return responseObject; + + } + + + /** + * Returns a WordOfTheDay range + + * @param wordsWordOfTheDayInputRangeInput + + + * + * @return List {@link WordOfTheDay} + * @throws WordnikAPIException 404 - No data available + */ + @MethodArgumentNames(value="wordsWordOfTheDayInputRangeInput") + public static List getWordOfTheDayRange(WordsWordOfTheDayInputRangeInput wordsWordOfTheDayInputRangeInput) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDay/range"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + + if( wordsWordOfTheDayInputRangeInput != null && wordsWordOfTheDayInputRangeInput.getCategory() != null) { + queryParams.put("category", wordsWordOfTheDayInputRangeInput.getCategory()); + } + if( wordsWordOfTheDayInputRangeInput != null && wordsWordOfTheDayInputRangeInput.getCreator() != null) { + queryParams.put("creator", wordsWordOfTheDayInputRangeInput.getCreator()); + } + if( wordsWordOfTheDayInputRangeInput != null && wordsWordOfTheDayInputRangeInput.getProvider() != null) { + queryParams.put("provider", wordsWordOfTheDayInputRangeInput.getProvider()); + } + if( wordsWordOfTheDayInputRangeInput != null && wordsWordOfTheDayInputRangeInput.getSkip() != null) { + queryParams.put("skip", wordsWordOfTheDayInputRangeInput.getSkip()); + } + if( wordsWordOfTheDayInputRangeInput != null && wordsWordOfTheDayInputRangeInput.getLimit() != null) { + queryParams.put("limit", wordsWordOfTheDayInputRangeInput.getLimit()); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Fetches a WordOfTheDayList by ID + + * @param permalink ID of WordOfTheDayList + + * @param includeAll Returns future WordOfTheDay items + + + * + * @return WordOfTheDayList {@link WordOfTheDayList} + * @throws WordnikAPIException 400 - Invalid id supplied 404 - WordOfTheDayList not found + */ + @MethodArgumentNames(value="permalink, includeAll") + public static WordOfTheDayList getWordOfTheDayList(String permalink, String includeAll) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayList/{permalink}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( includeAll != null) { + queryParams.put("includeAll", includeAll); + } + + if( permalink != null) { + resourcePath = resourcePath.replace("{permalink}", permalink); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordOfTheDayList responseObject = (WordOfTheDayList)deserialize(response, WordOfTheDayList.class); + return responseObject; + + } + + + /** + * Fetches a WordOfTheDayList by ID + + * @param permalink ID of WordOfTheDayList + + * @param specifier Specifier for the item to fetch. Either 'current' or a date. + + + * + * @return WordOfTheDay {@link WordOfTheDay} + * @throws WordnikAPIException 400 - Invalid id supplied 404 - WordOfTheDayList not found + */ + @MethodArgumentNames(value="permalink, specifier") + public static WordOfTheDay getWordOfTheDayListItem(String permalink, String specifier) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayList/{permalink}/{specifier}"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( permalink != null) { + resourcePath = resourcePath.replace("{permalink}", permalink); + } + if( specifier != null) { + resourcePath = resourcePath.replace("{specifier}", specifier); + } + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + WordOfTheDay responseObject = (WordOfTheDay)deserialize(response, WordOfTheDay.class); + return responseObject; + + } + + + /** + * Fetches recently created WordOfTheDayLists + + * @param skip Results to skip + + * @param limit Maximum number of results to return + + + * + * @return List {@link WordOfTheDayList} + * @throws WordnikAPIException 404 - No WordOfTheDayLists found. + */ + @MethodArgumentNames(value="skip, limit") + public static List getRecentWordOfTheDayLists(String skip, String limit) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayLists/recent"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( skip != null) { + queryParams.put("skip", skip); + } + if( limit != null) { + queryParams.put("limit", limit); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + + TypeReference> typeRef = new TypeReference>() { + }; + try { + List responseObject = (List) mapper.readValue(response, typeRef); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, typeRef.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * Returns whether or not a subscription process has been run. + Uses the current server time (day resolution) as the default date to check for, optionally a dateString can be supplied for a specific date to check for. + * @param date Date string to fetch for. + + + * + * @return String {@link String} + * @throws WordnikAPIException 400 - Invalid date format supplied. + */ + @MethodArgumentNames(value="date") + public static String getWordOfTheDayListSubscriptionProcessStatus(String date) throws WordnikAPIException { + + + //parse inputs + String resourcePath = "/words.{format}/wordOfTheDayLists/subscriptionProcess"; + resourcePath = resourcePath.replace("{format}","json"); + String method = "GET"; + Map queryParams = new HashMap(); + + if( date != null) { + queryParams.put("date", date); + } + + + + //make the API Call + String response = invokeAPI(null, resourcePath, method, queryParams, null); + //create output objects if the response has more than one object + if(response == null || response.length() == 0){ + return null; + } + String responseObject = (String)deserialize(response, String.class); + return responseObject; + + } + + + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/common/WordnikAPI.java b/android/driver/src/main/java/com/wordnik/common/WordnikAPI.java new file mode 100644 index 00000000000..6ffdceebd24 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/common/WordnikAPI.java @@ -0,0 +1,238 @@ +package com.wordnik.common; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.util.Map; +import java.util.logging.Logger; + + +import org.apache.http.HttpException; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.*; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.DeserializationConfig.Feature; + +import com.wordnik.exception.WordnikAPIException; +import com.wordnik.exception.WordnikExceptionCodes; + +/** + * Provides way to initialize the communication with Wordnik API server. + * This is also a Base class for all API classes + * @author ramesh + * + */ +public class WordnikAPI { + + private static String apiServer = "http://api.wordnik.com/v4"; + private static String apiKey = ""; + private static boolean loggingEnabled; + private static Logger logger = null; + + public static final String WORDNIK_HEADER_NAME = "api_key"; + + protected static String POST = "POST"; + protected static String GET = "GET"; + protected static String PUT = "PUT"; + protected static String DELETE = "DELETE"; + protected static ObjectMapper mapper = new ObjectMapper(); + static{ + mapper.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + /** + * Initializes the API communication with required inputs. + * @param apiKey provide the key provided as part of registration + * @param apiServer Sets the URL for the API server. It is defaulted to the server + * used while building the driver. This value should be provided while testing the APIs against + * test servers or if there is any changes in production server URLs. + * @param enableLogging This will enable the logging using Jersey logging filter. Refer the following documentation + * for more details. {@link //LoggingFilter}. Default output is sent to system.out. + * Create a logger ({@link Logger} class and set using setLogger method. + */ + public static void initialize(String apiKey, String apiServer, boolean enableLogging) { + setApiKey(apiKey); + if(apiServer != null && apiServer.length() > 0) { + if(apiServer.substring(apiServer.length()-1).equals("/")){ + apiServer = apiServer.substring(0, apiServer.length()-1); + } + setApiServer(apiServer); + } + loggingEnabled = enableLogging; + } + + /** + * Set the logger instance used for Jersey logging. + * @param aLogger + */ + public static void setLogger(Logger aLogger) { + logger = aLogger; + } + + /** + * Gets the API key used for server communication. + * This value is set using initialize method. + * @return + */ + private static String getApiKey() { + return apiKey; + } + + private static void setApiKey(String apiKey) { + WordnikAPI.apiKey = apiKey; + } + + /** + * Sets the URL for the API server. It is defaulted to the server used while building the driver. + * @return + */ + private static String getApiServer() { + return apiServer; + } + + private static void setApiServer(String server) { + WordnikAPI.apiServer = server; + } + + + /** + * Invokes the API and returns the response as json string. + * This is an internal method called by individual APIs for communication. It sets the required HTTP headers + * based on API key and auth token. + * @param authToken - token that is received as part of authentication call. This is only needed for the calls that are secure. + * @param resourceURL - URL for the rest resource + * @param method - Method we should use for communicating to the back end. + * @param postObject - if the method is POST, provide the object that should be sent as part of post request. + * @return JSON response of the API call. + * @throws com.wordnik.exception.WordnikAPIException if the call to API server fails. + */ + protected static String invokeAPI(String authToken, String resourceURL, String method, + Map queryParams, Object postObject) + throws WordnikAPIException { + String responseString = null; + try { + //check for app key and server values + if(getApiKey() == null || getApiKey().length() == 0) { + String[] args = {getApiKey()}; + throw new WordnikAPIException(WordnikExceptionCodes.API_KEY_NOT_VALID, args); + } + if(getApiServer() == null || getApiServer().length() == 0) { + String[] args = {getApiServer()}; + throw new WordnikAPIException(WordnikExceptionCodes.API_SERVER_NOT_VALID, args); + } + + String url = getApiServer() + resourceURL + getQueryParams(queryParams); + + HttpUriRequest request = null; + if(method.equals(GET)) { + request = new HttpGet(url); + } else if (method.equals(POST)) { + request = new HttpPost(url); + if(postObject != null) { + StringEntity entity = new StringEntity(serialize(postObject)); + ((HttpPost) request).setEntity(entity); + } + } else if (method.equals(PUT)) { + request = new HttpPut(url); + if(postObject != null) { + StringEntity entity = new StringEntity(serialize(postObject)); + ((HttpPut) request).setEntity(entity); + } + } else if (method.equals(DELETE)) { + request = new HttpDelete(url); + } else { + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_FROM_WEBSERVICE_CALL, "Http method not valid - " + method); + } + + request.setHeader("Content-type", "application/json"); + request.addHeader(WORDNIK_HEADER_NAME, getApiKey()); + if(authToken != null){ + request.addHeader("auth_token", authToken); + } + + final HttpClient hc = new DefaultHttpClient(); + final HttpResponse resp = hc.execute(request); + final int status = resp.getStatusLine().getStatusCode(); + if (status == HttpStatus.SC_OK) { + if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + responseString = EntityUtils.toString(resp.getEntity(), HTTP.UTF_8); + } else { + throw new WordnikAPIException(resp.getStatusLine().getStatusCode(), EntityUtils.toString(resp.getEntity(), HTTP.UTF_8)); + } + } else { + throw new WordnikAPIException(status, EntityUtils.toString(resp.getEntity(), HTTP.UTF_8)); + } + } catch (Exception e) { + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_FROM_WEBSERVICE_CALL, e.getMessage(), e); + } + + return responseString; + } + + private static String getQueryParams(Map queryParams) { + if(queryParams == null || queryParams.size() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(); + buf.append("?"); + + for(String key : queryParams.keySet()) { + String value = queryParams.get(key); + + try { + value = URLEncoder.encode(value, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + if(buf.length() > 1) { + buf.append("&"); + } + + buf.append(key).append("=").append(value); + } + + return buf.toString(); + } + + /** + * De-serialize the object from String to input object. + * @param response + * @param inputClassName + * @return + */ + public static Object deserialize(String response, Class inputClassName) throws WordnikAPIException { + try { + Object responseObject = mapper.readValue(response, inputClassName); + return responseObject; + } catch (IOException ioe) { + String[] args = new String[]{response, inputClassName.toString()}; + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in coversting response json value to java object : " + ioe.getMessage(), ioe); + } + } + + + /** + * serialize the object from String to input object. + * @param input + * @return + */ + public static String serialize(Object input) throws WordnikAPIException { + try { + if(input != null) { + return mapper.writeValueAsString(input); + }else{ + return ""; + } + } catch (IOException ioe) { + throw new WordnikAPIException(WordnikExceptionCodes.ERROR_CONVERTING_JAVA_TO_JSON, "Error in coverting input java to json : " + ioe.getMessage(), ioe); + } + } +} diff --git a/android/driver/src/main/java/com/wordnik/model/ApiResponse.java b/android/driver/src/main/java/com/wordnik/model/ApiResponse.java new file mode 100644 index 00000000000..a5c9038778b --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/ApiResponse.java @@ -0,0 +1,43 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class ApiResponse extends WordnikObject { + + // + private String message ; + // + private String type ; + + + // + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + // + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/ApiTokenStatus.java b/android/driver/src/main/java/com/wordnik/model/ApiTokenStatus.java new file mode 100644 index 00000000000..434f81b8708 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/ApiTokenStatus.java @@ -0,0 +1,76 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class ApiTokenStatus extends WordnikObject { + + // + private String token ; + // + private Long expiresInMillis ; + // + private Long totalRequests ; + // + private Long remainingCalls ; + // + private Long resetsInMillis ; + + + // + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + // + + public Long getExpiresInMillis() { + return expiresInMillis; + } + + public void setExpiresInMillis(Long expiresInMillis) { + this.expiresInMillis = expiresInMillis; + } + // + + public Long getTotalRequests() { + return totalRequests; + } + + public void setTotalRequests(Long totalRequests) { + this.totalRequests = totalRequests; + } + // + + public Long getRemainingCalls() { + return remainingCalls; + } + + public void setRemainingCalls(Long remainingCalls) { + this.remainingCalls = remainingCalls; + } + // + + public Long getResetsInMillis() { + return resetsInMillis; + } + + public void setResetsInMillis(Long resetsInMillis) { + this.resetsInMillis = resetsInMillis; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/AudioFile.java b/android/driver/src/main/java/com/wordnik/model/AudioFile.java new file mode 100644 index 00000000000..a0a312a65f2 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/AudioFile.java @@ -0,0 +1,134 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; +import java.util.Date; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class AudioFile extends WordnikObject { + + // + private Long id ; + // + private String description ; + // + private String createdBy ; + // + private String word ; + // + private Date createdAt ; + // + private int commentCount ; + // + private int voteCount ; + // + private float voteAverage ; + // + private float voteWeightedAverage ; + // + private String fileUrl ; + + + // + + @Required + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + // + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + // + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + // + + public String getWord() { + return word; + } + + public void setWord(String word) { + this.word = word; + } + // + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + // + + public int getCommentCount() { + return commentCount; + } + + public void setCommentCount(int commentCount) { + this.commentCount = commentCount; + } + // + + public int getVoteCount() { + return voteCount; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + // + + public float getVoteAverage() { + return voteAverage; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + // + + public float getVoteWeightedAverage() { + return voteWeightedAverage; + } + + public void setVoteWeightedAverage(float voteWeightedAverage) { + this.voteWeightedAverage = voteWeightedAverage; + } + // + + public String getFileUrl() { + return fileUrl; + } + + public void setFileUrl(String fileUrl) { + this.fileUrl = fileUrl; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/AudioObject.java b/android/driver/src/main/java/com/wordnik/model/AudioObject.java new file mode 100644 index 00000000000..a2d016a92b7 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/AudioObject.java @@ -0,0 +1,165 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; +import java.util.Date; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class AudioObject extends WordnikObject { + + // + private Long id ; + // + private AudioType type ; + // + private String description ; + // + private Long userId ; + // + private String createdBy ; + // + private String wordstring ; + // + private Long wordId ; + // + private Date createdAt ; + // + private String filePath ; + // + private String recordId ; + // + private AudioType audioFileType ; + // + private Long audioFileId ; + // + private String streamPath ; + + + // + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + // + + public AudioType getType() { + return type; + } + + public void setType(AudioType type) { + this.type = type; + } + // + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + // + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + // + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + // + + public String getWordstring() { + return wordstring; + } + + public void setWordstring(String wordstring) { + this.wordstring = wordstring; + } + // + + public Long getWordId() { + return wordId; + } + + public void setWordId(Long wordId) { + this.wordId = wordId; + } + // + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + // + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + // + + public String getRecordId() { + return recordId; + } + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + // + + public AudioType getAudioFileType() { + return audioFileType; + } + + public void setAudioFileType(AudioType audioFileType) { + this.audioFileType = audioFileType; + } + // + + public Long getAudioFileId() { + return audioFileId; + } + + public void setAudioFileId(Long audioFileId) { + this.audioFileId = audioFileId; + } + // + + public String getStreamPath() { + return streamPath; + } + + public void setStreamPath(String streamPath) { + this.streamPath = streamPath; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/AudioType.java b/android/driver/src/main/java/com/wordnik/model/AudioType.java new file mode 100644 index 00000000000..c67211f4e40 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/AudioType.java @@ -0,0 +1,43 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class AudioType extends WordnikObject { + + // + private String name ; + // + private int id ; + + + // + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + // + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/AuthenticationToken.java b/android/driver/src/main/java/com/wordnik/model/AuthenticationToken.java new file mode 100644 index 00000000000..d3ef086e5fe --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/AuthenticationToken.java @@ -0,0 +1,43 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class AuthenticationToken extends WordnikObject { + + // + private String token ; + // + private Long userId ; + + + // + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + // + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/Bigram.java b/android/driver/src/main/java/com/wordnik/model/Bigram.java new file mode 100644 index 00000000000..53a18a2fe94 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/Bigram.java @@ -0,0 +1,76 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class Bigram extends WordnikObject { + + // + private Long count ; + // + private String gram1 ; + // + private String gram2 ; + // + private Double mi ; + // + private Double wlmi ; + + + // + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + // + + public String getGram1() { + return gram1; + } + + public void setGram1(String gram1) { + this.gram1 = gram1; + } + // + + public String getGram2() { + return gram2; + } + + public void setGram2(String gram2) { + this.gram2 = gram2; + } + // + + public Double getMi() { + return mi; + } + + public void setMi(Double mi) { + this.mi = mi; + } + // + + public Double getWlmi() { + return wlmi; + } + + public void setWlmi(Double wlmi) { + this.wlmi = wlmi; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/Category.java b/android/driver/src/main/java/com/wordnik/model/Category.java new file mode 100644 index 00000000000..5514dea02e4 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/Category.java @@ -0,0 +1,32 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class Category extends WordnikObject { + + // + private String name ; + + + // + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/Citation.java b/android/driver/src/main/java/com/wordnik/model/Citation.java new file mode 100644 index 00000000000..6fb91465e03 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/Citation.java @@ -0,0 +1,43 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class Citation extends WordnikObject { + + // + private String source ; + // + private String cite ; + + + // + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + // + + public String getCite() { + return cite; + } + + public void setCite(String cite) { + this.cite = cite; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/ContentProvider.java b/android/driver/src/main/java/com/wordnik/model/ContentProvider.java new file mode 100644 index 00000000000..0c994e62050 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/ContentProvider.java @@ -0,0 +1,43 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class ContentProvider extends WordnikObject { + + // + private String name ; + // + private int id ; + + + // + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + // + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} \ No newline at end of file diff --git a/android/driver/src/main/java/com/wordnik/model/Definition.java b/android/driver/src/main/java/com/wordnik/model/Definition.java new file mode 100644 index 00000000000..0653667b393 --- /dev/null +++ b/android/driver/src/main/java/com/wordnik/model/Definition.java @@ -0,0 +1,177 @@ +package com.wordnik.model; + +import com.wordnik.common.WordnikObject; +import com.wordnik.annotations.AllowableValues; +import com.wordnik.annotations.Required; + +import com.wordnik.common.WordListType; +import java.util.List; +import java.util.ArrayList; + + +/** + * + * NOTE: This class is auto generated by the drive code generator program so please do not edit the program manually. + * @author ramesh + * + */ +public class Definition extends WordnikObject { + + // + private List exampleUses = new ArrayList< ExampleUsage>(); + // + private String word ; + // + private String text ; + // + private List textProns = new ArrayList< TextPron>(); + // + private float score ; + // + private String partOfSpeech ; + // + private List notes = new ArrayList< Note>(); + // + private List citations = new ArrayList< Citation>(); + // + private List relatedWords = new ArrayList< Related>(); + // + private String sourceDictionary ; + // + private List