id
int32
0
12.9k
code
sequencelengths
2
264k
8,300
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "com", ".", "google", ".", "common", ".", "base", ".", "Joiner", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "HttpClient", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "methods", ".", "HttpPost", ";", "import", "org", ".", "apache", ".", "http", ".", "entity", ".", "StringEntity", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "DefaultHttpClient", ";", "import", "org", ".", "payments4j", ".", "core", ".", "AbstractPaymentGateway", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ".", "AbstractBaseConverter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ".", "CredentialsConverter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ".", "CreditCardConverter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ".", "MoneyConverter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "PayFlowProPaymentGateway", "extends", "AbstractPaymentGateway", "{", "public", "static", "final", "String", "HOST_ADDRESS", "=", "\"\"", ";", "public", "static", "final", "String", "TEST_HOST_ADDRESS", "=", "\"\"", ";", "private", "CredentialsConverter", "credentialsConverter", ";", "private", "boolean", "test", ";", "public", "PayFlowProPaymentGateway", "(", "String", "username", ",", "String", "password", ")", "{", "this", ".", "credentialsConverter", "=", "new", "CredentialsConverter", "(", "username", ",", "password", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doPurchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "buildParamList", "(", "new", "MoneyConverter", "(", "money", ")", ",", "new", "CreditCardConverter", "(", "creditCard", ")", ",", "credentialsConverter", ")", ";", "return", "executeTransaction", "(", "paramsList", ",", "\"S\"", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doAuthorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "buildParamList", "(", "new", "MoneyConverter", "(", "money", ")", ",", "new", "CreditCardConverter", "(", "creditCard", ")", ",", "credentialsConverter", ")", ";", "return", "executeTransaction", "(", "paramsList", ",", "\"A\"", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCapture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "buildParamList", "(", "new", "MoneyConverter", "(", "money", ")", ",", "credentialsConverter", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"ORIGID\"", ",", "authorizationId", ")", ")", ";", "return", "executeTransaction", "(", "paramsList", ",", "\"D\"", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRevert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "buildParamList", "(", "credentialsConverter", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"ORIGID\"", ",", "transactionId", ")", ")", ";", "return", "executeTransaction", "(", "paramsList", ",", "\"V\"", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCredit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "buildParamList", "(", "credentialsConverter", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"ORIGID\"", ",", "transactionId", ")", ")", ";", "return", "executeTransaction", "(", "paramsList", ",", "\"C\"", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRecurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doStoreCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doEvictCreditCard", "(", "String", "creditCardId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "boolean", "supportsPurchase", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsAuthorize", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCapture", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsRevert", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCredit", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsStoreCreditCard", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "boolean", "supportsEvictCreditCard", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "void", "setTest", "(", "boolean", "test", ")", "{", "this", ".", "test", "=", "test", ";", "}", "private", "TransactionResponse", "executeTransaction", "(", "List", "<", "Pair", ">", "paramsList", ",", "String", "transactionType", ")", "{", "HttpPost", "post", "=", "buildHttpPost", "(", "test", "?", "TEST_HOST_ADDRESS", ":", "HOST_ADDRESS", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"VERBOSITY\"", ",", "\"MEDIUM\"", ")", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"TRXTYPE\"", ",", "transactionType", ")", ")", ";", "post", ".", "setEntity", "(", "toStringEntity", "(", "paramsList", ")", ")", ";", "try", "{", "HttpClient", "httpClient", "=", "buildHttpClient", "(", ")", ";", "return", "httpClient", ".", "execute", "(", "post", ",", "new", "PayFlowResponseHandler", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "private", "List", "<", "Pair", ">", "buildParamList", "(", "AbstractBaseConverter", "...", "converters", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "new", "ArrayList", "<", "Pair", ">", "(", ")", ";", "for", "(", "AbstractBaseConverter", "converter", ":", "converters", ")", "{", "paramsList", ".", "addAll", "(", "converter", ".", "toParamsList", "(", ")", ")", ";", "}", "return", "paramsList", ";", "}", "private", "StringEntity", "toStringEntity", "(", "List", "<", "Pair", ">", "paramsList", ")", "{", "String", "params", "=", "Joiner", ".", "on", "(", "\"&\"", ")", ".", "join", "(", "paramsList", ")", ";", "try", "{", "return", "new", "StringEntity", "(", "params", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "return", "null", ";", "}", "}", "HttpClient", "buildHttpClient", "(", ")", "{", "return", "new", "DefaultHttpClient", "(", ")", ";", "}", "HttpPost", "buildHttpPost", "(", "String", "url", ")", "{", "return", "new", "HttpPost", "(", "url", ")", ";", "}", "}", "</s>" ]
8,301
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "com", ".", "google", ".", "common", ".", "collect", ".", "ImmutableMultimap", ";", "import", "com", ".", "google", ".", "common", ".", "collect", ".", "Multimap", ";", "import", "org", ".", "apache", ".", "commons", ".", "beanutils", ".", "ConvertUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "beanutils", ".", "PropertyUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "beanutils", ".", "WrapDynaBean", ";", "import", "org", ".", "apache", ".", "http", ".", "HttpResponse", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "ClientProtocolException", ";", "import", "org", ".", "apache", ".", "http", ".", "client", ".", "ResponseHandler", ";", "import", "org", ".", "apache", ".", "http", ".", "impl", ".", "client", ".", "BasicResponseHandler", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "util", ".", "Collection", ";", "public", "class", "PayFlowResponseHandler", "implements", "ResponseHandler", "<", "TransactionResponse", ">", "{", "private", "static", "final", "Multimap", "<", "String", ",", "String", ">", "nameToProperty", "=", "new", "ImmutableMultimap", ".", "Builder", "<", "String", ",", "String", ">", "(", ")", ".", "putAll", "(", "\"PNREF\"", ",", "\"\"", ")", ".", "putAll", "(", "\"RESULT\"", ",", "\"code\"", ",", "\"reasonCode\"", ")", ".", "putAll", "(", "\"RESPMSG\"", ",", "\"message\"", ")", ".", "build", "(", ")", ";", "@", "Override", "public", "TransactionResponse", "handleResponse", "(", "HttpResponse", "response", ")", "throws", "ClientProtocolException", ",", "IOException", "{", "BasicResponseHandler", "basicResponseHandler", "=", "new", "BasicResponseHandler", "(", ")", ";", "String", "responseString", "=", "basicResponseHandler", ".", "handleResponse", "(", "response", ")", ";", "TransactionResponse", "transactionResponse", "=", "buildTransactionResponse", "(", "responseString", ")", ";", "if", "(", "transactionResponse", ".", "getCode", "(", ")", "==", "0", ")", "{", "transactionResponse", ".", "setSuccessful", "(", "true", ")", ";", "}", "return", "transactionResponse", ";", "}", "private", "TransactionResponse", "buildTransactionResponse", "(", "String", "responseString", ")", "{", "TransactionResponse", "transactionResponse", "=", "new", "TransactionResponse", "(", ")", ";", "WrapDynaBean", "dynaBean", "=", "new", "WrapDynaBean", "(", "transactionResponse", ")", ";", "String", "[", "]", "pairs", "=", "responseString", ".", "split", "(", "\"&\"", ")", ";", "for", "(", "String", "pair", ":", "pairs", ")", "{", "String", "[", "]", "parts", "=", "pair", ".", "split", "(", "\"=\"", ")", ";", "setProperties", "(", "dynaBean", ",", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", ")", ";", "}", "return", "(", "TransactionResponse", ")", "dynaBean", ".", "getInstance", "(", ")", ";", "}", "private", "void", "setProperties", "(", "WrapDynaBean", "dynaBean", ",", "String", "name", ",", "String", "value", ")", "{", "Collection", "<", "String", ">", "properties", "=", "nameToProperty", ".", "get", "(", "name", ")", ";", "if", "(", "properties", "!=", "null", "&&", "!", "properties", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "String", "property", ":", "properties", ")", "{", "try", "{", "Class", "propertyType", "=", "PropertyUtils", ".", "getPropertyType", "(", "dynaBean", ".", "getInstance", "(", ")", ",", "property", ")", ";", "if", "(", "propertyType", "==", "String", ".", "class", ")", "{", "dynaBean", ".", "set", "(", "property", ",", "value", ")", ";", "}", "else", "{", "dynaBean", ".", "set", "(", "property", ",", "ConvertUtils", ".", "convert", "(", "value", ",", "propertyType", ")", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "nameToProperty", ".", "hashCode", "(", ")", ";", "}", "}", "</s>" ]
8,302
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "static", "java", ".", "lang", ".", "String", ".", "format", ";", "public", "class", "Pair", "{", "private", "String", "name", ";", "private", "String", "value", ";", "public", "Pair", "(", "String", "name", ",", "String", "value", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "value", "=", "value", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "void", "setValue", "(", "String", "value", ")", "{", "this", ".", "value", "=", "value", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "name", ")", ".", "append", "(", "this", ".", "value", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "Pair", "that", "=", "(", "Pair", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "name", ",", "that", ".", "name", ")", ".", "append", "(", "this", ".", "value", ",", "that", ".", "value", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "format", "(", "\"%s[%s]=%s\"", ",", "name", ",", "value", ".", "length", "(", ")", ",", "value", ")", ";", "}", "}", "</s>" ]
8,303
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "static", "java", ".", "lang", ".", "String", ".", "format", ";", "public", "class", "CreditCardConverter", "extends", "AbstractBaseConverter", "{", "private", "CreditCard", "creditCard", ";", "public", "CreditCardConverter", "(", "CreditCard", "creditCard", ")", "{", "this", ".", "creditCard", "=", "creditCard", ";", "}", "public", "List", "<", "Pair", ">", "toParamsList", "(", ")", "{", "List", "<", "Pair", ">", "params", "=", "new", "ArrayList", "<", "Pair", ">", "(", ")", ";", "addPair", "(", "params", ",", "\"ACCT\"", ",", "creditCard", ".", "getNumber", "(", ")", ")", ";", "addPair", "(", "params", ",", "\"EXPDATE\"", ",", "format", "(", "\"%s%s\"", ",", "creditCard", ".", "getMonth", "(", ")", ",", "creditCard", ".", "getYear", "(", ")", ".", "substring", "(", "2", ")", ")", ")", ";", "addPair", "(", "params", ",", "\"CVV2\"", ",", "creditCard", ".", "getSecurityCode", "(", ")", ")", ";", "addPair", "(", "params", ",", "\"FIRSTNAME\"", ",", "creditCard", ".", "getFirstName", "(", ")", ")", ";", "addPair", "(", "params", ",", "\"LASTNAME\"", ",", "creditCard", ".", "getLastName", "(", ")", ")", ";", "addPair", "(", "params", ",", "\"TENDER\"", ",", "\"C\"", ")", ";", "return", "params", ";", "}", "}", "</s>" ]
8,304
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "List", ";", "public", "abstract", "class", "AbstractBaseConverter", "{", "public", "abstract", "List", "<", "Pair", ">", "toParamsList", "(", ")", ";", "protected", "void", "addPair", "(", "List", "<", "Pair", ">", "params", ",", "String", "name", ",", "String", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "params", ".", "add", "(", "new", "Pair", "(", "name", ",", "value", ")", ")", ";", "}", "}", "}", "</s>" ]
8,305
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "static", "java", ".", "lang", ".", "String", ".", "format", ";", "public", "class", "MoneyConverter", "extends", "AbstractBaseConverter", "{", "private", "Money", "money", ";", "public", "MoneyConverter", "(", "Money", "money", ")", "{", "this", ".", "money", "=", "money", ";", "}", "public", "List", "<", "Pair", ">", "toParamsList", "(", ")", "{", "List", "<", "Pair", ">", "params", "=", "new", "ArrayList", "<", "Pair", ">", "(", ")", ";", "addPair", "(", "params", ",", "\"AMT\"", ",", "format", "(", "\"%1$#.2f\"", ",", "money", ".", "getAmount", "(", ")", ")", ")", ";", "addPair", "(", "params", ",", "\"CURRENCY\"", ",", "money", ".", "getCurrency", "(", ")", ".", "getCurrencyCode", "(", ")", ")", ";", "return", "params", ";", "}", "}", "</s>" ]
8,306
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "converter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "payflowpro", ".", "Pair", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "CredentialsConverter", "extends", "AbstractBaseConverter", "{", "private", "String", "username", ";", "private", "String", "password", ";", "public", "CredentialsConverter", "(", "String", "username", ",", "String", "password", ")", "{", "this", ".", "username", "=", "username", ";", "this", ".", "password", "=", "password", ";", "}", "@", "Override", "public", "List", "<", "Pair", ">", "toParamsList", "(", ")", "{", "List", "<", "Pair", ">", "paramsList", "=", "new", "ArrayList", "<", "Pair", ">", "(", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"USER\"", ",", "username", ")", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"VENDOR\"", ",", "username", ")", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"PWD\"", ",", "password", ")", ")", ";", "paramsList", ".", "add", "(", "new", "Pair", "(", "\"PARTNER\"", ",", "\"PayPal\"", ")", ")", ";", "return", "paramsList", ";", "}", "}", "</s>" ]
8,307
[ "<s>", "package", "org", ".", "payments4j", ".", "common", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "UUID", ";", "import", "static", "com", ".", "google", ".", "common", ".", "base", ".", "Preconditions", ".", "checkArgument", ";", "public", "class", "ParamUtil", "{", "private", "ParamUtil", "(", ")", "{", "}", "public", "static", "void", "requireOption", "(", "Map", "<", "String", ",", "Object", ">", "options", ",", "String", "option", ")", "{", "checkArgument", "(", "options", "!=", "null", "&&", "options", ".", "get", "(", "option", ")", "!=", "null", ",", "\"\"", ",", "option", ")", ";", "}", "public", "static", "String", "requestId", "(", ")", "{", "return", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,308
[ "<s>", "package", "org", ".", "payments4j", ".", "test", ".", "spi", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "payments4j", ".", "core", ".", "PaymentGateway", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCardBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "MoneyBuilder", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "Random", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "public", "abstract", "class", "AbstractBasePaymentGatewayIntegrationTest", "{", "protected", "Money", "money", ";", "protected", "CreditCard", "creditCard", ";", "protected", "PaymentGateway", "gateway", ";", "protected", "Properties", "credentials", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "if", "(", "credentials", "==", "null", ")", "{", "credentials", "=", "new", "Properties", "(", ")", ";", "credentials", ".", "load", "(", "this", ".", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "}", "int", "amount", "=", "new", "Random", "(", "System", ".", "nanoTime", "(", ")", ")", ".", "nextInt", "(", "30", ")", ";", "money", "=", "new", "MoneyBuilder", "(", ")", ".", "withAmount", "(", "String", ".", "valueOf", "(", "amount", ")", ")", ".", "withCurrency", "(", "Locale", ".", "US", ")", ".", "build", "(", ")", ";", "creditCard", "=", "getCreditCard", "(", ")", ";", "this", ".", "gateway", "=", "buildGateway", "(", ")", ";", "}", "protected", "abstract", "PaymentGateway", "buildGateway", "(", ")", ";", "protected", "CreditCard", "getCreditCard", "(", ")", "{", "return", "new", "CreditCardBuilder", "(", ")", ".", "withFirstName", "(", "\"Joe\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withMonth", "(", "\"11\"", ")", ".", "withYear", "(", "\"2013\"", ")", ".", "withNumber", "(", "\"\"", ")", ".", "withSecurityCode", "(", "\"132\"", ")", ".", "withType", "(", "MASTER_CARD", ")", ".", "build", "(", ")", ";", "}", "protected", "Map", "<", "String", ",", "Object", ">", "getCreditOptions", "(", ")", "{", "return", "null", ";", "}", "protected", "Map", "<", "String", ",", "Object", ">", "getCaptureOptions", "(", ")", "{", "return", "null", ";", "}", "protected", "Map", "<", "String", ",", "Object", ">", "getAuthOptions", "(", ")", "{", "return", "null", ";", "}", "protected", "Map", "<", "String", ",", "Object", ">", "getPurchaseOptions", "(", ")", "{", "return", "null", ";", "}", "protected", "Map", "<", "String", ",", "Object", ">", "getRevertOptions", "(", ")", "{", "return", "null", ";", "}", "@", "Test", "public", "void", "testAuthCaptureCredit", "(", ")", "throws", "Exception", "{", "TransactionResponse", "authResponse", "=", "gateway", ".", "authorize", "(", "money", ",", "creditCard", ",", "getAuthOptions", "(", ")", ")", ";", "assertThat", "(", "authResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "authResponse", ")", ".", "isTrue", "(", ")", ";", "TransactionResponse", "captureResponse", "=", "gateway", ".", "capture", "(", "money", ",", "authResponse", ".", "getAuthorizationId", "(", ")", ",", "getCaptureOptions", "(", ")", ")", ";", "assertThat", "(", "captureResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "captureResponse", ")", ".", "isTrue", "(", ")", ";", "TransactionResponse", "creditResponse", "=", "gateway", ".", "credit", "(", "money", ",", "captureResponse", ".", "getAuthorizationId", "(", ")", ",", "getCreditOptions", "(", ")", ")", ";", "assertThat", "(", "creditResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "creditResponse", ")", ".", "isTrue", "(", ")", ";", "}", "@", "Test", "public", "void", "testPurchaseCredit", "(", ")", "throws", "Exception", "{", "TransactionResponse", "purchaseResponse", "=", "gateway", ".", "purchase", "(", "money", ",", "creditCard", ",", "getPurchaseOptions", "(", ")", ")", ";", "assertThat", "(", "purchaseResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "purchaseResponse", ")", ".", "isTrue", "(", ")", ";", "TransactionResponse", "creditResponse", "=", "gateway", ".", "credit", "(", "money", ",", "purchaseResponse", ".", "getAuthorizationId", "(", ")", ",", "getCreditOptions", "(", ")", ")", ";", "assertThat", "(", "creditResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "creditResponse", ")", ".", "isTrue", "(", ")", ";", "}", "@", "Test", "public", "void", "testAuthRevert", "(", ")", "throws", "Exception", "{", "TransactionResponse", "authResponse", "=", "gateway", ".", "authorize", "(", "money", ",", "creditCard", ",", "getAuthOptions", "(", ")", ")", ";", "assertThat", "(", "authResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "authResponse", ")", ".", "isTrue", "(", ")", ";", "TransactionResponse", "revertResponse", "=", "gateway", ".", "revert", "(", "authResponse", ".", "getAuthorizationId", "(", ")", ",", "getRevertOptions", "(", ")", ")", ";", "assertThat", "(", "revertResponse", ".", "isSuccessful", "(", ")", ")", ".", "as", "(", "\"\"", "+", "revertResponse", ")", ".", "isTrue", "(", ")", ";", "}", "}", "</s>" ]
8,309
[ "<s>", "package", "org", ".", "payments4j", ".", "core", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "public", "class", "TransactionResponse", "{", "private", "boolean", "successful", ";", "private", "boolean", "test", ";", "private", "String", "authorizationId", ";", "private", "String", "message", ";", "private", "long", "code", ";", "private", "long", "reasonCode", ";", "private", "AvsResponse", "avsResponse", ";", "private", "CvvResponse", "cvvResponse", ";", "public", "boolean", "isSuccessful", "(", ")", "{", "return", "successful", ";", "}", "public", "void", "setSuccessful", "(", "boolean", "successful", ")", "{", "this", ".", "successful", "=", "successful", ";", "}", "public", "boolean", "isTest", "(", ")", "{", "return", "test", ";", "}", "public", "void", "setTest", "(", "boolean", "test", ")", "{", "this", ".", "test", "=", "test", ";", "}", "public", "String", "getAuthorizationId", "(", ")", "{", "return", "authorizationId", ";", "}", "public", "void", "setAuthorizationId", "(", "String", "authorizationId", ")", "{", "this", ".", "authorizationId", "=", "authorizationId", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "message", ";", "}", "public", "void", "setMessage", "(", "String", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "public", "long", "getCode", "(", ")", "{", "return", "code", ";", "}", "public", "void", "setCode", "(", "long", "code", ")", "{", "this", ".", "code", "=", "code", ";", "}", "public", "long", "getReasonCode", "(", ")", "{", "return", "reasonCode", ";", "}", "public", "void", "setReasonCode", "(", "long", "reasonCode", ")", "{", "this", ".", "reasonCode", "=", "reasonCode", ";", "}", "public", "AvsResponse", "getAvsResponse", "(", ")", "{", "return", "avsResponse", ";", "}", "public", "void", "setAvsResponse", "(", "AvsResponse", "avsResponse", ")", "{", "this", ".", "avsResponse", "=", "avsResponse", ";", "}", "public", "CvvResponse", "getCvvResponse", "(", ")", "{", "return", "cvvResponse", ";", "}", "public", "void", "setCvvResponse", "(", "CvvResponse", "cvvResponse", ")", "{", "this", ".", "cvvResponse", "=", "cvvResponse", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "successful", ")", ".", "append", "(", "test", ")", ".", "append", "(", "authorizationId", ")", ".", "append", "(", "message", ")", ".", "append", "(", "code", ")", ".", "append", "(", "reasonCode", ")", ".", "append", "(", "avsResponse", ")", ".", "append", "(", "cvvResponse", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "TransactionResponse", "that", "=", "(", "TransactionResponse", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "successful", ",", "that", ".", "successful", ")", ".", "append", "(", "this", ".", "test", ",", "that", ".", "test", ")", ".", "append", "(", "this", ".", "authorizationId", ",", "that", ".", "authorizationId", ")", ".", "append", "(", "this", ".", "message", ",", "that", ".", "message", ")", ".", "append", "(", "this", ".", "code", ",", "that", ".", "code", ")", ".", "append", "(", "this", ".", "reasonCode", ",", "that", ".", "reasonCode", ")", ".", "append", "(", "this", ".", "avsResponse", ",", "that", ".", "avsResponse", ")", ".", "append", "(", "this", ".", "avsResponse", ",", "that", ".", "avsResponse", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"successful\"", ",", "successful", ")", ".", "append", "(", "\"test\"", ",", "test", ")", ".", "append", "(", "\"\"", ",", "authorizationId", ")", ".", "append", "(", "\"message\"", ",", "message", ")", ".", "append", "(", "\"code\"", ",", "code", ")", ".", "append", "(", "\"reasonCode\"", ",", "reasonCode", ")", ".", "append", "(", "\"avsResponse\"", ",", "avsResponse", ")", ".", "append", "(", "\"cvvResponse\"", ",", "cvvResponse", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,310
[ "<s>", "package", "org", ".", "payments4j", ".", "core", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "interface", "PaymentGateway", "{", "TransactionResponse", "purchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "authorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "capture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "revert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "credit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "recurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "storeCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "TransactionResponse", "evictCreditCard", "(", "String", "creditCardId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "boolean", "supportsPurchase", "(", ")", ";", "boolean", "supportsAuthorize", "(", ")", ";", "boolean", "supportsCapture", "(", ")", ";", "boolean", "supportsRevert", "(", ")", ";", "boolean", "supportsCredit", "(", ")", ";", "boolean", "supportsStoreCreditCard", "(", ")", ";", "boolean", "supportsEvictCreditCard", "(", ")", ";", "void", "setTest", "(", "boolean", "test", ")", ";", "}", "</s>" ]
8,311
[ "<s>", "package", "org", ".", "payments4j", ".", "core", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "perf4j", ".", "StopWatch", ";", "import", "org", ".", "perf4j", ".", "slf4j", ".", "Slf4JStopWatch", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "java", ".", "lang", ".", "String", ".", "format", ";", "import", "static", "org", ".", "payments4j", ".", "common", ".", "ParamUtil", ".", "requestId", ";", "public", "abstract", "class", "AbstractPaymentGateway", "implements", "PaymentGateway", "{", "protected", "static", "Logger", "LOGGER", ";", "protected", "static", "StopWatch", "STOP_WATCH", ";", "protected", "AbstractPaymentGateway", "(", ")", "{", "LOGGER", "=", "LoggerFactory", ".", "getLogger", "(", "this", ".", "getClass", "(", ")", ")", ";", "STOP_WATCH", "=", "new", "Slf4JStopWatch", "(", "LOGGER", ")", ";", "STOP_WATCH", ".", "stop", "(", ")", ";", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "}", "@", "Override", "public", "TransactionResponse", "purchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"purchase\"", ")", ";", "logParam", "(", "\"money\"", ",", "requestId", ",", "money", ")", ";", "logParam", "(", "\"creditCard\"", ",", "requestId", ",", "creditCard", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doPurchase", "(", "money", ",", "creditCard", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"purchase\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doPurchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "authorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"authorize\"", ")", ";", "logParam", "(", "\"money\"", ",", "requestId", ",", "money", ")", ";", "logParam", "(", "\"creditCard\"", ",", "requestId", ",", "creditCard", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doAuthorize", "(", "money", ",", "creditCard", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"authorize\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doAuthorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "capture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"capture\"", ")", ";", "logParam", "(", "\"money\"", ",", "requestId", ",", "money", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doCapture", "(", "money", ",", "authorizationId", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"capture\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doCapture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "revert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"revert\"", ")", ";", "logParam", "(", "\"\"", ",", "requestId", ",", "transactionId", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doRevert", "(", "transactionId", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"revert\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doRevert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "credit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"credit\"", ")", ";", "logParam", "(", "\"money\"", ",", "requestId", ",", "money", ")", ";", "logParam", "(", "\"\"", ",", "requestId", ",", "transactionId", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doCredit", "(", "money", ",", "transactionId", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"credit\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doCredit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "recurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"recurring\"", ")", ";", "logParam", "(", "\"money\"", ",", "requestId", ",", "money", ")", ";", "logParam", "(", "\"creditCard\"", ",", "requestId", ",", "creditCard", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doRecurring", "(", "money", ",", "creditCard", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"recurring\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doRecurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "storeCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"\"", ")", ";", "logParam", "(", "\"creditCard\"", ",", "requestId", ",", "creditCard", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doStoreCreditCard", "(", "creditCard", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"\"", ")", ";", "return", "transactionResponse", ";", "}", "protected", "abstract", "TransactionResponse", "doStoreCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "@", "Override", "public", "TransactionResponse", "evictCreditCard", "(", "String", "creditCardId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "String", "requestId", "=", "requestId", "(", ")", ";", "options", "=", "initOptions", "(", "options", ")", ";", "options", ".", "put", "(", "\"requestId\"", ",", "requestId", ")", ";", "logOperationStart", "(", "requestId", ",", "\"\"", ")", ";", "logParam", "(", "\"creditCardId\"", ",", "requestId", ",", "creditCardId", ")", ";", "logParam", "(", "\"options\"", ",", "requestId", ",", "options", ")", ";", "TransactionResponse", "transactionResponse", "=", "doEvictCreditCard", "(", "creditCardId", ",", "options", ")", ";", "logResponse", "(", "requestId", ",", "transactionResponse", ")", ";", "logOperationEnd", "(", "requestId", ",", "\"\"", ")", ";", "return", "transactionResponse", ";", "}", "private", "Map", "<", "String", ",", "Object", ">", "initOptions", "(", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "}", "return", "options", ";", "}", "protected", "abstract", "TransactionResponse", "doEvictCreditCard", "(", "String", "creditCardIdd", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", ";", "private", "void", "logResponse", "(", "String", "requestId", ",", "TransactionResponse", "transactionResponse", ")", "{", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"\"", ",", "requestId", ",", "transactionResponse", ")", ";", "}", "}", "private", "void", "logParam", "(", "String", "name", ",", "String", "requestId", ",", "Object", "value", ")", "{", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"\"", "+", "name", "+", "\"={}].\"", ",", "requestId", ",", "value", ")", ";", "}", "}", "private", "void", "logOperationStart", "(", "String", "requestId", ",", "String", "operation", ")", "{", "String", "message", "=", "format", "(", "\"\"", ",", "requestId", ",", "operation", ")", ";", "STOP_WATCH", ".", "setTag", "(", "message", ")", ";", "LOGGER", ".", "info", "(", "message", ")", ";", "}", "private", "void", "logOperationEnd", "(", "String", "requestId", ",", "String", "operation", ")", "{", "STOP_WATCH", ".", "stop", "(", ")", ";", "LOGGER", ".", "info", "(", "\"\"", "+", "operation", "+", "\"", "operation.\"", ",", "requestId", ")", ";", "}", "}", "</s>" ]
8,312
[ "<s>", "package", "org", ".", "payments4j", ".", "core", ";", "public", "class", "AvsResponse", "{", "private", "String", "code", ";", "private", "String", "message", ";", "private", "String", "streetMatch", ";", "private", "String", "postalMatch", ";", "public", "String", "getCode", "(", ")", "{", "return", "code", ";", "}", "public", "void", "setCode", "(", "String", "code", ")", "{", "this", ".", "code", "=", "code", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "message", ";", "}", "public", "void", "setMessage", "(", "String", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "public", "String", "getStreetMatch", "(", ")", "{", "return", "streetMatch", ";", "}", "public", "void", "setStreetMatch", "(", "String", "streetMatch", ")", "{", "this", ".", "streetMatch", "=", "streetMatch", ";", "}", "public", "String", "getPostalMatch", "(", ")", "{", "return", "postalMatch", ";", "}", "public", "void", "setPostalMatch", "(", "String", "postalMatch", ")", "{", "this", ".", "postalMatch", "=", "postalMatch", ";", "}", "}", "</s>" ]
8,313
[ "<s>", "package", "org", ".", "payments4j", ".", "core", ";", "public", "class", "CvvResponse", "{", "private", "String", "code", ";", "private", "String", "message", ";", "public", "String", "getCode", "(", ")", "{", "return", "code", ";", "}", "public", "void", "setCode", "(", "String", "code", ")", "{", "this", ".", "code", "=", "code", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "message", ";", "}", "public", "void", "setMessage", "(", "String", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "}", "</s>" ]
8,314
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "public", "class", "AddressBuilder", "extends", "AbstractBaseModelBuilder", "<", "Address", ">", "{", "public", "AddressBuilder", "(", ")", "{", "super", "(", "Address", ".", "class", ")", ";", "}", "public", "AddressBuilder", "withFirstName", "(", "String", "firstName", ")", "{", "values", ".", "put", "(", "\"firstName\"", ",", "firstName", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withLastName", "(", "String", "lastName", ")", "{", "values", ".", "put", "(", "\"lastName\"", ",", "lastName", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withEmail", "(", "String", "email", ")", "{", "values", ".", "put", "(", "\"email\"", ",", "email", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withCompany", "(", "String", "company", ")", "{", "values", ".", "put", "(", "\"company\"", ",", "company", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withAddress1", "(", "String", "address1", ")", "{", "values", ".", "put", "(", "\"address1\"", ",", "address1", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withAddress2", "(", "String", "address2", ")", "{", "values", ".", "put", "(", "\"address2\"", ",", "address2", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withCity", "(", "String", "city", ")", "{", "values", ".", "put", "(", "\"city\"", ",", "city", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withState", "(", "String", "state", ")", "{", "values", ".", "put", "(", "\"state\"", ",", "state", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withCountryIsoCode", "(", "String", "countryIsoCode", ")", "{", "values", ".", "put", "(", "\"\"", ",", "countryIsoCode", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withPostalCode", "(", "String", "postalCode", ")", "{", "values", ".", "put", "(", "\"postalCode\"", ",", "postalCode", ")", ";", "return", "this", ";", "}", "public", "AddressBuilder", "withPhone", "(", "String", "phone", ")", "{", "values", ".", "put", "(", "\"phone\"", ",", "phone", ")", ";", "return", "this", ";", "}", "}", "</s>" ]
8,315
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "public", "class", "OrderLineBuilder", "extends", "AbstractBaseModelBuilder", "<", "OrderLine", ">", "{", "public", "OrderLineBuilder", "(", ")", "{", "super", "(", "OrderLine", ".", "class", ")", ";", "}", "public", "OrderLineBuilder", "withId", "(", "String", "id", ")", "{", "values", ".", "put", "(", "\"id\"", ",", "id", ")", ";", "return", "this", ";", "}", "public", "OrderLineBuilder", "withUnitPrice", "(", "Money", "unitPrice", ")", "{", "values", ".", "put", "(", "\"unitPrice\"", ",", "unitPrice", ")", ";", "return", "this", ";", "}", "public", "OrderLineBuilder", "withQuantity", "(", "long", "quantity", ")", "{", "values", ".", "put", "(", "\"quantity\"", ",", "quantity", ")", ";", "return", "this", ";", "}", "public", "OrderLineBuilder", "withDescription", "(", "String", "description", ")", "{", "values", ".", "put", "(", "\"description\"", ",", "description", ")", ";", "return", "this", ";", "}", "}", "</s>" ]
8,316
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "class", "OrderBuilder", "extends", "AbstractBaseModelBuilder", "<", "Order", ">", "{", "public", "OrderBuilder", "(", ")", "{", "super", "(", "Order", ".", "class", ")", ";", "}", "public", "OrderBuilder", "withId", "(", "String", "id", ")", "{", "values", ".", "put", "(", "\"id\"", ",", "id", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withIpAddress", "(", "String", "ipAddress", ")", "{", "values", ".", "put", "(", "\"ipAddress\"", ",", "ipAddress", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withCustomerName", "(", "String", "customerName", ")", "{", "values", ".", "put", "(", "\"customerName\"", ",", "customerName", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withCustomerEmail", "(", "String", "customerEmail", ")", "{", "values", ".", "put", "(", "\"\"", ",", "customerEmail", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withInvoiceNumber", "(", "String", "invoiceNumber", ")", "{", "values", ".", "put", "(", "\"\"", ",", "invoiceNumber", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withMerchant", "(", "String", "merchant", ")", "{", "values", ".", "put", "(", "\"merchant\"", ",", "merchant", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withDescription", "(", "String", "description", ")", "{", "values", ".", "put", "(", "\"description\"", ",", "description", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withBillingAddress", "(", "Address", "billingAddress", ")", "{", "values", ".", "put", "(", "\"\"", ",", "billingAddress", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withShippingAddress", "(", "Address", "shippingAddress", ")", "{", "values", ".", "put", "(", "\"\"", ",", "shippingAddress", ")", ";", "return", "this", ";", "}", "public", "OrderBuilder", "withOrderLines", "(", "Set", "<", "OrderLine", ">", "orderLines", ")", "{", "values", ".", "put", "(", "\"orderLines\"", ",", "orderLines", ")", ";", "return", "this", ";", "}", "}", "</s>" ]
8,317
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "public", "class", "OrderLine", "{", "private", "String", "id", ";", "private", "Money", "unitPrice", ";", "private", "long", "quantity", ";", "private", "String", "description", ";", "public", "String", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "String", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "Money", "getUnitPrice", "(", ")", "{", "return", "unitPrice", ";", "}", "public", "void", "setUnitPrice", "(", "Money", "unitPrice", ")", "{", "this", ".", "unitPrice", "=", "unitPrice", ";", "}", "public", "long", "getQuantity", "(", ")", "{", "return", "quantity", ";", "}", "public", "void", "setQuantity", "(", "long", "quantity", ")", "{", "this", ".", "quantity", "=", "quantity", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "description", ";", "}", "public", "void", "setDescription", "(", "String", "description", ")", "{", "this", ".", "description", "=", "description", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "id", ")", ".", "append", "(", "this", ".", "unitPrice", ")", ".", "append", "(", "this", ".", "quantity", ")", ".", "append", "(", "this", ".", "description", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "OrderLine", "that", "=", "(", "OrderLine", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "id", ",", "that", ".", "id", ")", ".", "append", "(", "this", ".", "unitPrice", ",", "that", ".", "unitPrice", ")", ".", "append", "(", "this", ".", "quantity", ",", "that", ".", "quantity", ")", ".", "append", "(", "this", ".", "description", ",", "that", ".", "description", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"id\"", ",", "this", ".", "id", ")", ".", "append", "(", "\"unitPrice\"", ",", "this", ".", "unitPrice", ")", ".", "append", "(", "\"quantity\"", ",", "this", ".", "quantity", ")", ".", "append", "(", "\"description\"", ",", "this", ".", "description", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,318
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "public", "class", "Address", "{", "private", "String", "firstName", ";", "private", "String", "lastName", ";", "private", "String", "email", ";", "private", "String", "company", ";", "private", "String", "address1", ";", "private", "String", "address2", ";", "private", "String", "city", ";", "private", "String", "state", ";", "private", "String", "countryIsoCode", ";", "private", "String", "postalCode", ";", "private", "String", "phone", ";", "public", "String", "getFirstName", "(", ")", "{", "return", "firstName", ";", "}", "public", "void", "setFirstName", "(", "String", "firstName", ")", "{", "this", ".", "firstName", "=", "firstName", ";", "}", "public", "String", "getLastName", "(", ")", "{", "return", "lastName", ";", "}", "public", "void", "setLastName", "(", "String", "lastName", ")", "{", "this", ".", "lastName", "=", "lastName", ";", "}", "public", "String", "getEmail", "(", ")", "{", "return", "email", ";", "}", "public", "void", "setEmail", "(", "String", "email", ")", "{", "this", ".", "email", "=", "email", ";", "}", "public", "String", "getCompany", "(", ")", "{", "return", "company", ";", "}", "public", "void", "setCompany", "(", "String", "company", ")", "{", "this", ".", "company", "=", "company", ";", "}", "public", "String", "getAddress1", "(", ")", "{", "return", "address1", ";", "}", "public", "void", "setAddress1", "(", "String", "address1", ")", "{", "this", ".", "address1", "=", "address1", ";", "}", "public", "String", "getAddress2", "(", ")", "{", "return", "address2", ";", "}", "public", "void", "setAddress2", "(", "String", "address2", ")", "{", "this", ".", "address2", "=", "address2", ";", "}", "public", "String", "getCity", "(", ")", "{", "return", "city", ";", "}", "public", "void", "setCity", "(", "String", "city", ")", "{", "this", ".", "city", "=", "city", ";", "}", "public", "String", "getState", "(", ")", "{", "return", "state", ";", "}", "public", "void", "setState", "(", "String", "state", ")", "{", "this", ".", "state", "=", "state", ";", "}", "public", "String", "getCountryIsoCode", "(", ")", "{", "return", "countryIsoCode", ";", "}", "public", "void", "setCountryIsoCode", "(", "String", "countryIsoCode", ")", "{", "this", ".", "countryIsoCode", "=", "countryIsoCode", ";", "}", "public", "String", "getPostalCode", "(", ")", "{", "return", "postalCode", ";", "}", "public", "void", "setPostalCode", "(", "String", "postalCode", ")", "{", "this", ".", "postalCode", "=", "postalCode", ";", "}", "public", "String", "getPhone", "(", ")", "{", "return", "phone", ";", "}", "public", "void", "setPhone", "(", "String", "phone", ")", "{", "this", ".", "phone", "=", "phone", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "firstName", ")", ".", "append", "(", "this", ".", "lastName", ")", ".", "append", "(", "this", ".", "email", ")", ".", "append", "(", "this", ".", "company", ")", ".", "append", "(", "this", ".", "address1", ")", ".", "append", "(", "this", ".", "address2", ")", ".", "append", "(", "this", ".", "city", ")", ".", "append", "(", "this", ".", "state", ")", ".", "append", "(", "this", ".", "countryIsoCode", ")", ".", "append", "(", "this", ".", "postalCode", ")", ".", "append", "(", "this", ".", "phone", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "Address", "that", "=", "(", "Address", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "firstName", ",", "that", ".", "firstName", ")", ".", "append", "(", "this", ".", "lastName", ",", "that", ".", "lastName", ")", ".", "append", "(", "this", ".", "email", ",", "that", ".", "email", ")", ".", "append", "(", "this", ".", "company", ",", "that", ".", "company", ")", ".", "append", "(", "this", ".", "address1", ",", "that", ".", "address1", ")", ".", "append", "(", "this", ".", "address2", ",", "that", ".", "address2", ")", ".", "append", "(", "this", ".", "city", ",", "that", ".", "city", ")", ".", "append", "(", "this", ".", "state", ",", "that", ".", "state", ")", ".", "append", "(", "this", ".", "countryIsoCode", ",", "that", ".", "countryIsoCode", ")", ".", "append", "(", "this", ".", "postalCode", ",", "that", ".", "postalCode", ")", ".", "append", "(", "this", ".", "phone", ",", "that", ".", "phone", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"firstName\"", ",", "this", ".", "firstName", ")", ".", "append", "(", "\"lastName\"", ",", "this", ".", "lastName", ")", ".", "append", "(", "\"email\"", ",", "this", ".", "email", ")", ".", "append", "(", "\"company\"", ",", "this", ".", "company", ")", ".", "append", "(", "\"address1\"", ",", "this", ".", "address1", ")", ".", "append", "(", "\"address2\"", ",", "this", ".", "address2", ")", ".", "append", "(", "\"city\"", ",", "this", ".", "city", ")", ".", "append", "(", "\"state\"", ",", "this", ".", "state", ")", ".", "append", "(", "\"\"", ",", "this", ".", "countryIsoCode", ")", ".", "append", "(", "\"postalCode\"", ",", "this", ".", "postalCode", ")", ".", "append", "(", "\"phone\"", ",", "this", ".", "phone", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,319
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "class", "Order", "{", "private", "String", "id", ";", "private", "String", "ipAddress", ";", "private", "String", "customerName", ";", "private", "String", "customerEmail", ";", "private", "String", "invoiceNumber", ";", "private", "String", "merchant", ";", "private", "String", "description", ";", "private", "Address", "billingAddress", ";", "private", "Address", "shippingAddress", ";", "private", "Set", "<", "OrderLine", ">", "orderLines", ";", "public", "String", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "String", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "String", "getIpAddress", "(", ")", "{", "return", "ipAddress", ";", "}", "public", "void", "setIpAddress", "(", "String", "ipAddress", ")", "{", "this", ".", "ipAddress", "=", "ipAddress", ";", "}", "public", "String", "getCustomerName", "(", ")", "{", "return", "customerName", ";", "}", "public", "void", "setCustomerName", "(", "String", "customerName", ")", "{", "this", ".", "customerName", "=", "customerName", ";", "}", "public", "String", "getCustomerEmail", "(", ")", "{", "return", "customerEmail", ";", "}", "public", "void", "setCustomerEmail", "(", "String", "customerEmail", ")", "{", "this", ".", "customerEmail", "=", "customerEmail", ";", "}", "public", "String", "getInvoiceNumber", "(", ")", "{", "return", "invoiceNumber", ";", "}", "public", "void", "setInvoiceNumber", "(", "String", "invoiceNumber", ")", "{", "this", ".", "invoiceNumber", "=", "invoiceNumber", ";", "}", "public", "String", "getMerchant", "(", ")", "{", "return", "merchant", ";", "}", "public", "void", "setMerchant", "(", "String", "merchant", ")", "{", "this", ".", "merchant", "=", "merchant", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "description", ";", "}", "public", "void", "setDescription", "(", "String", "description", ")", "{", "this", ".", "description", "=", "description", ";", "}", "public", "Address", "getBillingAddress", "(", ")", "{", "return", "billingAddress", ";", "}", "public", "void", "setBillingAddress", "(", "Address", "billingAddress", ")", "{", "this", ".", "billingAddress", "=", "billingAddress", ";", "}", "public", "Address", "getShippingAddress", "(", ")", "{", "return", "shippingAddress", ";", "}", "public", "void", "setShippingAddress", "(", "Address", "shippingAddress", ")", "{", "this", ".", "shippingAddress", "=", "shippingAddress", ";", "}", "public", "Set", "<", "OrderLine", ">", "getOrderLines", "(", ")", "{", "return", "orderLines", ";", "}", "public", "void", "setOrderLines", "(", "Set", "<", "OrderLine", ">", "orderLines", ")", "{", "this", ".", "orderLines", "=", "orderLines", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "id", ")", ".", "append", "(", "this", ".", "ipAddress", ")", ".", "append", "(", "this", ".", "customerName", ")", ".", "append", "(", "this", ".", "customerEmail", ")", ".", "append", "(", "this", ".", "invoiceNumber", ")", ".", "append", "(", "this", ".", "merchant", ")", ".", "append", "(", "this", ".", "description", ")", ".", "append", "(", "this", ".", "billingAddress", ")", ".", "append", "(", "this", ".", "shippingAddress", ")", ".", "append", "(", "this", ".", "orderLines", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "Order", "that", "=", "(", "Order", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "id", ",", "that", ".", "id", ")", ".", "append", "(", "this", ".", "ipAddress", ",", "that", ".", "ipAddress", ")", ".", "append", "(", "this", ".", "customerName", ",", "that", ".", "customerName", ")", ".", "append", "(", "this", ".", "customerEmail", ",", "that", ".", "customerEmail", ")", ".", "append", "(", "this", ".", "invoiceNumber", ",", "that", ".", "invoiceNumber", ")", ".", "append", "(", "this", ".", "merchant", ",", "that", ".", "merchant", ")", ".", "append", "(", "this", ".", "description", ",", "that", ".", "description", ")", ".", "append", "(", "this", ".", "billingAddress", ",", "that", ".", "billingAddress", ")", ".", "append", "(", "this", ".", "shippingAddress", ",", "that", ".", "shippingAddress", ")", ".", "append", "(", "this", ".", "orderLines", ",", "that", ".", "orderLines", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"id\"", ",", "this", ".", "id", ")", ".", "append", "(", "\"ipAddress\"", ",", "this", ".", "ipAddress", ")", ".", "append", "(", "\"customerName\"", ",", "this", ".", "customerName", ")", ".", "append", "(", "\"\"", ",", "this", ".", "customerEmail", ")", ".", "append", "(", "\"\"", ",", "this", ".", "invoiceNumber", ")", ".", "append", "(", "\"merchant\"", ",", "this", ".", "merchant", ")", ".", "append", "(", "\"description\"", ",", "this", ".", "description", ")", ".", "append", "(", "\"\"", ",", "this", ".", "billingAddress", ")", ".", "append", "(", "\"\"", ",", "this", ".", "shippingAddress", ")", ".", "append", "(", "\"orderLines\"", ",", "this", ".", "orderLines", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,320
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "import", "static", "com", ".", "google", ".", "common", ".", "base", ".", "Preconditions", ".", "checkArgument", ";", "public", "class", "CreditCard", "{", "public", "enum", "Type", "{", "VISA", ",", "MASTER_CARD", ",", "AMERICAN_EXPRESS", ",", "DISCOVER", ",", "JCP", ",", "CARTE_BLANCHE", ",", "DINERS_CLUB", ",", "EN_ROUTE", ",", "LASER", ",", "MAESTRO", ",", "SOLO", ",", "SWITCH", "}", "private", "String", "firstName", ";", "private", "String", "lastName", ";", "private", "String", "number", ";", "private", "String", "month", ";", "private", "String", "year", ";", "private", "Type", "type", ";", "private", "String", "securityCode", ";", "public", "String", "getFirstName", "(", ")", "{", "return", "firstName", ";", "}", "public", "void", "setFirstName", "(", "String", "firstName", ")", "{", "this", ".", "firstName", "=", "firstName", ";", "}", "public", "String", "getLastName", "(", ")", "{", "return", "lastName", ";", "}", "public", "void", "setLastName", "(", "String", "lastName", ")", "{", "this", ".", "lastName", "=", "lastName", ";", "}", "public", "String", "getNumber", "(", ")", "{", "return", "number", ";", "}", "public", "void", "setNumber", "(", "String", "number", ")", "{", "this", ".", "number", "=", "number", ";", "}", "public", "String", "getMonth", "(", ")", "{", "return", "month", ";", "}", "public", "void", "setMonth", "(", "String", "month", ")", "{", "checkArgument", "(", "Integer", ".", "valueOf", "(", "month", ")", ">=", "1", "&&", "Integer", ".", "valueOf", "(", "month", ")", "<=", "12", ",", "\"\"", ")", ";", "this", ".", "month", "=", "month", ";", "}", "public", "String", "getYear", "(", ")", "{", "return", "year", ";", "}", "public", "void", "setYear", "(", "String", "year", ")", "{", "checkArgument", "(", "Integer", ".", "valueOf", "(", "year", ")", ">=", "1950", "&&", "Integer", ".", "valueOf", "(", "year", ")", "<=", "3000", ",", "\"\"", ")", ";", "this", ".", "year", "=", "year", ";", "}", "public", "Type", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "void", "setType", "(", "Type", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "public", "String", "getSecurityCode", "(", ")", "{", "return", "securityCode", ";", "}", "public", "void", "setSecurityCode", "(", "String", "securityCode", ")", "{", "checkArgument", "(", "securityCode", ".", "length", "(", ")", ">=", "2", "&&", "securityCode", ".", "length", "(", ")", "<=", "4", ",", "\"\"", ")", ";", "this", ".", "securityCode", "=", "securityCode", ";", "}", "public", "boolean", "isValid", "(", ")", "{", "return", "false", ";", "}", "public", "boolean", "isExpired", "(", ")", "{", "return", "true", ";", "}", "public", "String", "getDisplayNumber", "(", ")", "{", "return", "\"\"", ";", "}", "public", "String", "getLastDigits", "(", ")", "{", "return", "\"\"", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "firstName", ")", ".", "append", "(", "this", ".", "lastName", ")", ".", "append", "(", "this", ".", "number", ")", ".", "append", "(", "this", ".", "month", ")", ".", "append", "(", "this", ".", "year", ")", ".", "append", "(", "this", ".", "type", ")", ".", "append", "(", "this", ".", "securityCode", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "CreditCard", "that", "=", "(", "CreditCard", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "firstName", ",", "that", ".", "firstName", ")", ".", "append", "(", "this", ".", "lastName", ",", "that", ".", "lastName", ")", ".", "append", "(", "this", ".", "number", ",", "that", ".", "number", ")", ".", "append", "(", "this", ".", "month", ",", "that", ".", "month", ")", ".", "append", "(", "this", ".", "year", ",", "that", ".", "year", ")", ".", "append", "(", "this", ".", "type", ",", "that", ".", "type", ")", ".", "append", "(", "this", ".", "securityCode", ",", "that", ".", "securityCode", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"firstName\"", ",", "this", ".", "firstName", ")", ".", "append", "(", "\"lastName\"", ",", "this", ".", "lastName", ")", ".", "append", "(", "\"number\"", ",", "this", ".", "number", ")", ".", "append", "(", "\"month\"", ",", "this", ".", "month", ")", ".", "append", "(", "\"year\"", ",", "this", ".", "year", ")", ".", "append", "(", "\"type\"", ",", "this", ".", "type", ")", ".", "append", "(", "\"securityCode\"", ",", "this", ".", "securityCode", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,321
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang", ".", "builder", ".", "ToStringBuilder", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "util", ".", "Currency", ";", "import", "java", ".", "util", ".", "Locale", ";", "public", "class", "Money", "{", "private", "BigDecimal", "amount", ";", "private", "Currency", "currency", ";", "public", "Money", "(", "BigDecimal", "amount", ",", "Currency", "currency", ")", "{", "this", ".", "amount", "=", "amount", ";", "this", ".", "currency", "=", "currency", ";", "}", "public", "Money", "(", "String", "amount", ",", "Locale", "locale", ")", "{", "this", "(", "new", "BigDecimal", "(", "amount", ")", ",", "Currency", ".", "getInstance", "(", "locale", ")", ")", ";", "}", "public", "BigDecimal", "getAmount", "(", ")", "{", "return", "amount", ";", "}", "public", "Currency", "getCurrency", "(", ")", "{", "return", "currency", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "this", ".", "amount", ")", ".", "append", "(", "this", ".", "currency", ")", ".", "toHashCode", "(", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "this", "==", "o", ")", "{", "return", "true", ";", "}", "if", "(", "o", "==", "null", "||", "getClass", "(", ")", "!=", "o", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "Money", "that", "=", "(", "Money", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "amount", ",", "that", ".", "amount", ")", ".", "append", "(", "this", ".", "currency", ",", "that", ".", "currency", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "new", "ToStringBuilder", "(", "this", ")", ".", "append", "(", "\"amount\"", ",", "this", ".", "amount", ")", ".", "append", "(", "\"currency\"", ",", "this", ".", "currency", ")", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,322
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "public", "class", "CreditCardBuilder", "extends", "AbstractBaseModelBuilder", "<", "CreditCard", ">", "{", "public", "CreditCardBuilder", "(", ")", "{", "super", "(", "CreditCard", ".", "class", ")", ";", "}", "public", "CreditCardBuilder", "withFirstName", "(", "String", "firstName", ")", "{", "values", ".", "put", "(", "\"firstName\"", ",", "firstName", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withLastName", "(", "String", "lastName", ")", "{", "values", ".", "put", "(", "\"lastName\"", ",", "lastName", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withNumber", "(", "String", "number", ")", "{", "values", ".", "put", "(", "\"number\"", ",", "number", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withMonth", "(", "String", "month", ")", "{", "values", ".", "put", "(", "\"month\"", ",", "month", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withYear", "(", "String", "year", ")", "{", "values", ".", "put", "(", "\"year\"", ",", "year", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withType", "(", "CreditCard", ".", "Type", "type", ")", "{", "values", ".", "put", "(", "\"type\"", ",", "type", ")", ";", "return", "this", ";", "}", "public", "CreditCardBuilder", "withSecurityCode", "(", "String", "securityCode", ")", "{", "values", ".", "put", "(", "\"securityCode\"", ",", "securityCode", ")", ";", "return", "this", ";", "}", "}", "</s>" ]
8,323
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "util", ".", "Currency", ";", "import", "java", ".", "util", ".", "Locale", ";", "public", "class", "MoneyBuilder", "extends", "AbstractBaseModelBuilder", "<", "Money", ">", "{", "public", "MoneyBuilder", "(", ")", "{", "super", "(", "Money", ".", "class", ")", ";", "}", "public", "MoneyBuilder", "withAmount", "(", "String", "amount", ")", "{", "values", ".", "put", "(", "\"amount\"", ",", "new", "BigDecimal", "(", "amount", ")", ")", ";", "return", "this", ";", "}", "public", "MoneyBuilder", "withAmount", "(", "BigDecimal", "amount", ")", "{", "values", ".", "put", "(", "\"amount\"", ",", "amount", ")", ";", "return", "this", ";", "}", "public", "MoneyBuilder", "withCurrency", "(", "Currency", "currency", ")", "{", "values", ".", "put", "(", "\"currency\"", ",", "currency", ")", ";", "return", "this", ";", "}", "public", "MoneyBuilder", "withCurrency", "(", "Locale", "locale", ")", "{", "values", ".", "put", "(", "\"currency\"", ",", "Currency", ".", "getInstance", "(", "locale", ")", ")", ";", "return", "this", ";", "}", "@", "Override", "public", "Money", "build", "(", ")", "{", "BigDecimal", "amount", ";", "Object", "amountObj", "=", "values", ".", "get", "(", "\"amount\"", ")", ";", "if", "(", "amountObj", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "amountObj", "instanceof", "String", ")", "{", "amount", "=", "new", "BigDecimal", "(", "(", "String", ")", "amountObj", ")", ";", "}", "else", "{", "amount", "=", "(", "BigDecimal", ")", "amountObj", ";", "}", "Currency", "currency", ";", "Object", "currencyObj", "=", "values", ".", "get", "(", "\"currency\"", ")", ";", "if", "(", "currencyObj", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "currencyObj", "instanceof", "Locale", ")", "{", "currency", "=", "Currency", ".", "getInstance", "(", "(", "Locale", ")", "currencyObj", ")", ";", "}", "else", "{", "currency", "=", "(", "Currency", ")", "currencyObj", ";", "}", "return", "new", "Money", "(", "amount", ",", "currency", ")", ";", "}", "}", "</s>" ]
8,324
[ "<s>", "package", "org", ".", "payments4j", ".", "model", ";", "import", "org", ".", "apache", ".", "commons", ".", "beanutils", ".", "WrapDynaBean", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "AbstractBaseModelBuilder", "<", "T", ">", "{", "protected", "Map", "<", "String", ",", "Object", ">", "values", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "protected", "Class", "<", "T", ">", "clazz", ";", "public", "AbstractBaseModelBuilder", "(", "Class", "<", "T", ">", "clazz", ")", "{", "this", ".", "clazz", "=", "clazz", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "build", "(", ")", "{", "try", "{", "WrapDynaBean", "bean", "=", "new", "WrapDynaBean", "(", "clazz", ".", "newInstance", "(", ")", ")", ";", "for", "(", "String", "key", ":", "values", ".", "keySet", "(", ")", ")", "{", "bean", ".", "set", "(", "key", ",", "values", ".", "get", "(", "key", ")", ")", ";", "}", "values", ".", "clear", "(", ")", ";", "return", "(", "T", ")", "bean", ".", "getInstance", "(", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "}", "</s>" ]
8,325
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "authorizenet", ";", "import", "org", ".", "junit", ".", "Ignore", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "payments4j", ".", "core", ".", "PaymentGateway", ";", "import", "org", ".", "payments4j", ".", "test", ".", "spi", ".", "AbstractBasePaymentGatewayIntegrationTest", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "AuthorizeNetPaymentGatewayIntegrationTest", "extends", "AbstractBasePaymentGatewayIntegrationTest", "{", "protected", "PaymentGateway", "buildGateway", "(", ")", "{", "PaymentGateway", "gateway", "=", "new", "AuthorizeNetPaymentGateway", "(", "credentials", ".", "getProperty", "(", "\"\"", ")", ",", "credentials", ".", "getProperty", "(", "\"\"", ")", ")", ";", "gateway", ".", "setTest", "(", "true", ")", ";", "return", "gateway", ";", "}", "@", "Override", "@", "Test", "@", "Ignore", "(", "\"\"", "+", "\"\"", ")", "public", "void", "testAuthRevert", "(", ")", "throws", "Exception", "{", "super", ".", "testAuthRevert", "(", ")", ";", "}", "@", "Override", "@", "Test", "@", "Ignore", "(", "\"\"", "+", "\"\"", ")", "public", "void", "testAuthCaptureCredit", "(", ")", "throws", "Exception", "{", "super", ".", "testAuthCaptureCredit", "(", ")", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getCreditOptions", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"\"", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"11\"", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"2013\"", ")", ";", "return", "options", ";", "}", "}", "</s>" ]
8,326
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "authorizenet", ";", "import", "net", ".", "authorize", ".", "Merchant", ";", "import", "net", ".", "authorize", ".", "ResponseField", ";", "import", "net", ".", "authorize", ".", "Result", ";", "import", "net", ".", "authorize", ".", "TransactionType", ";", "import", "net", ".", "authorize", ".", "aim", ".", "Transaction", ";", "import", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "ArgumentCaptor", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "mockito", ".", "runners", ".", "MockitoJUnitRunner", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCardBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "MoneyBuilder", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "*", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "*", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "@", "RunWith", "(", "MockitoJUnitRunner", ".", "class", ")", "public", "class", "AuthorizeNetPaymentGatewayTest", "{", "private", "static", "final", "String", "LOGIN_ID", "=", "\"LOGIN_ID\"", ";", "private", "static", "final", "String", "TRANSACTION_KEY", "=", "\"\"", ";", "@", "Mock", "private", "Merchant", "mockMerchant", ";", "private", "AuthorizeNetPaymentGateway_ForTest", "gateway", ";", "private", "Money", "money", ";", "private", "org", ".", "payments4j", ".", "model", ".", "CreditCard", "creditCard", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "gateway", "=", "new", "AuthorizeNetPaymentGateway_ForTest", "(", "LOGIN_ID", ",", "TRANSACTION_KEY", ")", ";", "money", "=", "new", "MoneyBuilder", "(", ")", ".", "withAmount", "(", "\"10\"", ")", ".", "withCurrency", "(", "Locale", ".", "US", ")", ".", "build", "(", ")", ";", "creditCard", "=", "new", "CreditCardBuilder", "(", ")", ".", "withNumber", "(", "\"\"", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withMonth", "(", "\"01\"", ")", ".", "withYear", "(", "\"2012\"", ")", ".", "withType", "(", "MASTER_CARD", ")", ".", "withSecurityCode", "(", "\"123\"", ")", ".", "build", "(", ")", ";", "}", "@", "Test", "public", "void", "testPurchase", "(", ")", "throws", "Exception", "{", "Transaction", "mockTransaction", "=", "setUpTransactionMock", "(", "AUTH_CAPTURE", ",", "new", "BigDecimal", "(", "\"10\"", ")", ")", ";", "TransactionResponse", "transactionResponse", "=", "gateway", ".", "purchase", "(", "money", ",", "creditCard", ",", "null", ")", ";", "verifyTransactionResult", "(", "mockTransaction", ",", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testAuthorize", "(", ")", "throws", "Exception", "{", "Transaction", "mockTransaction", "=", "setUpTransactionMock", "(", "AUTH_ONLY", ",", "new", "BigDecimal", "(", "\"10\"", ")", ")", ";", "TransactionResponse", "transactionResponse", "=", "gateway", ".", "authorize", "(", "money", ",", "creditCard", ",", "null", ")", ";", "verifyTransactionResult", "(", "mockTransaction", ",", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testCapture", "(", ")", "throws", "Exception", "{", "Transaction", "mockTransaction", "=", "setUpTransactionMock", "(", "PRIOR_AUTH_CAPTURE", ",", "new", "BigDecimal", "(", "\"10\"", ")", ")", ";", "TransactionResponse", "transactionResponse", "=", "gateway", ".", "capture", "(", "money", ",", "\"SOME_AUTH_ID\"", ",", "null", ")", ";", "verifyTransactionResultWithTransactionId", "(", "mockTransaction", ",", "transactionResponse", ")", ";", "}", "@", "Test", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "testRevert", "(", ")", "throws", "Exception", "{", "Transaction", "mockTransaction", "=", "setUpTransactionMock", "(", "VOID", ",", "null", ")", ";", "TransactionResponse", "transactionResponse", "=", "gateway", ".", "revert", "(", "\"SOME_AUTH_ID\"", ",", "null", ")", ";", "verifyTransactionResultWithTransactionId", "(", "mockTransaction", ",", "transactionResponse", ")", ";", "}", "@", "Test", "public", "void", "testCredit", "(", ")", "throws", "Exception", "{", "Transaction", "mockTransaction", "=", "setUpTransactionMock", "(", "CREDIT", ",", "new", "BigDecimal", "(", "\"10\"", ")", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "optionals", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "optionals", ".", "put", "(", "\"\"", ",", "\"\"", ")", ";", "optionals", ".", "put", "(", "\"\"", ",", "\"11\"", ")", ";", "optionals", ".", "put", "(", "\"\"", ",", "\"2010\"", ")", ";", "TransactionResponse", "transactionResponse", "=", "gateway", ".", "credit", "(", "money", ",", "\"SOME_AUTH_ID\"", ",", "optionals", ")", ";", "assertThat", "(", "gateway", ".", "buildMerchant_wasCalled", ")", ".", "isTrue", "(", ")", ";", "verify", "(", "mockTransaction", ")", ".", "setTransactionId", "(", "\"SOME_AUTH_ID\"", ")", ";", "CreditCard", "value", "=", "captureCreditCard", "(", "mockTransaction", ")", ";", "assertThat", "(", "value", ".", "getCreditCardNumber", "(", ")", ")", ".", "isEqualTo", "(", "\"\"", ")", ";", "assertThat", "(", "value", ".", "getExpirationMonth", "(", ")", ")", ".", "isEqualTo", "(", "\"11\"", ")", ";", "assertThat", "(", "value", ".", "getExpirationYear", "(", ")", ")", ".", "isEqualTo", "(", "\"2010\"", ")", ";", "verifyTransactionResponse", "(", "transactionResponse", ",", "\"01\"", ",", "\"some", "reason\"", ",", "\"01\"", ",", "\"2222\"", ")", ";", "}", "private", "void", "verifyTransactionResultWithTransactionId", "(", "Transaction", "mockTransaction", ",", "TransactionResponse", "transactionResponse", ")", "{", "assertThat", "(", "gateway", ".", "buildMerchant_wasCalled", ")", ".", "isTrue", "(", ")", ";", "verify", "(", "mockTransaction", ")", ".", "setTransactionId", "(", "\"SOME_AUTH_ID\"", ")", ";", "verifyTransactionResponse", "(", "transactionResponse", ",", "\"01\"", ",", "\"some", "reason\"", ",", "\"01\"", ",", "\"2222\"", ")", ";", "}", "private", "void", "verifyTransactionResult", "(", "Transaction", "mockTransaction", ",", "TransactionResponse", "transactionResponse", ")", "{", "assertThat", "(", "gateway", ".", "buildMerchant_wasCalled", ")", ".", "isTrue", "(", ")", ";", "CreditCard", "value", "=", "captureCreditCard", "(", "mockTransaction", ")", ";", "assertThatCreditCardEquals", "(", "value", ",", "creditCard", ")", ";", "verifyTransactionResponse", "(", "transactionResponse", ",", "\"01\"", ",", "\"some", "reason\"", ",", "\"01\"", ",", "\"2222\"", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "Transaction", "setUpTransactionMock", "(", "TransactionType", "transactionType", ",", "BigDecimal", "amount", ")", "{", "Transaction", "mockTransaction", "=", "mock", "(", "Transaction", ".", "class", ")", ";", "when", "(", "mockMerchant", ".", "createAIMTransaction", "(", "transactionType", ",", "amount", ")", ")", ".", "thenReturn", "(", "mockTransaction", ")", ";", "Result", "<", "Transaction", ">", "mockResult", "=", "buildMockResult", "(", "\"01\"", ",", "\"some", "reason\"", ",", "\"01\"", ",", "\"2222\"", ")", ";", "when", "(", "mockMerchant", ".", "postTransaction", "(", "mockTransaction", ")", ")", ".", "thenReturn", "(", "(", "Result", ")", "mockResult", ")", ";", "return", "mockTransaction", ";", "}", "private", "CreditCard", "captureCreditCard", "(", "Transaction", "mockTransaction", ")", "{", "ArgumentCaptor", "<", "CreditCard", ">", "captor", "=", "ArgumentCaptor", ".", "forClass", "(", "CreditCard", ".", "class", ")", ";", "verify", "(", "mockTransaction", ")", ".", "setCreditCard", "(", "captor", ".", "capture", "(", ")", ")", ";", "return", "captor", ".", "getValue", "(", ")", ";", "}", "private", "void", "verifyTransactionResponse", "(", "TransactionResponse", "transactionResponse", ",", "String", "code", ",", "String", "message", ",", "String", "reasonCode", ",", "String", "authId", ")", "{", "assertThat", "(", "transactionResponse", ".", "getCode", "(", ")", ")", ".", "isEqualTo", "(", "Long", ".", "valueOf", "(", "code", ")", ")", ";", "assertThat", "(", "transactionResponse", ".", "getMessage", "(", ")", ")", ".", "isEqualTo", "(", "message", ")", ";", "assertThat", "(", "transactionResponse", ".", "getReasonCode", "(", ")", ")", ".", "isEqualTo", "(", "Long", ".", "valueOf", "(", "reasonCode", ")", ")", ";", "assertThat", "(", "transactionResponse", ".", "getAuthorizationId", "(", ")", ")", ".", "isEqualTo", "(", "authId", ")", ";", "assertThat", "(", "transactionResponse", ".", "isSuccessful", "(", ")", ")", ".", "isTrue", "(", ")", ";", "}", "private", "Result", "<", "Transaction", ">", "buildMockResult", "(", "String", "code", ",", "String", "message", ",", "String", "reasonCode", ",", "String", "authId", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Result", "<", "Transaction", ">", "mockResult", "=", "mock", "(", "Result", ".", "class", ")", ";", "Transaction", "mockResultTransaction", "=", "mock", "(", "Transaction", ".", "class", ")", ";", "Map", "<", "ResponseField", ",", "String", ">", "responseMap", "=", "new", "HashMap", "<", "ResponseField", ",", "String", ">", "(", ")", ";", "responseMap", ".", "put", "(", "ResponseField", ".", "RESPONSE_CODE", ",", "code", ")", ";", "responseMap", ".", "put", "(", "ResponseField", ".", "RESPONSE_REASON_TEXT", ",", "message", ")", ";", "responseMap", ".", "put", "(", "ResponseField", ".", "RESPONSE_REASON_CODE", ",", "reasonCode", ")", ";", "responseMap", ".", "put", "(", "ResponseField", ".", "AUTHORIZATION_CODE", ",", "authId", ")", ";", "when", "(", "mockResultTransaction", ".", "getResponseMap", "(", ")", ")", ".", "thenReturn", "(", "responseMap", ")", ";", "when", "(", "mockResult", ".", "getTarget", "(", ")", ")", ".", "thenReturn", "(", "mockResultTransaction", ")", ";", "return", "mockResult", ";", "}", "private", "void", "assertThatCreditCardEquals", "(", "CreditCard", "value", ",", "org", ".", "payments4j", ".", "model", ".", "CreditCard", "creditCard", ")", "{", "assertThat", "(", "value", ".", "getCreditCardNumber", "(", ")", ")", ".", "isEqualTo", "(", "creditCard", ".", "getNumber", "(", ")", ")", ";", "assertThat", "(", "value", ".", "getExpirationYear", "(", ")", ")", ".", "isEqualTo", "(", "creditCard", ".", "getYear", "(", ")", ")", ";", "assertThat", "(", "value", ".", "getExpirationMonth", "(", ")", ")", ".", "isEqualTo", "(", "creditCard", ".", "getMonth", "(", ")", ")", ";", "assertThat", "(", "value", ".", "getCardCodeVerification", "(", ")", ")", ".", "isEqualTo", "(", "creditCard", ".", "getSecurityCode", "(", ")", ")", ";", "assertThat", "(", "value", ".", "getCardType", "(", ")", ".", "name", "(", ")", ")", ".", "isEqualToIgnoringCase", "(", "creditCard", ".", "getType", "(", ")", ".", "name", "(", ")", ")", ";", "}", "private", "class", "AuthorizeNetPaymentGateway_ForTest", "extends", "AuthorizeNetPaymentGateway", "{", "private", "boolean", "buildMerchant_wasCalled", ";", "public", "AuthorizeNetPaymentGateway_ForTest", "(", "String", "apiLoginId", ",", "String", "transactionKey", ")", "{", "super", "(", "apiLoginId", ",", "transactionKey", ")", ";", "}", "@", "Override", "Merchant", "buildMerchant", "(", "String", "apiLoginId", ",", "String", "transactionKey", ")", "{", "assertThat", "(", "apiLoginId", ")", ".", "isEqualTo", "(", "LOGIN_ID", ")", ";", "assertThat", "(", "transactionKey", ")", ".", "isEqualTo", "(", "transactionKey", ")", ";", "buildMerchant_wasCalled", "=", "true", ";", "return", "mockMerchant", ";", "}", "}", "}", "</s>" ]
8,327
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "authorizenet", ";", "import", "net", ".", "authorize", ".", "Environment", ";", "import", "net", ".", "authorize", ".", "Merchant", ";", "import", "net", ".", "authorize", ".", "ResponseCode", ";", "import", "net", ".", "authorize", ".", "ResponseField", ";", "import", "net", ".", "authorize", ".", "Result", ";", "import", "net", ".", "authorize", ".", "TransactionType", ";", "import", "net", ".", "authorize", ".", "aim", ".", "Transaction", ";", "import", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CardType", ";", "import", "org", ".", "payments4j", ".", "core", ".", "AbstractPaymentGateway", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "AUTH_CAPTURE", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "AUTH_ONLY", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "CREDIT", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "PRIOR_AUTH_CAPTURE", ";", "import", "static", "net", ".", "authorize", ".", "TransactionType", ".", "VOID", ";", "import", "static", "org", ".", "payments4j", ".", "common", ".", "ParamUtil", ".", "requireOption", ";", "public", "class", "AuthorizeNetPaymentGateway", "extends", "AbstractPaymentGateway", "{", "private", "String", "apiLoginId", ";", "private", "String", "transactionKey", ";", "private", "boolean", "test", ";", "public", "AuthorizeNetPaymentGateway", "(", "String", "apiLoginId", ",", "String", "transactionKey", ")", "{", "this", ".", "apiLoginId", "=", "apiLoginId", ";", "this", ".", "transactionKey", "=", "transactionKey", ";", "}", "@", "Override", "public", "TransactionResponse", "doPurchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "specificOptions", ")", "{", "return", "executeTransactionWithCreditCard", "(", "AUTH_CAPTURE", ",", "creditCard", ",", "money", ".", "getAmount", "(", ")", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doAuthorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "return", "executeTransactionWithCreditCard", "(", "AUTH_ONLY", ",", "creditCard", ",", "money", ".", "getAmount", "(", ")", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCapture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "return", "executeTransactionWithTransactionId", "(", "PRIOR_AUTH_CAPTURE", ",", "authorizationId", ",", "money", ".", "getAmount", "(", ")", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRevert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "return", "executeTransactionWithTransactionId", "(", "VOID", ",", "transactionId", ",", "null", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCredit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "requireOption", "(", "options", ",", "\"\"", ")", ";", "requireOption", "(", "options", ",", "\"\"", ")", ";", "Merchant", "merchant", "=", "buildMerchant", "(", "apiLoginId", ",", "transactionKey", ")", ";", "Transaction", "transaction", "=", "merchant", ".", "createAIMTransaction", "(", "CREDIT", ",", "money", ".", "getAmount", "(", ")", ")", ";", "transaction", ".", "setTransactionId", "(", "transactionId", ")", ";", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", "creditCard", "=", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", ".", "createCreditCard", "(", ")", ";", "creditCard", ".", "setCreditCardNumber", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "creditCard", ".", "setExpirationMonth", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "creditCard", ".", "setExpirationYear", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "transaction", ".", "setCreditCard", "(", "creditCard", ")", ";", "Result", "<", "?", ">", "result", "=", "merchant", ".", "postTransaction", "(", "transaction", ")", ";", "return", "convert", "(", "result", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRecurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doStoreCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doEvictCreditCard", "(", "String", "creditCardId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "boolean", "supportsPurchase", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsAuthorize", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCapture", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsRevert", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCredit", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsStoreCreditCard", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "boolean", "supportsEvictCreditCard", "(", ")", "{", "return", "false", ";", "}", "private", "TransactionResponse", "executeTransactionWithTransactionId", "(", "TransactionType", "transactionType", ",", "String", "authorizationId", ",", "BigDecimal", "amount", ")", "{", "Merchant", "merchant", "=", "buildMerchant", "(", "apiLoginId", ",", "transactionKey", ")", ";", "Transaction", "transaction", "=", "merchant", ".", "createAIMTransaction", "(", "transactionType", ",", "amount", ")", ";", "transaction", ".", "setTransactionId", "(", "authorizationId", ")", ";", "Result", "<", "?", ">", "result", "=", "merchant", ".", "postTransaction", "(", "transaction", ")", ";", "return", "convert", "(", "result", ")", ";", "}", "private", "TransactionResponse", "executeTransactionWithCreditCard", "(", "TransactionType", "transactionType", ",", "CreditCard", "creditCard", ",", "BigDecimal", "amount", ")", "{", "Merchant", "merchant", "=", "buildMerchant", "(", "apiLoginId", ",", "transactionKey", ")", ";", "Transaction", "transaction", "=", "merchant", ".", "createAIMTransaction", "(", "transactionType", ",", "amount", ")", ";", "transaction", ".", "setCreditCard", "(", "convert", "(", "creditCard", ")", ")", ";", "Result", "<", "?", ">", "result", "=", "merchant", ".", "postTransaction", "(", "transaction", ")", ";", "return", "convert", "(", "result", ")", ";", "}", "@", "Override", "public", "void", "setTest", "(", "boolean", "test", ")", "{", "this", ".", "test", "=", "test", ";", "}", "private", "TransactionResponse", "convert", "(", "Result", "<", "?", ">", "result", ")", "{", "TransactionResponse", "response", "=", "new", "TransactionResponse", "(", ")", ";", "Transaction", "transaction", "=", "(", "Transaction", ")", "result", ".", "getTarget", "(", ")", ";", "response", ".", "setCode", "(", "getLongResponseField", "(", "transaction", ",", "ResponseField", ".", "RESPONSE_CODE", ")", ")", ";", "response", ".", "setReasonCode", "(", "getLongResponseField", "(", "transaction", ",", "ResponseField", ".", "RESPONSE_REASON_CODE", ")", ")", ";", "response", ".", "setMessage", "(", "getStringResponseField", "(", "transaction", ",", "ResponseField", ".", "RESPONSE_REASON_TEXT", ")", ")", ";", "response", ".", "setAuthorizationId", "(", "getStringResponseField", "(", "transaction", ",", "ResponseField", ".", "AUTHORIZATION_CODE", ")", ")", ";", "response", ".", "setSuccessful", "(", "ResponseCode", ".", "APPROVED", "==", "ResponseCode", ".", "findByResponseCode", "(", "(", "int", ")", "response", ".", "getCode", "(", ")", ")", ")", ";", "return", "response", ";", "}", "private", "Long", "getLongResponseField", "(", "Transaction", "transaction", ",", "ResponseField", "field", ")", "{", "return", "Long", ".", "valueOf", "(", "getStringResponseField", "(", "transaction", ",", "field", ")", ")", ";", "}", "private", "String", "getStringResponseField", "(", "Transaction", "transaction", ",", "ResponseField", "field", ")", "{", "return", "transaction", ".", "getResponseMap", "(", ")", ".", "get", "(", "field", ")", ";", "}", "private", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", "convert", "(", "CreditCard", "creditCard", ")", "{", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", "converted", "=", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", ".", "createCreditCard", "(", ")", ";", "converted", ".", "setCreditCardNumber", "(", "creditCard", ".", "getNumber", "(", ")", ")", ";", "converted", ".", "setExpirationMonth", "(", "creditCard", ".", "getMonth", "(", ")", ")", ";", "converted", ".", "setExpirationYear", "(", "creditCard", ".", "getYear", "(", ")", ")", ";", "converted", ".", "setCardCodeVerification", "(", "creditCard", ".", "getSecurityCode", "(", ")", ")", ";", "converted", ".", "setCardType", "(", "CardType", ".", "valueOf", "(", "creditCard", ".", "getType", "(", ")", ".", "name", "(", ")", ")", ")", ";", "return", "converted", ";", "}", "Merchant", "buildMerchant", "(", "String", "apiLoginId", ",", "String", "transactionKey", ")", "{", "Environment", "environment", "=", "Environment", ".", "PRODUCTION", ";", "if", "(", "test", ")", "{", "environment", "=", "Environment", ".", "SANDBOX", ";", "}", "return", "Merchant", ".", "createMerchant", "(", "environment", ",", "apiLoginId", ",", "transactionKey", ")", ";", "}", "}", "</s>" ]
8,328
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data", ".", "transactionprocessor", ".", "ITransactionProcessor", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data", ".", "transactionprocessor", ".", "TransactionProcessor", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "PurchaseTotals", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "ReplyMessage", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "RequestMessage", ";", "import", "com", ".", "google", ".", "common", ".", "annotations", ".", "VisibleForTesting", ";", "import", "org", ".", "apache", ".", "cxf", ".", "endpoint", ".", "Endpoint", ";", "import", "org", ".", "apache", ".", "cxf", ".", "frontend", ".", "ClientProxy", ";", "import", "org", ".", "apache", ".", "cxf", ".", "ws", ".", "security", ".", "wss4j", ".", "WSS4JOutInterceptor", ";", "import", "org", ".", "payments4j", ".", "core", ".", "AbstractPaymentGateway", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Order", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "converter", ".", "AddressConverter", ";", "import", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "converter", ".", "CreditCardConverter", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "java", ".", "lang", ".", "String", ".", "format", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSConstants", ".", "PW_TEXT", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "ACTION", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "PASSWORD_TYPE", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "PW_CALLBACK_REF", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "USER", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "USERNAME_TOKEN", ";", "import", "static", "org", ".", "payments4j", ".", "common", ".", "ParamUtil", ".", "requireOption", ";", "import", "static", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "TransactionType", ".", "AUTHORIZE", ";", "import", "static", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "TransactionType", ".", "CAPTURE", ";", "import", "static", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "TransactionType", ".", "CREDIT", ";", "import", "static", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "TransactionType", ".", "PURCHASE", ";", "import", "static", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "TransactionType", ".", "REVERT", ";", "public", "class", "CybersourcePaymentGateway", "extends", "AbstractPaymentGateway", "{", "public", "static", "final", "URL", "HOSTNAME", "=", "initUrl", "(", "\"\"", ")", ";", "public", "static", "final", "URL", "TEST_HOSTNAME", "=", "initUrl", "(", "\"\"", ")", ";", "private", "boolean", "test", ";", "private", "String", "username", ";", "private", "String", "transactionKey", ";", "public", "CybersourcePaymentGateway", "(", "String", "username", ",", "String", "transactionKey", ")", "{", "this", ".", "username", "=", "username", ";", "this", ".", "transactionKey", "=", "transactionKey", ";", "}", "@", "Override", "public", "TransactionResponse", "doPurchase", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "requireOption", "(", "options", ",", "\"order\"", ")", ";", "ITransactionProcessor", "processor", "=", "buildTransactionProcessor", "(", ")", ";", "Order", "order", "=", "(", "Order", ")", "options", ".", "get", "(", "\"order\"", ")", ";", "RequestMessage", "request", "=", "buildRequestMessage", "(", "PURCHASE", ",", "money", ",", "creditCard", ",", "order", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "return", "executeTransaction", "(", "processor", ",", "request", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doAuthorize", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "requireOption", "(", "options", ",", "\"order\"", ")", ";", "ITransactionProcessor", "processor", "=", "buildTransactionProcessor", "(", ")", ";", "Order", "order", "=", "(", "Order", ")", "options", ".", "get", "(", "\"order\"", ")", ";", "RequestMessage", "request", "=", "buildRequestMessage", "(", "AUTHORIZE", ",", "money", ",", "creditCard", ",", "order", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "return", "executeTransaction", "(", "processor", ",", "request", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCapture", "(", "Money", "money", ",", "String", "authorizationId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "ITransactionProcessor", "processor", "=", "buildTransactionProcessor", "(", ")", ";", "RequestMessage", "request", "=", "buildRequestMessage", "(", "CAPTURE", ",", "money", ",", "null", ",", "null", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "request", ".", "getCcCaptureService", "(", ")", ".", "setAuthRequestID", "(", "authorizationId", ")", ";", "return", "executeTransaction", "(", "processor", ",", "request", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRevert", "(", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "requireOption", "(", "options", ",", "\"money\"", ")", ";", "ITransactionProcessor", "processor", "=", "buildTransactionProcessor", "(", ")", ";", "RequestMessage", "request", "=", "buildRequestMessage", "(", "REVERT", ",", "null", ",", "null", ",", "null", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "request", ".", "setPurchaseTotals", "(", "buildPurchaseTotals", "(", "(", "Money", ")", "options", ".", "get", "(", "\"money\"", ")", ")", ")", ";", "request", ".", "getCcAuthReversalService", "(", ")", ".", "setAuthRequestID", "(", "transactionId", ")", ";", "return", "executeTransaction", "(", "processor", ",", "request", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doCredit", "(", "Money", "money", ",", "String", "transactionId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "requireOption", "(", "options", ",", "\"\"", ")", ";", "ITransactionProcessor", "processor", "=", "buildTransactionProcessor", "(", ")", ";", "RequestMessage", "request", "=", "buildRequestMessage", "(", "CREDIT", ",", "money", ",", "null", ",", "null", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "(", "String", ")", "options", ".", "get", "(", "\"\"", ")", ")", ";", "request", ".", "getCcCreditService", "(", ")", ".", "setCaptureRequestID", "(", "transactionId", ")", ";", "return", "executeTransaction", "(", "processor", ",", "request", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doRecurring", "(", "Money", "money", ",", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doStoreCreditCard", "(", "CreditCard", "creditCard", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "TransactionResponse", "doEvictCreditCard", "(", "String", "creditCardId", ",", "Map", "<", "String", ",", "Object", ">", "options", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "boolean", "supportsPurchase", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsAuthorize", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCapture", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsRevert", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsCredit", "(", ")", "{", "return", "true", ";", "}", "@", "Override", "public", "boolean", "supportsStoreCreditCard", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "boolean", "supportsEvictCreditCard", "(", ")", "{", "return", "false", ";", "}", "@", "Override", "public", "void", "setTest", "(", "boolean", "test", ")", "{", "this", ".", "test", "=", "test", ";", "}", "private", "TransactionResponse", "executeTransaction", "(", "ITransactionProcessor", "processor", ",", "RequestMessage", "request", ")", "{", "ReplyMessage", "replyMessage", "=", "processor", ".", "runTransaction", "(", "request", ")", ";", "return", "buildTransactionResponse", "(", "replyMessage", ")", ";", "}", "private", "RequestMessage", "buildRequestMessage", "(", "TransactionType", "transactionType", ",", "Money", "money", ",", "CreditCard", "creditCard", ",", "Order", "order", ")", "{", "RequestMessage", "request", "=", "new", "RequestMessage", "(", ")", ";", "transactionType", ".", "setServices", "(", "request", ")", ";", "request", ".", "setMerchantID", "(", "username", ")", ";", "if", "(", "creditCard", "!=", "null", ")", "{", "request", ".", "setCard", "(", "new", "CreditCardConverter", "(", "creditCard", ")", ".", "toCard", "(", ")", ")", ";", "}", "if", "(", "money", "!=", "null", ")", "{", "request", ".", "setPurchaseTotals", "(", "buildPurchaseTotals", "(", "money", ")", ")", ";", "}", "if", "(", "order", "!=", "null", ")", "{", "request", ".", "setBillTo", "(", "new", "AddressConverter", "(", "order", ".", "getBillingAddress", "(", ")", ")", ".", "toBillTo", "(", ")", ")", ";", "request", ".", "setShipTo", "(", "new", "AddressConverter", "(", "order", ".", "getShippingAddress", "(", ")", ")", ".", "toShipTo", "(", ")", ")", ";", "}", "return", "request", ";", "}", "private", "ITransactionProcessor", "buildTransactionProcessor", "(", ")", "{", "ITransactionProcessor", "processor", "=", "buildProcessor", "(", "test", "?", "TEST_HOSTNAME", ":", "HOSTNAME", ")", ";", "addSecurityProperties", "(", "processor", ",", "username", ",", "transactionKey", ")", ";", "return", "processor", ";", "}", "private", "TransactionResponse", "buildTransactionResponse", "(", "ReplyMessage", "replyMessage", ")", "{", "TransactionResponse", "transactionResponse", "=", "new", "TransactionResponse", "(", ")", ";", "String", "message", "=", "replyMessage", ".", "getDecision", "(", ")", ";", "if", "(", "!", "replyMessage", ".", "getMissingField", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "message", "+=", "(", "\"\"", "+", "replyMessage", ".", "getMissingField", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "!", "replyMessage", ".", "getInvalidField", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "message", "+=", "(", "\"\"", "+", "replyMessage", ".", "getInvalidField", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "transactionResponse", ".", "setMessage", "(", "message", ")", ";", "transactionResponse", ".", "setCode", "(", "replyMessage", ".", "getReasonCode", "(", ")", ".", "intValue", "(", ")", ")", ";", "transactionResponse", ".", "setReasonCode", "(", "replyMessage", ".", "getReasonCode", "(", ")", ".", "intValue", "(", ")", ")", ";", "transactionResponse", ".", "setAuthorizationId", "(", "replyMessage", ".", "getRequestID", "(", ")", ")", ";", "transactionResponse", ".", "setSuccessful", "(", "100", "==", "replyMessage", ".", "getReasonCode", "(", ")", ".", "intValue", "(", ")", ")", ";", "return", "transactionResponse", ";", "}", "private", "PurchaseTotals", "buildPurchaseTotals", "(", "Money", "money", ")", "{", "PurchaseTotals", "purchaseTotals", "=", "new", "PurchaseTotals", "(", ")", ";", "purchaseTotals", ".", "setGrandTotalAmount", "(", "format", "(", "\"%1$.2f\"", ",", "money", ".", "getAmount", "(", ")", ")", ")", ";", "purchaseTotals", ".", "setCurrency", "(", "money", ".", "getCurrency", "(", ")", ".", "getCurrencyCode", "(", ")", ")", ";", "return", "purchaseTotals", ";", "}", "private", "void", "addSecurityProperties", "(", "ITransactionProcessor", "processor", ",", "String", "username", ",", "String", "transactionKey", ")", "{", "Endpoint", "endpoint", "=", "buildEndpoint", "(", "processor", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "headers", ".", "put", "(", "ACTION", ",", "USERNAME_TOKEN", ")", ";", "headers", ".", "put", "(", "USER", ",", "username", ")", ";", "headers", ".", "put", "(", "PASSWORD_TYPE", ",", "PW_TEXT", ")", ";", "headers", ".", "put", "(", "PW_CALLBACK_REF", ",", "new", "ClientPasswordHandler", "(", "transactionKey", ")", ")", ";", "WSS4JOutInterceptor", "interceptor", "=", "new", "WSS4JOutInterceptor", "(", "headers", ")", ";", "endpoint", ".", "getOutInterceptors", "(", ")", ".", "add", "(", "interceptor", ")", ";", "}", "@", "VisibleForTesting", "Endpoint", "buildEndpoint", "(", "ITransactionProcessor", "processor", ")", "{", "return", "ClientProxy", ".", "getClient", "(", "processor", ")", ".", "getEndpoint", "(", ")", ";", "}", "@", "VisibleForTesting", "ITransactionProcessor", "buildProcessor", "(", "URL", "wsdlLocation", ")", "{", "return", "new", "TransactionProcessor", "(", "wsdlLocation", ")", ".", "getPortXML", "(", ")", ";", "}", "private", "static", "URL", "initUrl", "(", "String", "url", ")", "{", "try", "{", "return", "new", "URL", "(", "url", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "}", "</s>" ]
8,329
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "CCAuthReversalService", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "CCAuthService", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "CCCaptureService", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "CCCreditService", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "RequestMessage", ";", "enum", "TransactionType", "{", "PURCHASE", "{", "@", "Override", "public", "void", "setServices", "(", "RequestMessage", "request", ")", "{", "AUTHORIZE", ".", "setServices", "(", "request", ")", ";", "CAPTURE", ".", "setServices", "(", "request", ")", ";", "}", "}", ",", "AUTHORIZE", "{", "@", "Override", "public", "void", "setServices", "(", "RequestMessage", "request", ")", "{", "request", ".", "setCcAuthService", "(", "new", "CCAuthService", "(", ")", ")", ";", "request", ".", "getCcAuthService", "(", ")", ".", "setRun", "(", "\"true\"", ")", ";", "}", "}", ",", "CAPTURE", "{", "@", "Override", "public", "void", "setServices", "(", "RequestMessage", "request", ")", "{", "request", ".", "setCcCaptureService", "(", "new", "CCCaptureService", "(", ")", ")", ";", "request", ".", "getCcCaptureService", "(", ")", ".", "setRun", "(", "\"true\"", ")", ";", "}", "}", ",", "REVERT", "{", "@", "Override", "public", "void", "setServices", "(", "RequestMessage", "request", ")", "{", "request", ".", "setCcAuthReversalService", "(", "new", "CCAuthReversalService", "(", ")", ")", ";", "request", ".", "getCcAuthReversalService", "(", ")", ".", "setRun", "(", "\"true\"", ")", ";", "}", "}", ",", "CREDIT", "{", "@", "Override", "public", "void", "setServices", "(", "RequestMessage", "request", ")", "{", "request", ".", "setCcCreditService", "(", "new", "CCCreditService", "(", ")", ")", ";", "request", ".", "getCcCreditService", "(", ")", ".", "setRun", "(", "\"true\"", ")", ";", "}", "}", ";", "public", "abstract", "void", "setServices", "(", "RequestMessage", "request", ")", ";", "}", "</s>" ]
8,330
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSPasswordCallback", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "Callback", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "CallbackHandler", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "UnsupportedCallbackException", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "class", "ClientPasswordHandler", "implements", "CallbackHandler", "{", "private", "String", "key", ";", "public", "ClientPasswordHandler", "(", "String", "key", ")", "{", "this", ".", "key", "=", "key", ";", "}", "@", "Override", "public", "void", "handle", "(", "Callback", "[", "]", "callbacks", ")", "throws", "IOException", ",", "UnsupportedCallbackException", "{", "for", "(", "Callback", "callback", ":", "callbacks", ")", "{", "if", "(", "callback", "instanceof", "WSPasswordCallback", ")", "{", "WSPasswordCallback", "passwordCallback", "=", "(", "WSPasswordCallback", ")", "callback", ";", "passwordCallback", ".", "setPassword", "(", "key", ")", ";", "}", "}", "}", "}", "</s>" ]
8,331
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "converter", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "Card", ";", "import", "com", ".", "google", ".", "common", ".", "collect", ".", "ImmutableMap", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "AMERICAN_EXPRESS", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "CARTE_BLANCHE", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "DINERS_CLUB", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "DISCOVER", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "EN_ROUTE", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "JCP", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "LASER", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MAESTRO", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "SOLO", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "VISA", ";", "public", "class", "CreditCardConverter", "{", "private", "static", "final", "Map", "<", "CreditCard", ".", "Type", ",", "String", ">", "CARD_TYPE_TO_CODE", "=", "new", "ImmutableMap", ".", "Builder", "<", "CreditCard", ".", "Type", ",", "String", ">", "(", ")", ".", "put", "(", "VISA", ",", "\"001\"", ")", ".", "put", "(", "MASTER_CARD", ",", "\"002\"", ")", ".", "put", "(", "AMERICAN_EXPRESS", ",", "\"003\"", ")", ".", "put", "(", "DISCOVER", ",", "\"004\"", ")", ".", "put", "(", "DINERS_CLUB", ",", "\"005\"", ")", ".", "put", "(", "CARTE_BLANCHE", ",", "\"006\"", ")", ".", "put", "(", "JCP", ",", "\"007\"", ")", ".", "put", "(", "EN_ROUTE", ",", "\"014\"", ")", ".", "put", "(", "MAESTRO", ",", "\"024\"", ")", ".", "put", "(", "SOLO", ",", "\"032\"", ")", ".", "put", "(", "LASER", ",", "\"035\"", ")", ".", "build", "(", ")", ";", "private", "CreditCard", "creditCard", ";", "public", "CreditCardConverter", "(", "CreditCard", "creditCard", ")", "{", "this", ".", "creditCard", "=", "creditCard", ";", "}", "public", "Card", "toCard", "(", ")", "{", "Card", "card", "=", "new", "Card", "(", ")", ";", "card", ".", "setAccountNumber", "(", "creditCard", ".", "getNumber", "(", ")", ")", ";", "card", ".", "setFullName", "(", "creditCard", ".", "getFirstName", "(", ")", "+", "\"", "\"", "+", "creditCard", ".", "getLastName", "(", ")", ")", ";", "card", ".", "setCardType", "(", "CARD_TYPE_TO_CODE", ".", "get", "(", "creditCard", ".", "getType", "(", ")", ")", ")", ";", "card", ".", "setExpirationMonth", "(", "new", "BigInteger", "(", "creditCard", ".", "getMonth", "(", ")", ")", ")", ";", "card", ".", "setExpirationYear", "(", "new", "BigInteger", "(", "creditCard", ".", "getYear", "(", ")", ")", ")", ";", "card", ".", "setCvNumber", "(", "creditCard", ".", "getSecurityCode", "(", ")", ")", ";", "return", "card", ";", "}", "}", "</s>" ]
8,332
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ".", "converter", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "BillTo", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "ShipTo", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Address", ";", "public", "class", "AddressConverter", "{", "private", "Address", "address", ";", "public", "AddressConverter", "(", "Address", "address", ")", "{", "this", ".", "address", "=", "address", ";", "}", "public", "BillTo", "toBillTo", "(", ")", "{", "BillTo", "billTo", "=", "new", "BillTo", "(", ")", ";", "billTo", ".", "setFirstName", "(", "address", ".", "getFirstName", "(", ")", ")", ";", "billTo", ".", "setLastName", "(", "address", ".", "getLastName", "(", ")", ")", ";", "billTo", ".", "setEmail", "(", "address", ".", "getEmail", "(", ")", ")", ";", "billTo", ".", "setStreet1", "(", "address", ".", "getAddress1", "(", ")", ")", ";", "billTo", ".", "setStreet2", "(", "address", ".", "getAddress2", "(", ")", ")", ";", "billTo", ".", "setCity", "(", "address", ".", "getCity", "(", ")", ")", ";", "billTo", ".", "setPostalCode", "(", "address", ".", "getPostalCode", "(", ")", ")", ";", "billTo", ".", "setState", "(", "address", ".", "getState", "(", ")", ")", ";", "billTo", ".", "setCountry", "(", "address", ".", "getCountryIsoCode", "(", ")", ")", ";", "billTo", ".", "setPhoneNumber", "(", "address", ".", "getPhone", "(", ")", ")", ";", "return", "billTo", ";", "}", "public", "ShipTo", "toShipTo", "(", ")", "{", "ShipTo", "shipTo", "=", "new", "ShipTo", "(", ")", ";", "shipTo", ".", "setFirstName", "(", "address", ".", "getFirstName", "(", ")", ")", ";", "shipTo", ".", "setLastName", "(", "address", ".", "getLastName", "(", ")", ")", ";", "shipTo", ".", "setEmail", "(", "address", ".", "getEmail", "(", ")", ")", ";", "shipTo", ".", "setStreet1", "(", "address", ".", "getAddress1", "(", ")", ")", ";", "shipTo", ".", "setStreet2", "(", "address", ".", "getAddress2", "(", ")", ")", ";", "shipTo", ".", "setCity", "(", "address", ".", "getCity", "(", ")", ")", ";", "shipTo", ".", "setPostalCode", "(", "address", ".", "getPostalCode", "(", ")", ")", ";", "shipTo", ".", "setState", "(", "address", ".", "getState", "(", ")", ")", ";", "shipTo", ".", "setCountry", "(", "address", ".", "getCountryIsoCode", "(", ")", ")", ";", "shipTo", ".", "setPhoneNumber", "(", "address", ".", "getPhone", "(", ")", ")", ";", "return", "shipTo", ";", "}", "}", "</s>" ]
8,333
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSPasswordCallback", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "mockito", ".", "runners", ".", "MockitoJUnitRunner", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "Callback", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verifyZeroInteractions", ";", "@", "RunWith", "(", "MockitoJUnitRunner", ".", "class", ")", "public", "class", "ClientPasswordHandlerTest", "{", "@", "Mock", "private", "WSPasswordCallback", "mockPasswordCallback", ";", "@", "Mock", "private", "Callback", "mockOtherCallback", ";", "@", "Test", "public", "void", "testHandle", "(", ")", "throws", "Exception", "{", "ClientPasswordHandler", "handler", "=", "new", "ClientPasswordHandler", "(", "\"some_key\"", ")", ";", "handler", ".", "handle", "(", "new", "Callback", "[", "]", "{", "mockPasswordCallback", ",", "mockOtherCallback", "}", ")", ";", "verify", "(", "mockPasswordCallback", ")", ".", "setPassword", "(", "\"some_key\"", ")", ";", "verifyZeroInteractions", "(", "mockOtherCallback", ")", ";", "}", "}", "</s>" ]
8,334
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data", ".", "transactionprocessor", ".", "ITransactionProcessor", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "BillTo", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "Card", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "PurchaseTotals", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "ReplyMessage", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "RequestMessage", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "ShipTo", ";", "import", "org", ".", "apache", ".", "cxf", ".", "endpoint", ".", "Endpoint", ";", "import", "org", ".", "apache", ".", "cxf", ".", "interceptor", ".", "Interceptor", ";", "import", "org", ".", "apache", ".", "cxf", ".", "message", ".", "Message", ";", "import", "org", ".", "apache", ".", "cxf", ".", "ws", ".", "security", ".", "wss4j", ".", "WSS4JOutInterceptor", ";", "import", "org", ".", "junit", ".", "After", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "ArgumentCaptor", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "mockito", ".", "runners", ".", "MockitoJUnitRunner", ";", "import", "org", ".", "payments4j", ".", "core", ".", "TransactionResponse", ";", "import", "org", ".", "payments4j", ".", "model", ".", "AddressBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCardBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Money", ";", "import", "org", ".", "payments4j", ".", "model", ".", "MoneyBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Order", ";", "import", "org", ".", "payments4j", ".", "model", ".", "OrderBuilder", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSConstants", ".", "PW_TEXT", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "ACTION", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "PASSWORD_TYPE", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "PW_CALLBACK_REF", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "USER", ";", "import", "static", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ".", "USERNAME_TOKEN", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "Assertions", ".", "assertThat", ";", "import", "static", "org", ".", "fest", ".", "assertions", ".", "MapAssert", ".", "entry", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "isA", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ".", "Type", ".", "MASTER_CARD", ";", "@", "RunWith", "(", "MockitoJUnitRunner", ".", "class", ")", "public", "class", "CybersourcePaymentGatewayTest", "{", "private", "static", "final", "String", "USERNAME", "=", "\"\"", ";", "private", "static", "final", "String", "KEY", "=", "\"some_key\"", ";", "private", "static", "final", "String", "AUTHORIZATION_ID", "=", "\"some_auth_id\"", ";", "private", "CybersourcePaymentGateway_ForTest", "gateway", ";", "private", "Money", "money", ";", "private", "CreditCard", "creditCard", ";", "@", "Mock", "private", "Endpoint", "mockEndpoint", ";", "@", "Mock", "private", "ITransactionProcessor", "mockTransactionProcessor", ";", "private", "List", "<", "Interceptor", "<", "?", "extends", "Message", ">", ">", "outInterceptors", ";", "private", "HashMap", "<", "String", ",", "Object", ">", "options", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "gateway", "=", "new", "CybersourcePaymentGateway_ForTest", "(", "USERNAME", ",", "KEY", ")", ";", "gateway", ".", "setTest", "(", "true", ")", ";", "money", "=", "new", "MoneyBuilder", "(", ")", ".", "withAmount", "(", "\"10\"", ")", ".", "withCurrency", "(", "Locale", ".", "US", ")", ".", "build", "(", ")", ";", "creditCard", "=", "new", "CreditCardBuilder", "(", ")", ".", "withNumber", "(", "\"\"", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withMonth", "(", "\"01\"", ")", ".", "withYear", "(", "\"2012\"", ")", ".", "withType", "(", "MASTER_CARD", ")", ".", "withSecurityCode", "(", "\"123\"", ")", ".", "build", "(", ")", ";", "Order", "order", "=", "new", "OrderBuilder", "(", ")", ".", "withBillingAddress", "(", "new", "AddressBuilder", "(", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withEmail", "(", "\"\"", ")", ".", "withAddress1", "(", "\"b_street", "1\"", ")", ".", "withAddress2", "(", "\"b_street", "2\"", ")", ".", "withCity", "(", "\"b_city\"", ")", ".", "withPostalCode", "(", "\"10000\"", ")", ".", "withState", "(", "\"DE\"", ")", ".", "withCountryIsoCode", "(", "\"US\"", ")", ".", "build", "(", ")", ")", ".", "withShippingAddress", "(", "new", "AddressBuilder", "(", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withEmail", "(", "\"\"", ")", ".", "withAddress1", "(", "\"s_street", "1\"", ")", ".", "withAddress2", "(", "\"s_street", "2\"", ")", ".", "withCity", "(", "\"s_city\"", ")", ".", "withPostalCode", "(", "\"10000\"", ")", ".", "withState", "(", "\"DE\"", ")", ".", "withCountryIsoCode", "(", "\"US\"", ")", ".", "build", "(", ")", ")", ".", "build", "(", ")", ";", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"123\"", ")", ";", "options", ".", "put", "(", "\"order\"", ",", "order", ")", ";", "options", ".", "put", "(", "\"money\"", ",", "money", ")", ";", "TransactionResponse", "transactionResponse", "=", "new", "TransactionResponse", "(", ")", ";", "transactionResponse", ".", "setCode", "(", "100", ")", ";", "transactionResponse", ".", "setAuthorizationId", "(", "\"123\"", ")", ";", "transactionResponse", ".", "setReasonCode", "(", "100", ")", ";", "transactionResponse", ".", "setMessage", "(", "\"Verified\"", ")", ";", "transactionResponse", ".", "setSuccessful", "(", "true", ")", ";", "outInterceptors", "=", "new", "ArrayList", "<", "Interceptor", "<", "?", "extends", "Message", ">", ">", "(", ")", ";", "ReplyMessage", "replyMessage", "=", "new", "ReplyMessage", "(", ")", ";", "replyMessage", ".", "setDecision", "(", "\"Verified\"", ")", ";", "replyMessage", ".", "setReasonCode", "(", "new", "BigInteger", "(", "\"100\"", ")", ")", ";", "replyMessage", ".", "setRequestID", "(", "\"123\"", ")", ";", "when", "(", "mockTransactionProcessor", ".", "runTransaction", "(", "isA", "(", "RequestMessage", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "replyMessage", ")", ";", "when", "(", "mockEndpoint", ".", "getOutInterceptors", "(", ")", ")", ".", "thenReturn", "(", "outInterceptors", ")", ";", "}", "@", "After", "public", "void", "tearDown", "(", ")", "throws", "Exception", "{", "assertThatSecurityValuesAreSet", "(", ")", ";", "}", "@", "Test", "public", "void", "testPurchase", "(", ")", "throws", "Exception", "{", "gateway", ".", "purchase", "(", "money", ",", "creditCard", ",", "options", ")", ";", "RequestMessage", "requestMessage", "=", "captureRequestMessage", "(", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcAuthService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcCaptureService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThatCardEquals", "(", "requestMessage", ".", "getCard", "(", ")", ")", ";", "assertThatPurchaseTotalsEquals", "(", "requestMessage", ".", "getPurchaseTotals", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testAuthorize", "(", ")", "throws", "Exception", "{", "gateway", ".", "authorize", "(", "money", ",", "creditCard", ",", "options", ")", ";", "RequestMessage", "requestMessage", "=", "captureRequestMessage", "(", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcAuthService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThatCardEquals", "(", "requestMessage", ".", "getCard", "(", ")", ")", ";", "assertThatPurchaseTotalsEquals", "(", "requestMessage", ".", "getPurchaseTotals", "(", ")", ")", ";", "assertThatBillingAddressEquals", "(", "requestMessage", ".", "getBillTo", "(", ")", ")", ";", "assertThatShippingAddressEquals", "(", "requestMessage", ".", "getShipTo", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testCapture", "(", ")", "throws", "Exception", "{", "gateway", ".", "capture", "(", "money", ",", "AUTHORIZATION_ID", ",", "options", ")", ";", "RequestMessage", "requestMessage", "=", "captureRequestMessage", "(", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcCaptureService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThatPurchaseTotalsEquals", "(", "requestMessage", ".", "getPurchaseTotals", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testRevert", "(", ")", "throws", "Exception", "{", "gateway", ".", "revert", "(", "AUTHORIZATION_ID", ",", "options", ")", ";", "RequestMessage", "requestMessage", "=", "captureRequestMessage", "(", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcAuthReversalService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcAuthReversalService", "(", ")", ".", "getAuthRequestID", "(", ")", ")", ".", "isEqualTo", "(", "AUTHORIZATION_ID", ")", ";", "assertThatPurchaseTotalsEquals", "(", "requestMessage", ".", "getPurchaseTotals", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testCredit", "(", ")", "throws", "Exception", "{", "gateway", ".", "credit", "(", "money", ",", "AUTHORIZATION_ID", ",", "options", ")", ";", "RequestMessage", "requestMessage", "=", "captureRequestMessage", "(", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcCreditService", "(", ")", ".", "getRun", "(", ")", ")", ".", "isEqualTo", "(", "\"true\"", ")", ";", "assertThat", "(", "requestMessage", ".", "getCcCreditService", "(", ")", ".", "getCaptureRequestID", "(", ")", ")", ".", "isEqualTo", "(", "AUTHORIZATION_ID", ")", ";", "assertThatPurchaseTotalsEquals", "(", "requestMessage", ".", "getPurchaseTotals", "(", ")", ")", ";", "}", "private", "void", "assertThatBillingAddressEquals", "(", "BillTo", "billTo", ")", "{", "assertThat", "(", "billTo", ".", "getFirstName", "(", ")", ")", ".", "isEqualTo", "(", "\"John\"", ")", ";", "assertThat", "(", "billTo", ".", "getLastName", "(", ")", ")", ".", "isEqualTo", "(", "\"Doe\"", ")", ";", "assertThat", "(", "billTo", ".", "getEmail", "(", ")", ")", ".", "isEqualTo", "(", "\"\"", ")", ";", "assertThat", "(", "billTo", ".", "getStreet1", "(", ")", ")", ".", "isEqualTo", "(", "\"b_street", "1\"", ")", ";", "assertThat", "(", "billTo", ".", "getStreet2", "(", ")", ")", ".", "isEqualTo", "(", "\"b_street", "2\"", ")", ";", "assertThat", "(", "billTo", ".", "getCity", "(", ")", ")", ".", "isEqualTo", "(", "\"b_city\"", ")", ";", "assertThat", "(", "billTo", ".", "getPostalCode", "(", ")", ")", ".", "isEqualTo", "(", "\"10000\"", ")", ";", "assertThat", "(", "billTo", ".", "getState", "(", ")", ")", ".", "isEqualTo", "(", "\"DE\"", ")", ";", "assertThat", "(", "billTo", ".", "getCountry", "(", ")", ")", ".", "isEqualTo", "(", "\"US\"", ")", ";", "}", "private", "void", "assertThatShippingAddressEquals", "(", "ShipTo", "shipTo", ")", "{", "assertThat", "(", "shipTo", ".", "getFirstName", "(", ")", ")", ".", "isEqualTo", "(", "\"John\"", ")", ";", "assertThat", "(", "shipTo", ".", "getLastName", "(", ")", ")", ".", "isEqualTo", "(", "\"Doe\"", ")", ";", "assertThat", "(", "shipTo", ".", "getEmail", "(", ")", ")", ".", "isEqualTo", "(", "\"\"", ")", ";", "assertThat", "(", "shipTo", ".", "getStreet1", "(", ")", ")", ".", "isEqualTo", "(", "\"s_street", "1\"", ")", ";", "assertThat", "(", "shipTo", ".", "getStreet2", "(", ")", ")", ".", "isEqualTo", "(", "\"s_street", "2\"", ")", ";", "assertThat", "(", "shipTo", ".", "getCity", "(", ")", ")", ".", "isEqualTo", "(", "\"s_city\"", ")", ";", "assertThat", "(", "shipTo", ".", "getPostalCode", "(", ")", ")", ".", "isEqualTo", "(", "\"10000\"", ")", ";", "assertThat", "(", "shipTo", ".", "getState", "(", ")", ")", ".", "isEqualTo", "(", "\"DE\"", ")", ";", "assertThat", "(", "shipTo", ".", "getCountry", "(", ")", ")", ".", "isEqualTo", "(", "\"US\"", ")", ";", "}", "private", "void", "assertThatSecurityValuesAreSet", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "interceptorProperties", "=", "(", "(", "WSS4JOutInterceptor", ")", "outInterceptors", ".", "get", "(", "0", ")", ")", ".", "getProperties", "(", ")", ";", "assertThat", "(", "interceptorProperties", ")", ".", "includes", "(", "entry", "(", "ACTION", ",", "USERNAME_TOKEN", ")", ",", "entry", "(", "USER", ",", "USERNAME", ")", ",", "entry", "(", "PASSWORD_TYPE", ",", "PW_TEXT", ")", ")", ";", "assertThat", "(", "interceptorProperties", ".", "get", "(", "PW_CALLBACK_REF", ")", ")", ".", "isInstanceOf", "(", "ClientPasswordHandler", ".", "class", ")", ";", "}", "private", "RequestMessage", "captureRequestMessage", "(", ")", "{", "ArgumentCaptor", "<", "RequestMessage", ">", "captor", "=", "ArgumentCaptor", ".", "forClass", "(", "RequestMessage", ".", "class", ")", ";", "verify", "(", "mockTransactionProcessor", ")", ".", "runTransaction", "(", "captor", ".", "capture", "(", ")", ")", ";", "return", "captor", ".", "getValue", "(", ")", ";", "}", "private", "void", "assertThatPurchaseTotalsEquals", "(", "PurchaseTotals", "purchaseTotals", ")", "{", "assertThat", "(", "purchaseTotals", ".", "getCurrency", "(", ")", ")", ".", "isEqualTo", "(", "\"USD\"", ")", ";", "assertThat", "(", "purchaseTotals", ".", "getGrandTotalAmount", "(", ")", ")", ".", "isEqualTo", "(", "\"10.00\"", ")", ";", "}", "private", "void", "assertThatCardEquals", "(", "Card", "card", ")", "{", "assertThat", "(", "card", ".", "getAccountNumber", "(", ")", ")", ".", "isEqualTo", "(", "\"\"", ")", ";", "assertThat", "(", "card", ".", "getAccountNumber", "(", ")", ")", ".", "isEqualTo", "(", "\"\"", ")", ";", "assertThat", "(", "card", ".", "getFullName", "(", ")", ")", ".", "isEqualTo", "(", "\"John", "Doe\"", ")", ";", "assertThat", "(", "card", ".", "getExpirationMonth", "(", ")", ")", ".", "isEqualTo", "(", "new", "BigInteger", "(", "\"01\"", ")", ")", ";", "assertThat", "(", "card", ".", "getExpirationYear", "(", ")", ")", ".", "isEqualTo", "(", "new", "BigInteger", "(", "\"2012\"", ")", ")", ";", "assertThat", "(", "card", ".", "getCvNumber", "(", ")", ")", ".", "isEqualTo", "(", "\"123\"", ")", ";", "assertThat", "(", "card", ".", "getCardType", "(", ")", ")", ".", "isEqualTo", "(", "\"002\"", ")", ";", "}", "private", "class", "CybersourcePaymentGateway_ForTest", "extends", "CybersourcePaymentGateway", "{", "public", "CybersourcePaymentGateway_ForTest", "(", "String", "username", ",", "String", "transactionKey", ")", "{", "super", "(", "username", ",", "transactionKey", ")", ";", "}", "@", "Override", "ITransactionProcessor", "buildProcessor", "(", "URL", "wsdlLocation", ")", "{", "assertThat", "(", "wsdlLocation", ")", ".", "isEqualTo", "(", "TEST_HOSTNAME", ")", ";", "return", "mockTransactionProcessor", ";", "}", "@", "Override", "Endpoint", "buildEndpoint", "(", "ITransactionProcessor", "processor", ")", "{", "return", "mockEndpoint", ";", "}", "}", "}", "</s>" ]
8,335
[ "<s>", "package", "org", ".", "payments4j", ".", "spi", ".", "cybersource", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "payments4j", ".", "core", ".", "PaymentGateway", ";", "import", "org", ".", "payments4j", ".", "model", ".", "AddressBuilder", ";", "import", "org", ".", "payments4j", ".", "model", ".", "CreditCard", ";", "import", "org", ".", "payments4j", ".", "model", ".", "Order", ";", "import", "org", ".", "payments4j", ".", "model", ".", "OrderBuilder", ";", "import", "org", ".", "payments4j", ".", "test", ".", "spi", ".", "AbstractBasePaymentGatewayIntegrationTest", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "CybersourcePaymentGatewayIntegrationTest", "extends", "AbstractBasePaymentGatewayIntegrationTest", "{", "private", "Order", "order", ";", "@", "Override", "protected", "PaymentGateway", "buildGateway", "(", ")", "{", "CybersourcePaymentGateway", "gateway", "=", "new", "CybersourcePaymentGateway", "(", "credentials", ".", "getProperty", "(", "\"\"", ")", ",", "credentials", ".", "getProperty", "(", "\"\"", ")", ")", ";", "gateway", ".", "setTest", "(", "true", ")", ";", "return", "gateway", ";", "}", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "order", "=", "new", "OrderBuilder", "(", ")", ".", "withBillingAddress", "(", "new", "AddressBuilder", "(", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withEmail", "(", "\"\"", ")", ".", "withAddress1", "(", "\"b_street", "1\"", ")", ".", "withAddress2", "(", "\"b_street", "2\"", ")", ".", "withCity", "(", "\"b_city\"", ")", ".", "withPostalCode", "(", "\"10000\"", ")", ".", "withState", "(", "\"DE\"", ")", ".", "withCountryIsoCode", "(", "\"US\"", ")", ".", "build", "(", ")", ")", ".", "withShippingAddress", "(", "new", "AddressBuilder", "(", ")", ".", "withFirstName", "(", "\"John\"", ")", ".", "withLastName", "(", "\"Doe\"", ")", ".", "withEmail", "(", "\"\"", ")", ".", "withAddress1", "(", "\"s_street", "1\"", ")", ".", "withAddress2", "(", "\"s_street", "2\"", ")", ".", "withCity", "(", "\"s_city\"", ")", ".", "withPostalCode", "(", "\"10000\"", ")", ".", "withState", "(", "\"DE\"", ")", ".", "withCountryIsoCode", "(", "\"US\"", ")", ".", "build", "(", ")", ")", ".", "build", "(", ")", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getAuthOptions", "(", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"123\"", ")", ";", "options", ".", "put", "(", "\"order\"", ",", "order", ")", ";", "return", "options", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getCaptureOptions", "(", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"456\"", ")", ";", "return", "options", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getPurchaseOptions", "(", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"789\"", ")", ";", "options", ".", "put", "(", "\"order\"", ",", "order", ")", ";", "return", "options", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getCreditOptions", "(", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"159\"", ")", ";", "return", "options", ";", "}", "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "getRevertOptions", "(", ")", "{", "HashMap", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"\"", ",", "\"753\"", ")", ";", "options", ".", "put", "(", "\"money\"", ",", "money", ")", ";", "return", "options", ";", "}", "@", "Override", "protected", "CreditCard", "getCreditCard", "(", ")", "{", "CreditCard", "creditCard", "=", "super", ".", "getCreditCard", "(", ")", ";", "creditCard", ".", "setNumber", "(", "\"\"", ")", ";", "return", "creditCard", ";", "}", "}", "</s>" ]
8,336
[ "<s>", "package", "org", ".", "payments4j", ".", "examples", ";", "import", "net", ".", "authorize", ".", "Environment", ";", "import", "net", ".", "authorize", ".", "Merchant", ";", "import", "net", ".", "authorize", ".", "aim", ".", "Result", ";", "import", "net", ".", "authorize", ".", "TransactionType", ";", "import", "net", ".", "authorize", ".", "aim", ".", "Transaction", ";", "import", "net", ".", "authorize", ".", "data", ".", "creditcard", ".", "CreditCard", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "public", "class", "AuthorizeNetClientExample", "{", "private", "static", "final", "String", "API_LOGIN_ID", "=", "\"\"", ";", "private", "static", "final", "String", "TRANSACTION_KEY", "=", "\"\"", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Merchant", "merchant", "=", "Merchant", ".", "createMerchant", "(", "Environment", ".", "SANDBOX", ",", "API_LOGIN_ID", ",", "TRANSACTION_KEY", ")", ";", "CreditCard", "creditCard", "=", "CreditCard", ".", "createCreditCard", "(", ")", ";", "creditCard", ".", "setCreditCardNumber", "(", "\"\"", ")", ";", "creditCard", ".", "setExpirationMonth", "(", "\"12\"", ")", ";", "creditCard", ".", "setExpirationYear", "(", "\"2015\"", ")", ";", "Transaction", "authCaptureTransaction", "=", "merchant", ".", "createAIMTransaction", "(", "TransactionType", ".", "AUTH_CAPTURE", ",", "new", "BigDecimal", "(", "1.99", ")", ")", ";", "authCaptureTransaction", ".", "setCreditCard", "(", "creditCard", ")", ";", "Result", "<", "Transaction", ">", "result", "=", "(", "Result", "<", "Transaction", ">", ")", "merchant", ".", "postTransaction", "(", "authCaptureTransaction", ")", ";", "System", ".", "out", ".", "println", "(", "result", ".", "getTarget", "(", ")", ".", "getTransactionId", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "result", ".", "getResponseCode", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "result", ".", "getResponseText", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "result", ".", "getReasonResponseCode", "(", ")", ")", ";", "}", "}", "</s>" ]
8,337
[ "<s>", "package", "org", ".", "payments4j", ".", "examples", ";", "import", "paypal", ".", "payflow", ".", "*", ";", "public", "class", "PayFlowClientExample", "{", "private", "static", "final", "String", "MERCHANT_USERNAME", "=", "\"\"", ";", "private", "static", "final", "String", "MERCHANT_PASSWORD", "=", "\"\"", ";", "private", "static", "final", "String", "PARTNER", "=", "\"PayPal\"", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Invoice", "invoice", "=", "new", "Invoice", "(", ")", ";", "invoice", ".", "setAmt", "(", "new", "Currency", "(", "25.12", ")", ")", ";", "invoice", ".", "setPoNum", "(", "\"PO12345\"", ")", ";", "invoice", ".", "setInvNum", "(", "\"INV12345\"", ")", ";", "invoice", ".", "setBillTo", "(", "buildBuildTo", "(", ")", ")", ";", "invoice", ".", "addLineItem", "(", "buildLineItem", "(", "\"Desc", "1\"", ")", ")", ";", "invoice", ".", "addLineItem", "(", "buildLineItem", "(", "\"Desc", "2\"", ")", ")", ";", "CardTender", "card", "=", "buildCardTender", "(", ")", ";", "UserInfo", "user", "=", "new", "UserInfo", "(", "MERCHANT_USERNAME", ",", "MERCHANT_USERNAME", ",", "PARTNER", ",", "MERCHANT_PASSWORD", ")", ";", "PayflowConnectionData", "connection", "=", "new", "PayflowConnectionData", "(", "\"\"", ",", "443", ")", ";", "AuthorizationTransaction", "trans", "=", "new", "AuthorizationTransaction", "(", "user", ",", "connection", ",", "invoice", ",", "card", ",", "PayflowUtility", ".", "getRequestId", "(", ")", ")", ";", "Response", "resp", "=", "trans", ".", "submitTransaction", "(", ")", ";", "TransactionResponse", "transactionResponse", "=", "resp", ".", "getTransactionResponse", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"result", "=", "\"", "+", "transactionResponse", ".", "getResult", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"pnref", "=", "\"", "+", "transactionResponse", ".", "getPnref", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"respmsg", "=", "\"", "+", "transactionResponse", ".", "getRespMsg", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"authcode", "=", "\"", "+", "transactionResponse", ".", "getAuthCode", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"avsaddr", "=", "\"", "+", "transactionResponse", ".", "getAvsAddr", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"avszip", "=", "\"", "+", "transactionResponse", ".", "getAvsZip", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"iavs", "=", "\"", "+", "transactionResponse", ".", "getIavs", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"cvv2match", "=", "\"", "+", "transactionResponse", ".", "getCvv2Match", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"duplicate", "=", "\"", "+", "transactionResponse", ".", "getDuplicate", "(", ")", ")", ";", "FraudResponse", "fraudResp", "=", "resp", ".", "getFraudResponse", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"prefpsmsg", "=", "\"", "+", "fraudResp", ".", "getPreFpsMsg", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "fraudResp", ".", "getPostFpsMsg", "(", ")", ")", ";", "}", "private", "static", "LineItem", "buildLineItem", "(", "String", "description", ")", "{", "LineItem", "lineItem", "=", "new", "LineItem", "(", ")", ";", "lineItem", ".", "setDesc", "(", "description", ")", ";", "return", "lineItem", ";", "}", "private", "static", "BillTo", "buildBuildTo", "(", ")", "{", "BillTo", "bill", "=", "new", "BillTo", "(", ")", ";", "bill", ".", "setStreet", "(", "\"123", "Main", "St.\"", ")", ";", "bill", ".", "setZip", "(", "\"12345\"", ")", ";", "return", "bill", ";", "}", "private", "static", "CardTender", "buildCardTender", "(", ")", "{", "CreditCard", "cc", "=", "new", "CreditCard", "(", "\"\"", ",", "\"0112\"", ")", ";", "cc", ".", "setCvv2", "(", "\"123\"", ")", ";", "return", "new", "CardTender", "(", "cc", ")", ";", "}", "}", "</s>" ]
8,338
[ "<s>", "package", "org", ".", "payments4j", ".", "examples", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data", ".", "transactionprocessor", ".", "ITransactionProcessor", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data", ".", "transactionprocessor", ".", "TransactionProcessor", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "BillTo", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "CCAuthService", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "Card", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "Item", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "PurchaseTotals", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "ReplyMessage", ";", "import", "com", ".", "cybersource", ".", "schemas", ".", "transaction_data_1", ".", "RequestMessage", ";", "import", "org", ".", "apache", ".", "cxf", ".", "endpoint", ".", "Client", ";", "import", "org", ".", "apache", ".", "cxf", ".", "endpoint", ".", "Endpoint", ";", "import", "org", ".", "apache", ".", "cxf", ".", "frontend", ".", "ClientProxy", ";", "import", "org", ".", "apache", ".", "cxf", ".", "version", ".", "Version", ";", "import", "org", ".", "apache", ".", "cxf", ".", "ws", ".", "security", ".", "wss4j", ".", "WSS4JOutInterceptor", ";", "import", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSConstants", ";", "import", "org", ".", "apache", ".", "ws", ".", "security", ".", "WSPasswordCallback", ";", "import", "org", ".", "apache", ".", "ws", ".", "security", ".", "handler", ".", "WSHandlerConstants", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "Callback", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "CallbackHandler", ";", "import", "javax", ".", "security", ".", "auth", ".", "callback", ".", "UnsupportedCallbackException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "rmi", ".", "RemoteException", ";", "import", "java", ".", "util", ".", "HashMap", ";", "public", "class", "CybersourceClientExample", "{", "private", "static", "final", "String", "MERCHANT_ID", "=", "\"merchant_id\"", ";", "private", "static", "final", "String", "MERCHANT_KEY", "=", "\"merchant_key\"", ";", "private", "static", "final", "String", "SERVER_URL", "=", "\"\"", ";", "private", "static", "final", "String", "CLIENT_LIB_VERSION", "=", "Version", ".", "getCompleteVersionString", "(", ")", "+", "\"/1.5.10\"", ";", "private", "static", "final", "String", "CLIENT_LIBRARY", "=", "\"\"", ";", "private", "static", "final", "String", "CLIENT_ENV", "=", "System", ".", "getProperty", "(", "\"os.name\"", ")", "+", "\"/\"", "+", "System", ".", "getProperty", "(", "\"os.version\"", ")", "+", "\"/\"", "+", "System", ".", "getProperty", "(", "\"java.vendor\"", ")", "+", "\"/\"", "+", "System", ".", "getProperty", "(", "\"java.version\"", ")", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "RemoteException", ",", "MalformedURLException", "{", "RequestMessage", "request", "=", "new", "RequestMessage", "(", ")", ";", "addClientLibraryInfo", "(", "request", ")", ";", "request", ".", "setMerchantID", "(", "MERCHANT_ID", ")", ";", "request", ".", "setMerchantReferenceCode", "(", "\"222222\"", ")", ";", "request", ".", "setCcAuthService", "(", "new", "CCAuthService", "(", ")", ")", ";", "request", ".", "getCcAuthService", "(", ")", ".", "setRun", "(", "\"true\"", ")", ";", "request", ".", "setBillTo", "(", "buildBillTo", "(", ")", ")", ";", "request", ".", "setCard", "(", "buildCard", "(", ")", ")", ";", "request", ".", "setPurchaseTotals", "(", "buildPurchaseTotals", "(", ")", ")", ";", "request", ".", "getItem", "(", ")", ".", "add", "(", "buildItem", "(", "\"0\"", ",", "\"12.34\"", ",", "\"2\"", ")", ")", ";", "request", ".", "getItem", "(", ")", ".", "add", "(", "buildItem", "(", "\"1\"", ",", "\"56.78\"", ",", "\"1\"", ")", ")", ";", "ITransactionProcessor", "processor", "=", "new", "TransactionProcessor", "(", "new", "URL", "(", "SERVER_URL", ")", ")", ".", "getPortXML", "(", ")", ";", "addSecurityValues", "(", "processor", ")", ";", "ReplyMessage", "reply", "=", "processor", ".", "runTransaction", "(", "request", ")", ";", "System", ".", "out", ".", "println", "(", "\"decision", "=", "\"", "+", "reply", ".", "getDecision", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "reply", ".", "getReasonCode", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"requestID", "=", "\"", "+", "reply", ".", "getRequestID", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "reply", ".", "getRequestToken", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "reply", ".", "getCcAuthReply", "(", ")", ".", "getReasonCode", "(", ")", ")", ";", "}", "private", "static", "void", "addClientLibraryInfo", "(", "RequestMessage", "request", ")", "{", "request", ".", "setClientLibrary", "(", "CLIENT_LIBRARY", ")", ";", "request", ".", "setClientLibraryVersion", "(", "CLIENT_LIB_VERSION", ")", ";", "request", ".", "setClientEnvironment", "(", "CLIENT_ENV", ")", ";", "}", "private", "static", "Item", "buildItem", "(", "String", "id", ",", "String", "unitPrice", ",", "String", "quantity", ")", "{", "Item", "item", "=", "new", "Item", "(", ")", ";", "item", ".", "setId", "(", "new", "BigInteger", "(", "id", ")", ")", ";", "item", ".", "setUnitPrice", "(", "unitPrice", ")", ";", "item", ".", "setQuantity", "(", "new", "BigInteger", "(", "quantity", ")", ")", ";", "return", "item", ";", "}", "private", "static", "PurchaseTotals", "buildPurchaseTotals", "(", ")", "{", "PurchaseTotals", "purchaseTotals", "=", "new", "PurchaseTotals", "(", ")", ";", "purchaseTotals", ".", "setCurrency", "(", "\"USD\"", ")", ";", "purchaseTotals", ".", "setGrandTotalAmount", "(", "\"100\"", ")", ";", "return", "purchaseTotals", ";", "}", "private", "static", "Card", "buildCard", "(", ")", "{", "Card", "card", "=", "new", "Card", "(", ")", ";", "card", ".", "setAccountNumber", "(", "\"\"", ")", ";", "card", ".", "setExpirationMonth", "(", "new", "BigInteger", "(", "\"12\"", ")", ")", ";", "card", ".", "setExpirationYear", "(", "new", "BigInteger", "(", "\"2020\"", ")", ")", ";", "return", "card", ";", "}", "private", "static", "BillTo", "buildBillTo", "(", ")", "{", "BillTo", "billTo", "=", "new", "BillTo", "(", ")", ";", "billTo", ".", "setFirstName", "(", "\"John\"", ")", ";", "billTo", ".", "setLastName", "(", "\"Doe\"", ")", ";", "billTo", ".", "setStreet1", "(", "\"\"", ")", ";", "billTo", ".", "setCity", "(", "\"\"", ")", ";", "billTo", ".", "setState", "(", "\"CA\"", ")", ";", "billTo", ".", "setPostalCode", "(", "\"94043\"", ")", ";", "billTo", ".", "setCountry", "(", "\"US\"", ")", ";", "billTo", ".", "setEmail", "(", "\"\"", ")", ";", "billTo", ".", "setIpAddress", "(", "\"10.7.111.111\"", ")", ";", "return", "billTo", ";", "}", "private", "static", "void", "addSecurityValues", "(", "ITransactionProcessor", "processor", ")", "{", "Client", "client", "=", "ClientProxy", ".", "getClient", "(", "processor", ")", ";", "Endpoint", "endpoint", "=", "client", ".", "getEndpoint", "(", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "outHeaders", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "outHeaders", ".", "put", "(", "WSHandlerConstants", ".", "ACTION", ",", "WSHandlerConstants", ".", "USERNAME_TOKEN", ")", ";", "outHeaders", ".", "put", "(", "WSHandlerConstants", ".", "USER", ",", "MERCHANT_ID", ")", ";", "outHeaders", ".", "put", "(", "WSHandlerConstants", ".", "PASSWORD_TYPE", ",", "WSConstants", ".", "PW_TEXT", ")", ";", "outHeaders", ".", "put", "(", "WSHandlerConstants", ".", "PW_CALLBACK_CLASS", ",", "ClientPasswordHandler", ".", "class", ".", "getName", "(", ")", ")", ";", "WSS4JOutInterceptor", "interceptor", "=", "new", "WSS4JOutInterceptor", "(", "outHeaders", ")", ";", "endpoint", ".", "getOutInterceptors", "(", ")", ".", "add", "(", "interceptor", ")", ";", "}", "public", "static", "class", "ClientPasswordHandler", "implements", "CallbackHandler", "{", "@", "Override", "public", "void", "handle", "(", "Callback", "[", "]", "callbacks", ")", "throws", "IOException", ",", "UnsupportedCallbackException", "{", "for", "(", "Callback", "callback", ":", "callbacks", ")", "{", "if", "(", "callback", "instanceof", "WSPasswordCallback", ")", "{", "WSPasswordCallback", "passwordCallback", "=", "(", "WSPasswordCallback", ")", "callback", ";", "passwordCallback", ".", "setPassword", "(", "MERCHANT_KEY", ")", ";", "}", "}", "}", "}", "}", "</s>" ]
8,339
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "java", ".", "io", ".", "IOException", ";", "@", "Buildable", "public", "class", "CheckedExceptionBean", "{", "public", "CheckedExceptionBean", "(", ")", "throws", "IOException", "{", "throw", "new", "IOException", "(", ")", ";", "}", "}", "</s>" ]
8,340
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Mandatory", ";", "@", "Buildable", "public", "class", "MandatoryBean", "{", "private", "final", "int", "intField", ";", "private", "final", "String", "stringField", ";", "private", "final", "Integer", "integerField", ";", "private", "final", "SomeObject", "someObjectField", ";", "MandatoryBean", "(", "int", "intField", ",", "@", "Mandatory", "String", "stringField", ",", "Integer", "integerField", ",", "@", "Mandatory", "SomeObject", "someObjectField", ")", "{", "this", ".", "intField", "=", "intField", ";", "this", ".", "stringField", "=", "stringField", ";", "this", ".", "integerField", "=", "integerField", ";", "this", ".", "someObjectField", "=", "someObjectField", ";", "}", "public", "int", "getIntField", "(", ")", "{", "return", "intField", ";", "}", "public", "String", "getStringField", "(", ")", "{", "return", "stringField", ";", "}", "public", "Integer", "getIntegerField", "(", ")", "{", "return", "integerField", ";", "}", "public", "SomeObject", "getSomeObjectField", "(", ")", "{", "return", "someObjectField", ";", "}", "}", "</s>" ]
8,341
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Builder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "UncheckedBuilder", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "BuilderInterfaceExample", "{", "public", "<", "T", ">", "List", "<", "T", ">", "buildMultipleInstances", "(", "Builder", "<", "T", ">", "builder", ",", "int", "numberOfInstances", ")", "throws", "Exception", "{", "List", "<", "T", ">", "instances", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numberOfInstances", ";", "i", "++", ")", "{", "instances", ".", "add", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "return", "instances", ";", "}", "public", "<", "T", ">", "List", "<", "T", ">", "buildMultipleInstances", "(", "UncheckedBuilder", "<", "T", ">", "builder", ",", "int", "numberOfInstances", ")", "{", "List", "<", "T", ">", "instances", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numberOfInstances", ";", "i", "++", ")", "{", "instances", ".", "add", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "return", "instances", ";", "}", "}", "</s>" ]
8,342
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Build", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "public", "class", "AnnotatedConstructorBean", "{", "private", "String", "field1", ";", "private", "String", "field2", ";", "public", "AnnotatedConstructorBean", "(", "String", "field1", ",", "String", "field2", ")", "{", "this", ".", "field1", "=", "field1", ";", "this", ".", "field2", "=", "field2", ";", "}", "@", "Build", "public", "AnnotatedConstructorBean", "(", "String", "field1", ")", "{", "this", ".", "field1", "=", "field1", ";", "field2", "=", "\"yeah\"", ";", "}", "public", "AnnotatedConstructorBean", "(", ")", "{", "}", "public", "String", "getField1", "(", ")", "{", "return", "field1", ";", "}", "public", "String", "getField2", "(", ")", "{", "return", "field2", ";", "}", "}", "</s>" ]
8,343
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "public", "class", "FieldsBean", "{", "private", "final", "int", "intField", ";", "private", "final", "String", "stringField", ";", "private", "final", "Integer", "integerField", ";", "private", "final", "SomeObject", "someObjectField", ";", "FieldsBean", "(", "int", "intField", ",", "String", "stringField", ",", "Integer", "integerField", ",", "SomeObject", "someObjectField", ")", "{", "this", ".", "intField", "=", "intField", ";", "this", ".", "stringField", "=", "stringField", ";", "this", ".", "integerField", "=", "integerField", ";", "this", ".", "someObjectField", "=", "someObjectField", ";", "}", "public", "int", "getIntField", "(", ")", "{", "return", "intField", ";", "}", "public", "String", "getStringField", "(", ")", "{", "return", "stringField", ";", "}", "public", "Integer", "getIntegerField", "(", ")", "{", "return", "integerField", ";", "}", "public", "SomeObject", "getSomeObjectField", "(", ")", "{", "return", "someObjectField", ";", "}", "}", "</s>" ]
8,344
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "public", "class", "Person", "{", "private", "final", "int", "age", ";", "private", "final", "String", "name", ";", "Person", "(", "String", "name", ",", "int", "age", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "age", "=", "age", ";", "}", "public", "int", "getAge", "(", ")", "{", "return", "age", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "}", "</s>" ]
8,345
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "public", "class", "SimpleBean", "{", "}", "</s>" ]
8,346
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "(", "\"Factory\"", ")", "public", "class", "CustomNameBean", "{", "public", "static", "CustomNameBean", "factoryUsage", "(", ")", "{", "CustomNameBeanFactory", "factory", "=", "CustomNameBeanFactory", ".", "create", "(", ")", ";", "return", "factory", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,347
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "public", "class", "SomeObject", "{", "}", "</s>" ]
8,348
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "@", "Buildable", "public", "class", "UncheckedExceptionBean", "{", "public", "UncheckedExceptionBean", "(", ")", "throws", "IllegalStateException", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "}", "</s>" ]
8,349
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertSame", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "FieldsBean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "FieldsBeanBuilder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "SomeObject", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "FieldsBeanTest", "{", "@", "Test", "public", "void", "fieldsAssignment", "(", ")", "{", "Integer", "integerField", "=", "42", ";", "int", "intField", "=", "69", ";", "String", "stringField", "=", "\"foobar\"", ";", "SomeObject", "someObjectField", "=", "new", "SomeObject", "(", ")", ";", "FieldsBean", "fieldsBean", "=", "FieldsBeanBuilder", ".", "create", "(", ")", ".", "integerField", "(", "integerField", ")", ".", "intField", "(", "intField", ")", ".", "stringField", "(", "stringField", ")", ".", "someObjectField", "(", "someObjectField", ")", ".", "build", "(", ")", ";", "assertSame", "(", "integerField", ",", "fieldsBean", ".", "getIntegerField", "(", ")", ")", ";", "assertSame", "(", "intField", ",", "fieldsBean", ".", "getIntField", "(", ")", ")", ";", "assertSame", "(", "stringField", ",", "fieldsBean", ".", "getStringField", "(", ")", ")", ";", "assertSame", "(", "someObjectField", ",", "fieldsBean", ".", "getSomeObjectField", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "fieldsReassignment", "(", ")", "{", "Integer", "integerField1", "=", "42", ";", "Integer", "integerField2", "=", "69", ";", "FieldsBean", "fieldsBean", "=", "FieldsBeanBuilder", ".", "create", "(", ")", ".", "integerField", "(", "integerField1", ")", ".", "integerField", "(", "integerField2", ")", ".", "build", "(", ")", ";", "assertSame", "(", "integerField2", ",", "fieldsBean", ".", "getIntegerField", "(", ")", ")", ";", "}", "}", "</s>" ]
8,350
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "AnnotatedConstructorBean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "AnnotatedConstructorBeanBuilder", ";", "import", "org", ".", "junit", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "AnnotatedConstructorBeanTest", "{", "@", "Test", "public", "void", "annotatedConstructorIsUsed", "(", ")", "{", "AnnotatedConstructorBean", "bean", "=", "AnnotatedConstructorBeanBuilder", ".", "create", "(", ")", ".", "field1", "(", "\"hello\"", ")", ".", "build", "(", ")", ";", "Assert", ".", "assertEquals", "(", "\"hello\"", ",", "bean", ".", "getField1", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"yeah\"", ",", "bean", ".", "getField2", "(", ")", ")", ";", "}", "}", "</s>" ]
8,351
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "SimpleBean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "SimpleBeanBuilder", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "SimpleBeanTest", "{", "@", "Test", "public", "void", "newInstanceNotNull", "(", ")", "{", "Assert", ".", "assertNotNull", "(", "SimpleBeanBuilder", ".", "create", "(", ")", ".", "build", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "notSameInstanceTwice", "(", ")", "{", "SimpleBeanBuilder", "builder", "=", "SimpleBeanBuilder", ".", "create", "(", ")", ";", "SimpleBean", "bean1", "=", "builder", ".", "build", "(", ")", ";", "SimpleBean", "bean2", "=", "builder", ".", "build", "(", ")", ";", "Assert", ".", "assertNotSame", "(", "bean1", ",", "bean2", ")", ";", "}", "}", "</s>" ]
8,352
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "CheckedExceptionBeanBuilder", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "CheckedExceptionBeanTest", "{", "@", "Test", "(", "expected", "=", "IOException", ".", "class", ")", "public", "void", "throwsConstructorException", "(", ")", "throws", "IOException", "{", "CheckedExceptionBeanBuilder", ".", "create", "(", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,353
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "bean", ".", "UncheckedExceptionBeanBuilder", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "UncheckedExceptionBeanTest", "{", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "throwsConstructorException", "(", ")", "{", "UncheckedExceptionBeanBuilder", ".", "create", "(", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,354
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "bean", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertSame", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "MandatoryBeanTest", "{", "@", "Test", "public", "void", "mandatoryParametersAssignmentThroughtCreate", "(", ")", "{", "String", "stringField", "=", "\"42\"", ";", "SomeObject", "someObjectField", "=", "new", "SomeObject", "(", ")", ";", "MandatoryBean", "bean", "=", "MandatoryBeanBuilder", ".", "create", "(", "stringField", ",", "someObjectField", ")", ".", "build", "(", ")", ";", "assertSame", "(", "stringField", ",", "bean", ".", "getStringField", "(", ")", ")", ";", "assertSame", "(", "someObjectField", ",", "bean", ".", "getSomeObjectField", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "mandatoryParametersAssignmentThroughtConstructor", "(", ")", "{", "String", "stringField", "=", "\"42\"", ";", "SomeObject", "someObjectField", "=", "new", "SomeObject", "(", ")", ";", "MandatoryBean", "bean", "=", "new", "MandatoryBeanBuilder", "(", "stringField", ",", "someObjectField", ")", ".", "build", "(", ")", ";", "assertSame", "(", "stringField", ",", "bean", ".", "getStringField", "(", ")", ")", ";", "assertSame", "(", "someObjectField", ",", "bean", ".", "getSomeObjectField", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "mandatoryParametersReassignment", "(", ")", "{", "String", "stringField1", "=", "\"42\"", ";", "String", "stringField2", "=", "\"69\"", ";", "SomeObject", "someObjectField", "=", "new", "SomeObject", "(", ")", ";", "MandatoryBeanBuilder", "builder", "=", "MandatoryBeanBuilder", ".", "create", "(", "stringField1", ",", "someObjectField", ")", ";", "builder", ".", "stringField", "(", "stringField2", ")", ";", "MandatoryBean", "bean", "=", "builder", ".", "build", "(", ")", ";", "assertSame", "(", "stringField2", ",", "bean", ".", "getStringField", "(", ")", ")", ";", "}", "}", "</s>" ]
8,355
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "generation", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertSame", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyString", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "doThrow", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "times", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "javax", ".", "tools", ".", "JavaFileObject", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JCodeModel", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JPackage", ";", "public", "class", "SourceCodeWriterTest", "{", "@", "Test", "public", "void", "usesFilerToOpenStream", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "JavaFileObject", "fileObject", "=", "mock", "(", "JavaFileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createSourceFile", "(", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "OutputStream", "expectedOS", "=", "mock", "(", "OutputStream", ".", "class", ")", ";", "when", "(", "fileObject", ".", "openOutputStream", "(", ")", ")", ".", "thenReturn", "(", "expectedOS", ")", ";", "SourceCodeWriter", "sourceCodeWriter", "=", "new", "SourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "OutputStream", "resultingOS", "=", "sourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "\"\"", ")", ";", "assertSame", "(", "expectedOS", ",", "resultingOS", ")", ";", "}", "@", "Test", "public", "void", "doesNotCallOutputStreamCloseMethod", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "JavaFileObject", "fileObject", "=", "mock", "(", "JavaFileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createSourceFile", "(", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "OutputStream", "expectedOS", "=", "mock", "(", "OutputStream", ".", "class", ")", ";", "when", "(", "fileObject", ".", "openOutputStream", "(", ")", ")", ".", "thenReturn", "(", "expectedOS", ")", ";", "SourceCodeWriter", "sourceCodeWriter", "=", "new", "SourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "sourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "\"\"", ")", ";", "doThrow", "(", "new", "RuntimeException", "(", "\"\"", ")", ")", ".", "when", "(", "expectedOS", ")", ".", "close", "(", ")", ";", "sourceCodeWriter", ".", "close", "(", ")", ";", "}", "@", "Test", "public", "void", "multipleCallsAreDelegatedToFiler", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "JavaFileObject", "fileObject", "=", "mock", "(", "JavaFileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createSourceFile", "(", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "SourceCodeWriter", "sourceCodeWriter", "=", "new", "SourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "sourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "\"\"", ")", ";", "sourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "\"\"", ")", ";", "verify", "(", "filer", ",", "times", "(", "2", ")", ")", ".", "createSourceFile", "(", "anyString", "(", ")", ")", ";", "}", "}", "</s>" ]
8,356
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "generation", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertSame", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyString", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "doThrow", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "times", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "javax", ".", "tools", ".", "FileObject", ";", "import", "javax", ".", "tools", ".", "JavaFileManager", ".", "Location", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "Mockito", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JCodeModel", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JPackage", ";", "public", "class", "ResourceCodeWriterTest", "{", "@", "Test", "public", "void", "usesFilerToOpenStream", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "FileObject", "fileObject", "=", "mock", "(", "FileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createResource", "(", "Mockito", ".", "<", "Location", ">", "any", "(", ")", ",", "anyString", "(", ")", ",", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "OutputStream", "expectedOS", "=", "mock", "(", "OutputStream", ".", "class", ")", ";", "when", "(", "fileObject", ".", "openOutputStream", "(", ")", ")", ".", "thenReturn", "(", "expectedOS", ")", ";", "ResourceCodeWriter", "resourceCodeWriter", "=", "new", "ResourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "OutputStream", "resultingOS", "=", "resourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "null", ")", ";", "assertSame", "(", "expectedOS", ",", "resultingOS", ")", ";", "}", "@", "Test", "public", "void", "doesNotCallOutputStreamCloseMethod", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "FileObject", "fileObject", "=", "mock", "(", "FileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createResource", "(", "Mockito", ".", "<", "Location", ">", "any", "(", ")", ",", "anyString", "(", ")", ",", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "OutputStream", "expectedOS", "=", "mock", "(", "OutputStream", ".", "class", ")", ";", "when", "(", "fileObject", ".", "openOutputStream", "(", ")", ")", ".", "thenReturn", "(", "expectedOS", ")", ";", "ResourceCodeWriter", "resourceCodeWriter", "=", "new", "ResourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "resourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "null", ")", ";", "doThrow", "(", "new", "RuntimeException", "(", "\"\"", ")", ")", ".", "when", "(", "expectedOS", ")", ".", "close", "(", ")", ";", "resourceCodeWriter", ".", "close", "(", ")", ";", "}", "@", "Test", "public", "void", "multipleCallsAreDelegatedToFiler", "(", ")", "throws", "IOException", "{", "Filer", "filer", "=", "mock", "(", "Filer", ".", "class", ")", ";", "FileObject", "fileObject", "=", "mock", "(", "FileObject", ".", "class", ")", ";", "when", "(", "filer", ".", "createResource", "(", "Mockito", ".", "<", "Location", ">", "any", "(", ")", ",", "anyString", "(", ")", ",", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "fileObject", ")", ";", "ResourceCodeWriter", "resourceCodeWriter", "=", "new", "ResourceCodeWriter", "(", "filer", ")", ";", "JPackage", "jPackage", "=", "new", "JCodeModel", "(", ")", ".", "_package", "(", "\"some.package\"", ")", ";", "resourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "null", ")", ";", "resourceCodeWriter", ".", "openBinary", "(", "jPackage", ",", "null", ")", ";", "verify", "(", "filer", ",", "times", "(", "2", ")", ")", ".", "createResource", "(", "Mockito", ".", "<", "Location", ">", "any", "(", ")", ",", "anyString", "(", ")", ",", "anyString", "(", ")", ")", ";", "}", "}", "</s>" ]
8,357
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "validation", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertFalse", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertTrue", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "IsValidTest", "{", "@", "Test", "public", "void", "initialStateIsValid", "(", ")", "{", "IsValid", "valid", "=", "new", "IsValid", "(", ")", ";", "assertTrue", "(", "valid", ".", "isValid", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "invalidateInvalidates", "(", ")", "{", "IsValid", "valid", "=", "new", "IsValid", "(", ")", ";", "valid", ".", "invalidate", "(", ")", ";", "assertFalse", "(", "valid", ".", "isValid", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "doubleInvalidateInvalidates", "(", ")", "{", "IsValid", "valid", "=", "new", "IsValid", "(", ")", ";", "valid", ".", "invalidate", "(", ")", ";", "valid", ".", "invalidate", "(", ")", ";", "assertFalse", "(", "valid", ".", "isValid", "(", ")", ")", ";", "}", "}", "</s>" ]
8,358
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "validation", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertFalse", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertTrue", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "any", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyString", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "RETURNS_DEEP_STUBS", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "never", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "helper", ".", "ElementHelper", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Messager", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "ProcessingEnvironment", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "AnnotationMirror", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "AnnotationValue", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Element", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ElementKind", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ExecutableElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Modifier", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Name", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "TypeElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "type", ".", "DeclaredType", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ".", "Kind", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "BuildableValidatorTest", "{", "private", "ProcessingEnvironment", "processingEnv", ";", "private", "ElementHelper", "elementHelper", ";", "private", "BuildableValidator", "buildableValidator", ";", "private", "TypeElement", "element", ";", "private", "Element", "enclosingElement", ";", "private", "ExecutableElement", "constructor", ";", "private", "Iterator", "<", "ExecutableElement", ">", "iterator", ";", "private", "Buildable", "buildableAnnotation", ";", "private", "Messager", "messager", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "@", "Before", "public", "void", "setup", "(", ")", "{", "processingEnv", "=", "mock", "(", "ProcessingEnvironment", ".", "class", ")", ";", "messager", "=", "mock", "(", "Messager", ".", "class", ")", ";", "when", "(", "processingEnv", ".", "getMessager", "(", ")", ")", ".", "thenReturn", "(", "messager", ")", ";", "elementHelper", "=", "mock", "(", "ElementHelper", ".", "class", ")", ";", "constructor", "=", "mock", "(", "ExecutableElement", ".", "class", ")", ";", "when", "(", "constructor", ".", "getThrownTypes", "(", ")", ")", ".", "thenReturn", "(", "new", "ArrayList", "(", ")", ")", ";", "Set", "<", "ExecutableElement", ">", "constructors", "=", "mock", "(", "Set", ".", "class", ",", "RETURNS_DEEP_STUBS", ")", ";", "when", "(", "constructors", ".", "size", "(", ")", ")", ".", "thenReturn", "(", "1", ")", ";", "iterator", "=", "mock", "(", "Iterator", ".", "class", ")", ";", "when", "(", "iterator", ".", "next", "(", ")", ")", ".", "thenReturn", "(", "constructor", ")", ";", "when", "(", "constructors", ".", "iterator", "(", ")", ")", ".", "thenReturn", "(", "iterator", ")", ";", "when", "(", "elementHelper", ".", "findAccessibleConstructors", "(", "any", "(", "TypeElement", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "constructors", ")", ";", "buildableValidator", "=", "new", "BuildableValidator", "(", "processingEnv", ",", "elementHelper", ")", ";", "createMockValidTypeElement", "(", ")", ";", "}", "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "private", "void", "createMockValidTypeElement", "(", ")", "{", "element", "=", "mock", "(", "TypeElement", ".", "class", ")", ";", "when", "(", "element", ".", "getKind", "(", ")", ")", ".", "thenReturn", "(", "ElementKind", ".", "CLASS", ")", ";", "enclosingElement", "=", "mock", "(", "Element", ".", "class", ")", ";", "when", "(", "element", ".", "getEnclosingElement", "(", ")", ")", ".", "thenReturn", "(", "enclosingElement", ")", ";", "when", "(", "enclosingElement", ".", "getKind", "(", ")", ")", ".", "thenReturn", "(", "ElementKind", ".", "PACKAGE", ")", ";", "Set", "<", "Modifier", ">", "modifiers", "=", "mock", "(", "Set", ".", "class", ")", ";", "when", "(", "enclosingElement", ".", "getModifiers", "(", ")", ")", ".", "thenReturn", "(", "modifiers", ")", ";", "when", "(", "modifiers", ".", "contains", "(", "Modifier", ".", "ABSTRACT", ")", ")", ".", "thenReturn", "(", "true", ")", ";", "buildableAnnotation", "=", "mock", "(", "Buildable", ".", "class", ")", ";", "when", "(", "buildableAnnotation", ".", "value", "(", ")", ")", ".", "thenReturn", "(", "\"Builder\"", ")", ";", "when", "(", "element", ".", "getAnnotation", "(", "Buildable", ".", "class", ")", ")", ".", "thenReturn", "(", "buildableAnnotation", ")", ";", "AnnotationMirror", "annotationMirror", "=", "mock", "(", "AnnotationMirror", ".", "class", ")", ";", "ArrayList", "annotationMirrors", "=", "new", "ArrayList", "(", ")", ";", "annotationMirrors", ".", "add", "(", "annotationMirror", ")", ";", "when", "(", "element", ".", "getAnnotationMirrors", "(", ")", ")", ".", "thenReturn", "(", "annotationMirrors", ")", ";", "DeclaredType", "annotationMirrorType", "=", "mock", "(", "DeclaredType", ".", "class", ")", ";", "when", "(", "annotationMirror", ".", "getAnnotationType", "(", ")", ")", ".", "thenReturn", "(", "annotationMirrorType", ")", ";", "TypeElement", "annotationMirrorElement", "=", "mock", "(", "TypeElement", ".", "class", ")", ";", "when", "(", "annotationMirrorType", ".", "asElement", "(", ")", ")", ".", "thenReturn", "(", "annotationMirrorElement", ")", ";", "Name", "annotationMirrorName", "=", "mock", "(", "Name", ".", "class", ")", ";", "when", "(", "annotationMirrorElement", ".", "getQualifiedName", "(", ")", ")", ".", "thenReturn", "(", "annotationMirrorName", ")", ";", "when", "(", "annotationMirrorName", ".", "toString", "(", ")", ")", ".", "thenReturn", "(", "Buildable", ".", "class", ".", "getName", "(", ")", ")", ";", "Map", "annotationMirrorElementValues", "=", "new", "HashMap", "(", ")", ";", "AnnotationValue", "annotationValue", "=", "mock", "(", "AnnotationValue", ".", "class", ")", ";", "annotationMirrorElementValues", ".", "put", "(", "mock", "(", "ExecutableElement", ".", "class", ")", ",", "annotationValue", ")", ";", "when", "(", "annotationMirror", ".", "getElementValues", "(", ")", ")", ".", "thenReturn", "(", "annotationMirrorElementValues", ")", ";", "}", "@", "Test", "public", "void", "validTypeElementIsValid", "(", ")", "{", "boolean", "valid", "=", "buildableValidator", ".", "validate", "(", "element", ")", ";", "verify", "(", "messager", ",", "never", "(", ")", ")", ".", "printMessage", "(", "any", "(", "Kind", ".", "class", ")", ",", "anyString", "(", ")", ")", ";", "verify", "(", "messager", ",", "never", "(", ")", ")", ".", "printMessage", "(", "any", "(", "Kind", ".", "class", ")", ",", "anyString", "(", ")", ",", "any", "(", "Element", ".", "class", ")", ")", ";", "verify", "(", "messager", ",", "never", "(", ")", ")", ".", "printMessage", "(", "any", "(", "Kind", ".", "class", ")", ",", "anyString", "(", ")", ",", "any", "(", "Element", ".", "class", ")", ",", "any", "(", "AnnotationMirror", ".", "class", ")", ")", ";", "verify", "(", "messager", ",", "never", "(", ")", ")", ".", "printMessage", "(", "any", "(", "Kind", ".", "class", ")", ",", "anyString", "(", ")", ",", "any", "(", "Element", ".", "class", ")", ",", "any", "(", "AnnotationMirror", ".", "class", ")", ",", "any", "(", "AnnotationValue", ".", "class", ")", ")", ";", "assertTrue", "(", "valid", ")", ";", "}", "@", "Test", "public", "void", "emptyCustomBuilderNameIsNotValid", "(", ")", "{", "when", "(", "buildableAnnotation", ".", "value", "(", ")", ")", ".", "thenReturn", "(", "\"\"", ")", ";", "boolean", "valid", "=", "buildableValidator", ".", "validate", "(", "element", ")", ";", "verify", "(", "messager", ")", ".", "printMessage", "(", "any", "(", "Kind", ".", "class", ")", ",", "anyString", "(", ")", ",", "any", "(", "Element", ".", "class", ")", ",", "any", "(", "AnnotationMirror", ".", "class", ")", ",", "any", "(", "AnnotationValue", ".", "class", ")", ")", ";", "assertFalse", "(", "valid", ")", ";", "}", "}", "</s>" ]
8,359
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "processing", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "AbstractProcessor", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Processor", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "SupportedAnnotationTypes", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ";", "public", "abstract", "class", "AnnotatedAbstractProcessor", "extends", "AbstractProcessor", "{", "public", "Set", "<", "String", ">", "getSupportedAnnotationTypes", "(", ")", "{", "SupportedAnnotationClasses", "sac", "=", "this", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "SupportedAnnotationClasses", ".", "class", ")", ";", "if", "(", "sac", "==", "null", ")", "{", "if", "(", "isInitialized", "(", ")", ")", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "WARNING", ",", "\"No", "\"", "+", "SupportedAnnotationClasses", ".", "class", ".", "getSimpleName", "(", ")", "+", "\"", "annotation", "\"", "+", "\"found", "on", "\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "return", "super", ".", "getSupportedAnnotationTypes", "(", ")", ";", "}", "else", "return", "arrayToSet", "(", "sac", ".", "value", "(", ")", ")", ";", "}", "private", "static", "Set", "<", "String", ">", "arrayToSet", "(", "Class", "<", "?", "extends", "Annotation", ">", "[", "]", "array", ")", "{", "assert", "array", "!=", "null", ";", "Set", "<", "String", ">", "set", "=", "new", "HashSet", "<", "String", ">", "(", "array", ".", "length", ")", ";", "for", "(", "Class", "<", "?", "extends", "Annotation", ">", "c", ":", "array", ")", "{", "set", ".", "add", "(", "c", ".", "getName", "(", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "set", ")", ";", "}", "}", "</s>" ]
8,360
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "processing", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Builder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "generation", ".", "SourceGenerator", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "helper", ".", "ElementHelper", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "modeling", ".", "ModelBuilder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "validation", ".", "BuildableValidator", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Messager", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "RoundEnvironment", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "SupportedSourceVersion", ";", "import", "javax", ".", "lang", ".", "model", ".", "SourceVersion", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Element", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "TypeElement", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ".", "Kind", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JClassAlreadyExistsException", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JCodeModel", ";", "@", "SupportedAnnotationClasses", "(", "Buildable", ".", "class", ")", "@", "SupportedSourceVersion", "(", "SourceVersion", ".", "RELEASE_6", ")", "public", "class", "BuilderGenProcessor", "extends", "AnnotatedAbstractProcessor", "{", "@", "Override", "public", "boolean", "process", "(", "Set", "<", "?", "extends", "TypeElement", ">", "annotations", ",", "RoundEnvironment", "roundEnv", ")", "{", "try", "{", "processThrowing", "(", "roundEnv", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "printError", "(", "annotations", ",", "roundEnv", ",", "e", ")", ";", "}", "return", "true", ";", "}", "private", "void", "processThrowing", "(", "RoundEnvironment", "roundEnv", ")", "throws", "Exception", "{", "printCompileNote", "(", ")", ";", "Set", "<", "TypeElement", ">", "annotatedElements", "=", "getBuildableAnnotatedElements", "(", "roundEnv", ")", ";", "printNumberOfBuildables", "(", "annotatedElements", ")", ";", "Set", "<", "TypeElement", ">", "validatedElements", "=", "validateElements", "(", "annotatedElements", ")", ";", "JCodeModel", "codeModel", "=", "buildModel", "(", "validatedElements", ")", ";", "generateSources", "(", "codeModel", ")", ";", "}", "private", "void", "printCompileNote", "(", ")", "{", "Messager", "messager", "=", "processingEnv", ".", "getMessager", "(", ")", ";", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "NOTE", ",", "\"\"", ")", ";", "}", "private", "Set", "<", "TypeElement", ">", "getBuildableAnnotatedElements", "(", "RoundEnvironment", "roundEnv", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Set", "<", "TypeElement", ">", "annotatedElements", "=", "(", "Set", "<", "TypeElement", ">", ")", "roundEnv", ".", "getElementsAnnotatedWith", "(", "Buildable", ".", "class", ")", ";", "return", "annotatedElements", ";", "}", "private", "void", "printNumberOfBuildables", "(", "Set", "<", "?", ">", "buildableElements", ")", "{", "Messager", "messager", "=", "processingEnv", ".", "getMessager", "(", ")", ";", "messager", ".", "printMessage", "(", "Kind", ".", "NOTE", ",", "\"Found", "\"", "+", "buildableElements", ".", "size", "(", ")", "+", "\"\"", ")", ";", "}", "private", "Set", "<", "TypeElement", ">", "validateElements", "(", "Set", "<", "TypeElement", ">", "annotatedElements", ")", "{", "BuildableValidator", "validator", "=", "new", "BuildableValidator", "(", "processingEnv", ",", "new", "ElementHelper", "(", ")", ")", ";", "Set", "<", "TypeElement", ">", "validatedElements", "=", "new", "HashSet", "<", "TypeElement", ">", "(", ")", ";", "for", "(", "TypeElement", "annotatedElement", ":", "annotatedElements", ")", "{", "if", "(", "validator", ".", "validate", "(", "annotatedElement", ")", ")", "{", "validatedElements", ".", "add", "(", "annotatedElement", ")", ";", "}", "}", "return", "validatedElements", ";", "}", "private", "JCodeModel", "buildModel", "(", "Set", "<", "TypeElement", ">", "validatedElements", ")", "throws", "JClassAlreadyExistsException", "{", "JCodeModel", "codeModel", "=", "new", "JCodeModel", "(", ")", ";", "ModelBuilder", "modelBuilder", "=", "new", "ModelBuilder", "(", "codeModel", ",", "new", "ElementHelper", "(", ")", ")", ";", "for", "(", "TypeElement", "validatedElement", ":", "validatedElements", ")", "{", "modelBuilder", ".", "buildClass", "(", "validatedElement", ")", ";", "}", "return", "codeModel", ";", "}", "private", "void", "generateSources", "(", "JCodeModel", "codeModel", ")", "throws", "IOException", "{", "Filer", "filer", "=", "processingEnv", ".", "getFiler", "(", ")", ";", "SourceGenerator", "sourceGenerator", "=", "new", "SourceGenerator", "(", "filer", ")", ";", "sourceGenerator", ".", "generate", "(", "codeModel", ")", ";", "}", "private", "void", "printError", "(", "Set", "<", "?", "extends", "TypeElement", ">", "annotations", ",", "RoundEnvironment", "roundEnv", ",", "Exception", "e", ")", "{", "Messager", "messager", "=", "processingEnv", ".", "getMessager", "(", ")", ";", "Throwable", "rootCause", "=", "e", ";", "while", "(", "rootCause", ".", "getCause", "(", ")", "!=", "null", ")", "{", "rootCause", "=", "rootCause", ".", "getCause", "(", ")", ";", "}", "StackTraceElement", "firstElement", "=", "e", ".", "getStackTrace", "(", ")", "[", "0", "]", ";", "StackTraceElement", "rootFirstElement", "=", "rootCause", ".", "getStackTrace", "(", ")", "[", "0", "]", ";", "String", "errorMessage", "=", "e", ".", "toString", "(", ")", "+", "\"", "\"", "+", "firstElement", ".", "toString", "(", ")", "+", "\"", "root:", "\"", "+", "rootCause", ".", "toString", "(", ")", "+", "\"", "\"", "+", "rootFirstElement", ".", "toString", "(", ")", ";", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "\"\"", "+", "errorMessage", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "Element", "element", "=", "roundEnv", ".", "getElementsAnnotatedWith", "(", "annotations", ".", "iterator", "(", ")", ".", "next", "(", ")", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "messager", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "\"\"", "+", "errorMessage", ",", "element", ")", ";", "}", "}", "</s>" ]
8,361
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "processing", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Documented", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Documented", "@", "Target", "(", "ElementType", ".", "TYPE", ")", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "public", "@", "interface", "SupportedAnnotationClasses", "{", "Class", "<", "?", "extends", "Annotation", ">", "[", "]", "value", "(", ")", ";", "}", "</s>" ]
8,362
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "modeling", ";", "import", "static", "com", ".", "sun", ".", "codemodel", ".", "JExpr", ".", "_this", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Builder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Mandatory", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "UncheckedBuilder", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "helper", ".", "ElementHelper", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "processing", ".", "BuilderGenProcessor", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "annotation", ".", "Generated", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ExecutableElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "TypeElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "VariableElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "type", ".", "TypeMirror", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JBlock", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JClass", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JClassAlreadyExistsException", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JCodeModel", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JDefinedClass", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JDocComment", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JExpr", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JFieldVar", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JInvocation", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JMethod", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JMod", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JType", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JVar", ";", "public", "class", "ModelBuilder", "{", "private", "final", "ElementHelper", "elementHelper", ";", "private", "final", "JCodeModel", "codeModel", ";", "public", "ModelBuilder", "(", "JCodeModel", "codeModel", ",", "ElementHelper", "elementHelper", ")", "{", "this", ".", "elementHelper", "=", "elementHelper", ";", "this", ".", "codeModel", "=", "codeModel", ";", "}", "public", "void", "buildClass", "(", "TypeElement", "buildableElement", ")", "throws", "JClassAlreadyExistsException", "{", "String", "builderFullyQualifiedName", "=", "extractBuilderFullyQualifiedName", "(", "buildableElement", ")", ";", "Set", "<", "ExecutableElement", ">", "constructors", "=", "elementHelper", ".", "findAccessibleConstructors", "(", "buildableElement", ")", ";", "ExecutableElement", "constructor", "=", "elementHelper", ".", "findBuilderConstructor", "(", "constructors", ")", ";", "JDefinedClass", "builderClass", "=", "codeModel", ".", "_class", "(", "builderFullyQualifiedName", ")", ";", "JClass", "buildableClass", "=", "codeModel", ".", "ref", "(", "buildableElement", ".", "getQualifiedName", "(", ")", ".", "toString", "(", ")", ")", ";", "SimpleDateFormat", "isoDateFormat", "=", "new", "SimpleDateFormat", "(", "\"\"", ")", ";", "builderClass", ".", "annotate", "(", "Generated", ".", "class", ")", ".", "param", "(", "\"comments\"", ",", "\"\"", ")", ".", "param", "(", "\"value\"", ",", "BuilderGenProcessor", ".", "class", ".", "getName", "(", ")", ")", ".", "param", "(", "\"date\"", ",", "isoDateFormat", ".", "format", "(", "new", "Date", "(", ")", ")", ")", ";", "List", "<", "?", "extends", "VariableElement", ">", "parameters", "=", "constructor", ".", "getParameters", "(", ")", ";", "for", "(", "VariableElement", "parameter", ":", "parameters", ")", "{", "String", "paramName", "=", "parameter", ".", "getSimpleName", "(", ")", ".", "toString", "(", ")", ";", "String", "paramClassFullyQualifiedName", "=", "parameter", ".", "asType", "(", ")", ".", "toString", "(", ")", ";", "JClass", "paramClass", "=", "codeModel", ".", "ref", "(", "paramClassFullyQualifiedName", ")", ";", "JFieldVar", "setterField", "=", "builderClass", ".", "field", "(", "JMod", ".", "PRIVATE", ",", "paramClass", ",", "paramName", ")", ";", "JMethod", "setter", "=", "builderClass", ".", "method", "(", "JMod", ".", "PUBLIC", ",", "builderClass", ",", "paramName", ")", ";", "JVar", "setterParam", "=", "setter", ".", "param", "(", "paramClass", ",", "paramName", ")", ";", "setter", ".", "body", "(", ")", ".", "assign", "(", "_this", "(", ")", ".", "ref", "(", "setterField", ")", ",", "setterParam", ")", ".", "_return", "(", "_this", "(", ")", ")", ";", "JDocComment", "javadoc", "=", "setter", ".", "javadoc", "(", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "paramName", ")", ".", "append", "(", "\"", "parameter.\"", ")", ";", "javadoc", ".", "addParam", "(", "setterParam", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "paramName", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"", "class.\"", ")", ";", "javadoc", ".", "addReturn", "(", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "builderClass", ")", ".", "append", "(", "\"\"", ")", ";", "}", "List", "<", "VariableElement", ">", "mandatoryParameters", "=", "new", "ArrayList", "<", "VariableElement", ">", "(", ")", ";", "for", "(", "VariableElement", "parameter", ":", "parameters", ")", "{", "if", "(", "parameter", ".", "getAnnotation", "(", "Mandatory", ".", "class", ")", "!=", "null", ")", "{", "mandatoryParameters", ".", "add", "(", "parameter", ")", ";", "}", "}", "JMethod", "buildMethod", "=", "builderClass", ".", "method", "(", "JMod", ".", "PUBLIC", ",", "buildableClass", ",", "\"build\"", ")", ";", "JDocComment", "javadoc", "=", "buildMethod", ".", "javadoc", "(", ")", ".", "append", "(", "\"Creates", "\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"<br", "/>n\"", ")", ".", "append", "(", "\"\"", ")", ";", "javadoc", ".", "addReturn", "(", ")", ".", "append", "(", "\"a", "new", "\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"", "instance.\"", ")", ";", "boolean", "hasCheckedExceptions", "=", "false", ";", "JClass", "runtimeException", "=", "codeModel", ".", "ref", "(", "RuntimeException", ".", "class", ")", ";", "List", "<", "?", "extends", "TypeMirror", ">", "thrownTypes", "=", "constructor", ".", "getThrownTypes", "(", ")", ";", "for", "(", "TypeMirror", "thrownType", ":", "thrownTypes", ")", "{", "JClass", "thrownClass", "=", "codeModel", ".", "ref", "(", "thrownType", ".", "toString", "(", ")", ")", ";", "buildMethod", ".", "_throws", "(", "thrownClass", ")", ";", "javadoc", ".", "addThrows", "(", "thrownClass", ")", ".", "append", "(", "\"", "when", "\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"\"", ")", ";", "if", "(", "!", "runtimeException", ".", "isAssignableFrom", "(", "thrownClass", ")", ")", "{", "hasCheckedExceptions", "=", "true", ";", "}", "}", "if", "(", "hasCheckedExceptions", ")", "{", "JClass", "builderInterface", "=", "codeModel", ".", "ref", "(", "Builder", ".", "class", ")", ";", "JClass", "narrowedInterface", "=", "builderInterface", ".", "narrow", "(", "buildableClass", ")", ";", "builderClass", ".", "_implements", "(", "narrowedInterface", ")", ";", "}", "else", "{", "JClass", "builderInterface", "=", "codeModel", ".", "ref", "(", "UncheckedBuilder", ".", "class", ")", ";", "JClass", "narrowedInterface", "=", "builderInterface", ".", "narrow", "(", "buildableClass", ")", ";", "builderClass", ".", "_implements", "(", "narrowedInterface", ")", ";", "}", "JBlock", "buildBody", "=", "buildMethod", ".", "body", "(", ")", ";", "JInvocation", "newBuildable", "=", "JExpr", ".", "_new", "(", "buildableClass", ")", ";", "for", "(", "VariableElement", "parameter", ":", "constructor", ".", "getParameters", "(", ")", ")", "{", "String", "paramName", "=", "parameter", ".", "getSimpleName", "(", ")", ".", "toString", "(", ")", ";", "newBuildable", ".", "arg", "(", "JExpr", ".", "ref", "(", "paramName", ")", ")", ";", "}", "buildBody", ".", "_return", "(", "newBuildable", ")", ";", "JClass", "mandatoryClass", "=", "codeModel", ".", "ref", "(", "Mandatory", ".", "class", ")", ";", "if", "(", "mandatoryParameters", ".", "size", "(", ")", "!=", "0", ")", "{", "JMethod", "builderConstructor", "=", "builderClass", ".", "constructor", "(", "JMod", ".", "PUBLIC", ")", ";", "JBlock", "constructorBody", "=", "builderConstructor", ".", "body", "(", ")", ";", "JDocComment", "constructorJavadoc", "=", "builderConstructor", ".", "javadoc", "(", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "mandatoryClass", ")", ".", "append", "(", "\"", "parameters.\"", ")", ";", "for", "(", "VariableElement", "parameter", ":", "mandatoryParameters", ")", "{", "String", "paramName", "=", "parameter", ".", "getSimpleName", "(", ")", ".", "toString", "(", ")", ";", "JFieldVar", "paramField", "=", "builderClass", ".", "fields", "(", ")", ".", "get", "(", "paramName", ")", ";", "JType", "paramClass", "=", "paramField", ".", "type", "(", ")", ";", "JVar", "constructorParam", "=", "builderConstructor", ".", "param", "(", "paramClass", ",", "paramName", ")", ";", "constructorBody", ".", "assign", "(", "_this", "(", ")", ".", "ref", "(", "paramField", ")", ",", "constructorParam", ")", ";", "constructorJavadoc", ".", "addParam", "(", "constructorParam", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "paramName", ")", ".", "append", "(", "\"", "@\"", ")", ".", "append", "(", "mandatoryClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"", "class.\"", ")", ";", "}", "}", "JMethod", "createMethod", "=", "builderClass", ".", "method", "(", "JMod", ".", "PUBLIC", "|", "JMod", ".", "STATIC", ",", "builderClass", ",", "\"create\"", ")", ";", "JBlock", "createBody", "=", "createMethod", ".", "body", "(", ")", ";", "JDocComment", "createJavadoc", "=", "createMethod", ".", "javadoc", "(", ")", ";", "JInvocation", "newBuilder", "=", "JExpr", ".", "_new", "(", "builderClass", ")", ";", "if", "(", "mandatoryParameters", ".", "size", "(", ")", "!=", "0", ")", "{", "for", "(", "VariableElement", "parameter", ":", "mandatoryParameters", ")", "{", "String", "paramName", "=", "parameter", ".", "getSimpleName", "(", ")", ".", "toString", "(", ")", ";", "JFieldVar", "paramField", "=", "builderClass", ".", "fields", "(", ")", ".", "get", "(", "paramName", ")", ";", "JType", "paramClass", "=", "paramField", ".", "type", "(", ")", ";", "JVar", "createParam", "=", "createMethod", ".", "param", "(", "paramClass", ",", "paramName", ")", ";", "newBuilder", ".", "arg", "(", "createParam", ")", ";", "createJavadoc", ".", "addParam", "(", "createParam", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "paramName", ")", ".", "append", "(", "\"", "@\"", ")", ".", "append", "(", "mandatoryClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"", "class.\"", ")", ";", "}", "}", "createBody", ".", "_return", "(", "newBuilder", ")", ";", "createJavadoc", ".", "append", "(", "\"\"", ")", ".", "append", "(", "builderClass", ")", ".", "append", "(", "\"", "instances.\"", ")", ".", "addReturn", "(", ")", ".", "append", "(", "\"a", "new", "\"", ")", ".", "append", "(", "builderClass", ")", ".", "append", "(", "\"instance\"", ")", ";", "addBuilderClassJavadoc", "(", "builderClass", ",", "buildableClass", ")", ";", "}", "private", "void", "addBuilderClassJavadoc", "(", "JDefinedClass", "builderClass", ",", "JClass", "buildableClass", ")", "{", "builderClass", ".", "javadoc", "(", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"<br", "/>n\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"<br", "/>n\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "builderClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"<br", "/>n\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "buildableClass", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"", "method.n\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"<br", "/>n\"", ")", ".", "append", "(", "\"\"", ")", ";", "}", "private", "String", "extractBuilderFullyQualifiedName", "(", "TypeElement", "buildableElement", ")", "{", "Buildable", "buildableAnnotation", "=", "buildableElement", ".", "getAnnotation", "(", "Buildable", ".", "class", ")", ";", "String", "builderSuffix", "=", "buildableAnnotation", ".", "value", "(", ")", ";", "String", "buildableFullyQualifiedName", "=", "buildableElement", ".", "getQualifiedName", "(", ")", ".", "toString", "(", ")", ";", "return", "buildableFullyQualifiedName", "+", "builderSuffix", ";", "}", "}", "</s>" ]
8,363
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "validation", ";", "public", "class", "IsValid", "{", "private", "boolean", "valid", "=", "true", ";", "public", "void", "invalidate", "(", ")", "{", "valid", "=", "false", ";", "}", "public", "boolean", "isValid", "(", ")", "{", "return", "valid", ";", "}", "}", "</s>" ]
8,364
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "validation", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Build", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Buildable", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "helper", ".", "ElementHelper", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "ProcessingEnvironment", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "AnnotationMirror", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "AnnotationValue", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Element", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ElementKind", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ExecutableElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Modifier", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "TypeElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "type", ".", "TypeMirror", ";", "import", "javax", ".", "lang", ".", "model", ".", "util", ".", "Elements", ";", "import", "javax", ".", "lang", ".", "model", ".", "util", ".", "Types", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ";", "import", "javax", ".", "tools", ".", "Diagnostic", ".", "Kind", ";", "public", "class", "BuildableValidator", "{", "private", "final", "ProcessingEnvironment", "processingEnv", ";", "private", "final", "ElementHelper", "elementHelper", ";", "public", "BuildableValidator", "(", "ProcessingEnvironment", "processingEnv", ",", "ElementHelper", "elementHelper", ")", "{", "this", ".", "processingEnv", "=", "processingEnv", ";", "this", ".", "elementHelper", "=", "elementHelper", ";", "}", "public", "boolean", "validate", "(", "TypeElement", "element", ")", "{", "IsValid", "valid", "=", "new", "IsValid", "(", ")", ";", "if", "(", "element", ".", "getKind", "(", ")", "!=", "ElementKind", ".", "CLASS", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "printBuildableError", "(", "element", ",", "\"\"", ")", ";", "}", "if", "(", "element", ".", "getEnclosingElement", "(", ")", ".", "getKind", "(", ")", "!=", "ElementKind", ".", "PACKAGE", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "printBuildableError", "(", "element", ",", "\"\"", ")", ";", "}", "if", "(", "element", ".", "getModifiers", "(", ")", ".", "contains", "(", "Modifier", ".", "ABSTRACT", ")", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "printBuildableError", "(", "element", ",", "\"\"", ")", ";", "}", "Buildable", "buildableAnnotation", "=", "element", ".", "getAnnotation", "(", "Buildable", ".", "class", ")", ";", "String", "builderNameSuffix", "=", "buildableAnnotation", ".", "value", "(", ")", ";", "if", "(", "\"\"", ".", "equals", "(", "builderNameSuffix", ")", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "AnnotationMirror", "annotationMirror", "=", "findAnnotationMirror", "(", "element", ",", "Buildable", ".", "class", ")", ";", "AnnotationValue", "annotationValue", "=", "annotationMirror", ".", "getElementValues", "(", ")", ".", "values", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Kind", ".", "ERROR", ",", "\"\"", ",", "element", ",", "annotationMirror", ",", "annotationValue", ")", ";", "}", "Set", "<", "ExecutableElement", ">", "constructors", "=", "elementHelper", ".", "findAccessibleConstructors", "(", "element", ")", ";", "if", "(", "constructors", ".", "size", "(", ")", "==", "0", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "printBuildableError", "(", "element", ",", "\"\"", ")", ";", "}", "else", "{", "ExecutableElement", "builderConstructor", "=", "null", ";", "if", "(", "constructors", ".", "size", "(", ")", "==", "1", ")", "{", "builderConstructor", "=", "constructors", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}", "else", "{", "Set", "<", "ExecutableElement", ">", "builderConstructors", "=", "elementHelper", ".", "findBuilderConstructors", "(", "constructors", ")", ";", "if", "(", "builderConstructors", ".", "size", "(", ")", "==", "0", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "String", "message", "=", "\"\"", "+", "Build", ".", "class", ".", "getSimpleName", "(", ")", "+", "\"\"", ";", "printBuildableError", "(", "element", ",", "message", ")", ";", "for", "(", "ExecutableElement", "constructor", ":", "constructors", ")", "{", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "message", ",", "constructor", ")", ";", "}", "}", "else", "if", "(", "builderConstructors", ".", "size", "(", ")", ">", "1", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "for", "(", "ExecutableElement", "constructor", ":", "builderConstructors", ")", "{", "printBuildError", "(", "constructor", ",", "\"\"", ")", ";", "}", "}", "else", "{", "builderConstructor", "=", "builderConstructors", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}", "}", "if", "(", "builderConstructor", "!=", "null", ")", "{", "List", "<", "?", "extends", "TypeMirror", ">", "thrownTypes", "=", "builderConstructor", ".", "getThrownTypes", "(", ")", ";", "if", "(", "thrownTypes", ".", "size", "(", ")", ">", "0", ")", "{", "Types", "typeUtils", "=", "processingEnv", ".", "getTypeUtils", "(", ")", ";", "Elements", "elementUtils", "=", "processingEnv", ".", "getElementUtils", "(", ")", ";", "TypeElement", "exceptionElement", "=", "elementUtils", ".", "getTypeElement", "(", "Exception", ".", "class", ".", "getName", "(", ")", ")", ";", "TypeMirror", "exceptionMirror", "=", "exceptionElement", ".", "asType", "(", ")", ";", "for", "(", "TypeMirror", "thrownType", ":", "thrownTypes", ")", "{", "if", "(", "!", "typeUtils", ".", "isSubtype", "(", "thrownType", ",", "exceptionMirror", ")", ")", "{", "valid", ".", "invalidate", "(", ")", ";", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "\"\"", ",", "builderConstructor", ")", ";", "}", "}", "}", "}", "}", "return", "valid", ".", "isValid", "(", ")", ";", "}", "private", "void", "printBuildError", "(", "Element", "annotatedElement", ",", "String", "message", ")", "{", "printMessageOnAnnotation", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "annotatedElement", ",", "Build", ".", "class", ",", "String", ".", "format", "(", "message", ",", "\"@\"", "+", "Build", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "}", "private", "void", "printBuildableError", "(", "Element", "annotatedElement", ",", "String", "message", ")", "{", "printMessageOnAnnotation", "(", "Diagnostic", ".", "Kind", ".", "ERROR", ",", "annotatedElement", ",", "Buildable", ".", "class", ",", "String", ".", "format", "(", "message", ",", "\"@\"", "+", "Buildable", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "}", "private", "void", "printMessageOnAnnotation", "(", "Diagnostic", ".", "Kind", "diagnosticKind", ",", "Element", "annotatedElement", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ",", "String", "message", ")", "{", "AnnotationMirror", "annotationMirror", "=", "findAnnotationMirror", "(", "annotatedElement", ",", "annotationClass", ")", ";", "if", "(", "annotationMirror", "!=", "null", ")", "{", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "diagnosticKind", ",", "message", ",", "annotatedElement", ",", "annotationMirror", ")", ";", "}", "else", "{", "processingEnv", ".", "getMessager", "(", ")", ".", "printMessage", "(", "diagnosticKind", ",", "message", ",", "annotatedElement", ")", ";", "}", "}", "private", "AnnotationMirror", "findAnnotationMirror", "(", "Element", "annotatedElement", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ")", "{", "List", "<", "?", "extends", "AnnotationMirror", ">", "annotationMirrors", "=", "annotatedElement", ".", "getAnnotationMirrors", "(", ")", ";", "for", "(", "AnnotationMirror", "annotationMirror", ":", "annotationMirrors", ")", "{", "TypeElement", "annotationElement", "=", "(", "TypeElement", ")", "annotationMirror", ".", "getAnnotationType", "(", ")", ".", "asElement", "(", ")", ";", "if", "(", "hasSameQualifiedName", "(", "annotationElement", ",", "annotationClass", ")", ")", "{", "return", "annotationMirror", ";", "}", "}", "return", "null", ";", "}", "private", "boolean", "hasSameQualifiedName", "(", "TypeElement", "annotation", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ")", "{", "return", "annotation", ".", "getQualifiedName", "(", ")", ".", "toString", "(", ")", ".", "equals", "(", "annotationClass", ".", "getName", "(", ")", ")", ";", "}", "}", "</s>" ]
8,365
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "helper", ";", "import", "info", ".", "piwai", ".", "buildergen", ".", "api", ".", "Build", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Element", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ElementKind", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "ExecutableElement", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "Modifier", ";", "import", "javax", ".", "lang", ".", "model", ".", "element", ".", "TypeElement", ";", "public", "class", "ElementHelper", "{", "public", "Set", "<", "ExecutableElement", ">", "findAccessibleConstructors", "(", "TypeElement", "buildableElement", ")", "{", "Set", "<", "ExecutableElement", ">", "constructors", "=", "new", "HashSet", "<", "ExecutableElement", ">", "(", ")", ";", "List", "<", "?", "extends", "Element", ">", "enclosedElements", "=", "buildableElement", ".", "getEnclosedElements", "(", ")", ";", "for", "(", "Element", "enclosedElement", ":", "enclosedElements", ")", "{", "ElementKind", "enclosedElementKind", "=", "enclosedElement", ".", "getKind", "(", ")", ";", "if", "(", "enclosedElementKind", "==", "ElementKind", ".", "CONSTRUCTOR", ")", "{", "if", "(", "!", "enclosedElement", ".", "getModifiers", "(", ")", ".", "contains", "(", "Modifier", ".", "PRIVATE", ")", ")", "{", "constructors", ".", "add", "(", "(", "ExecutableElement", ")", "enclosedElement", ")", ";", "}", "}", "}", "return", "constructors", ";", "}", "public", "ExecutableElement", "findBuilderConstructor", "(", "Set", "<", "ExecutableElement", ">", "constructors", ")", "{", "Set", "<", "ExecutableElement", ">", "buildersConstructor", "=", "findBuilderConstructors", "(", "constructors", ")", ";", "if", "(", "buildersConstructor", ".", "size", "(", ")", "==", "1", ")", "{", "return", "buildersConstructor", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "}", "public", "Set", "<", "ExecutableElement", ">", "findBuilderConstructors", "(", "Set", "<", "ExecutableElement", ">", "constructors", ")", "{", "if", "(", "constructors", ".", "size", "(", ")", "==", "1", ")", "{", "return", "constructors", ";", "}", "else", "{", "Set", "<", "ExecutableElement", ">", "buildersConstructors", "=", "new", "HashSet", "<", "ExecutableElement", ">", "(", ")", ";", "for", "(", "ExecutableElement", "candidateConstructor", ":", "constructors", ")", "{", "if", "(", "candidateConstructor", ".", "getAnnotation", "(", "Build", ".", "class", ")", "!=", "null", ")", "{", "buildersConstructors", ".", "add", "(", "candidateConstructor", ")", ";", "}", "}", "return", "buildersConstructors", ";", "}", "}", "}", "</s>" ]
8,366
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "generation", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JCodeModel", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "writer", ".", "PrologCodeWriter", ";", "public", "class", "SourceGenerator", "{", "private", "static", "final", "String", "HEADER_WARNING", "=", "\"\"", ";", "private", "final", "Filer", "filer", ";", "public", "SourceGenerator", "(", "Filer", "filer", ")", "{", "this", ".", "filer", "=", "filer", ";", "}", "public", "void", "generate", "(", "JCodeModel", "codeModel", ")", "throws", "IOException", "{", "SourceCodeWriter", "sourceCodeWriter", "=", "new", "SourceCodeWriter", "(", "filer", ")", ";", "PrologCodeWriter", "prologCodeWriter", "=", "new", "PrologCodeWriter", "(", "sourceCodeWriter", ",", "HEADER_WARNING", ")", ";", "codeModel", ".", "build", "(", "prologCodeWriter", ",", "new", "ResourceCodeWriter", "(", "filer", ")", ")", ";", "}", "}", "</s>" ]
8,367
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "generation", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "javax", ".", "tools", ".", "FileObject", ";", "import", "javax", ".", "tools", ".", "StandardLocation", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "CodeWriter", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JPackage", ";", "public", "class", "ResourceCodeWriter", "extends", "CodeWriter", "{", "private", "final", "Filer", "filer", ";", "public", "ResourceCodeWriter", "(", "Filer", "filer", ")", "{", "this", ".", "filer", "=", "filer", ";", "}", "@", "Override", "public", "OutputStream", "openBinary", "(", "JPackage", "pkg", ",", "String", "fileName", ")", "throws", "IOException", "{", "FileObject", "resource", "=", "filer", ".", "createResource", "(", "StandardLocation", ".", "SOURCE_OUTPUT", ",", "pkg", ".", "name", "(", ")", ",", "fileName", ")", ";", "return", "resource", ".", "openOutputStream", "(", ")", ";", "}", "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "}", "}", "</s>" ]
8,368
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "generation", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "javax", ".", "annotation", ".", "processing", ".", "Filer", ";", "import", "javax", ".", "tools", ".", "JavaFileObject", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "CodeWriter", ";", "import", "com", ".", "sun", ".", "codemodel", ".", "JPackage", ";", "public", "class", "SourceCodeWriter", "extends", "CodeWriter", "{", "private", "final", "Filer", "filer", ";", "public", "SourceCodeWriter", "(", "Filer", "filer", ")", "{", "this", ".", "filer", "=", "filer", ";", "}", "@", "Override", "public", "OutputStream", "openBinary", "(", "JPackage", "pkg", ",", "String", "fileName", ")", "throws", "IOException", "{", "String", "qualifiedClassName", "=", "toQualifiedClassName", "(", "pkg", ",", "fileName", ")", ";", "JavaFileObject", "sourceFile", "=", "filer", ".", "createSourceFile", "(", "qualifiedClassName", ")", ";", "return", "sourceFile", ".", "openOutputStream", "(", ")", ";", "}", "private", "String", "toQualifiedClassName", "(", "JPackage", "pkg", ",", "String", "fileName", ")", "{", "int", "suffixPosition", "=", "fileName", ".", "lastIndexOf", "(", "'.'", ")", ";", "String", "className", "=", "fileName", ".", "substring", "(", "0", ",", "suffixPosition", ")", ";", "String", "qualifiedClassName", "=", "pkg", ".", "name", "(", ")", "+", "\".\"", "+", "className", ";", "return", "qualifiedClassName", ";", "}", "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "}", "}", "</s>" ]
8,369
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "api", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RetentionPolicy", ".", "SOURCE", ")", "@", "Target", "(", "ElementType", ".", "PARAMETER", ")", "public", "@", "interface", "Mandatory", "{", "}", "</s>" ]
8,370
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "api", ";", "public", "interface", "UncheckedBuilder", "<", "T", ">", "extends", "Builder", "<", "T", ">", "{", "T", "build", "(", ")", ";", "}", "</s>" ]
8,371
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "api", ";", "public", "interface", "Builder", "<", "T", ">", "{", "T", "build", "(", ")", "throws", "Exception", ";", "}", "</s>" ]
8,372
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "api", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RetentionPolicy", ".", "SOURCE", ")", "@", "Target", "(", "ElementType", ".", "CONSTRUCTOR", ")", "public", "@", "interface", "Build", "{", "}", "</s>" ]
8,373
[ "<s>", "package", "info", ".", "piwai", ".", "buildergen", ".", "api", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RetentionPolicy", ".", "SOURCE", ")", "@", "Target", "(", "ElementType", ".", "TYPE", ")", "public", "@", "interface", "Buildable", "{", "String", "value", "(", ")", "default", "\"Builder\"", ";", "}", "</s>" ]
8,374
[ "<s>", "package", "dcll", ".", "tarti", ".", "tartiquizz", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "ParserQuizzMoodleTest", "{", "@", "Test", "public", "void", "ParserTest", "(", ")", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "assertEquals", "(", "pars", ".", "getRacineName", "(", ")", ",", "\"quiz\"", ")", ";", "}", "}", "</s>" ]
8,375
[ "<s>", "package", "dcll", ".", "tarti", ".", "tartiquizz", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "elementMoodle", ".", "AnswerMoodle", ";", "import", "elementMoodle", ".", "QuizzMoodle", ";", "import", "exception", ".", "AttributNotFoundException", ";", "import", "exception", ".", "TypeQuestionNotFoundException", ";", "public", "class", "MultichoiceQuestionTest", "{", "@", "Test", "public", "void", "parserMultichoice", "(", ")", "throws", "AttributNotFoundException", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz", ";", "try", "{", "monQuizz", "=", "pars", ".", "createQuizz", "(", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"name\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"questiontext\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"format\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"penalty\"", ")", ",", "\"0.1\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"defaultgrade\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"hidden\"", ")", ",", "\"0\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"image\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"image_base64\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"single\"", ")", ",", "\"false\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"OK\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"KO\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"abc\"", ")", ";", "List", "<", "String", ">", "answer", "=", "monQuizz", ".", "getAnswers", "(", "1", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "0", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "1", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "2", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "3", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "@", "Test", "public", "void", "exportMultichoice", "(", ")", "throws", "AttributNotFoundException", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz", ";", "try", "{", "monQuizz", "=", "pars", ".", "createQuizz", "(", ")", ";", "pars", ".", "exportQuizzMoodle", "(", "monQuizz", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "ParserQuizzMoodle", "pars2", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz2", ";", "try", "{", "monQuizz2", "=", "pars2", ".", "createQuizz", "(", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"name\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"questiontext\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"format\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"penalty\"", ")", ",", "\"0.1\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"defaultgrade\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"hidden\"", ")", ",", "\"0\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"image\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"image_base64\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"single\"", ")", ",", "\"false\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"OK\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"KO\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"abc\"", ")", ";", "List", "<", "String", ">", "answer", "=", "monQuizz2", ".", "getAnswers", "(", "1", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "0", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "1", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "2", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "3", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "</s>" ]
8,376
[ "<s>", "package", "dcll", ".", "tarti", ".", "tartiquizz", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "elementMoodle", ".", "QuizzMoodle", ";", "import", "exception", ".", "AttributNotFoundException", ";", "import", "exception", ".", "TypeQuestionNotFoundException", ";", "public", "class", "TrueFalseQuestionTest", "{", "@", "Test", "public", "void", "parserTrueFalse", "(", ")", "throws", "AttributNotFoundException", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz", ";", "try", "{", "monQuizz", "=", "pars", ".", "createQuizz", "(", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"name\"", ")", ",", "\"Vrai", "ou", "Faux\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"questiontext\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"format\"", ")", ",", "\"html\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"penalty\"", ")", ",", "\"0.6\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"defaultgrade\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"hidden\"", ")", ",", "\"0\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"image\"", ")", ",", "\"monImage.jpg\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"image_base64\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"1\"", ")", ";", "List", "<", "String", ">", "answer", "=", "monQuizz", ".", "getAnswers", "(", "1", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "0", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "1", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "@", "Test", "public", "void", "exportTrueFalse", "(", ")", "throws", "AttributNotFoundException", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz", ";", "try", "{", "monQuizz", "=", "pars", ".", "createQuizz", "(", ")", ";", "pars", ".", "exportQuizzMoodle", "(", "monQuizz", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "ParserQuizzMoodle", "pars2", "=", "new", "ParserQuizzMoodle", "(", "\"\"", ")", ";", "QuizzMoodle", "monQuizz2", ";", "try", "{", "monQuizz2", "=", "pars", ".", "createQuizz", "(", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"name\"", ")", ",", "\"Vrai", "ou", "Faux\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"questiontext\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"format\"", ")", ",", "\"html\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"penalty\"", ")", ",", "\"0.6\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"defaultgrade\"", ")", ",", "\"1\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"hidden\"", ")", ",", "\"0\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"image\"", ")", ",", "\"monImage.jpg\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"image_base64\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "monQuizz2", ".", "getAttributQuestion", "(", "1", ",", "\"\"", ")", ",", "\"1\"", ")", ";", "List", "<", "String", ">", "answer", "=", "monQuizz2", ".", "getAnswers", "(", "1", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "0", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "answer", ".", "get", "(", "1", ")", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "</s>" ]
8,377
[ "<s>", "package", "exception", ";", "public", "class", "AttributNotFoundException", "extends", "Exception", "{", "private", "String", "attribut", ";", "public", "AttributNotFoundException", "(", "String", "attribut", ")", "{", "super", "(", ")", ";", "this", ".", "attribut", "=", "attribut", ";", "}", "public", "String", "getMessage", "(", ")", "{", "return", "\"L'attribut", "\"", "+", "this", ".", "attribut", "+", "\"\"", ";", "}", "}", "</s>" ]
8,378
[ "<s>", "package", "exception", ";", "public", "class", "TypeQuestionNotFoundException", "extends", "Exception", "{", "private", "String", "type", ";", "public", "TypeQuestionNotFoundException", "(", "String", "type", ")", "{", "super", "(", ")", ";", "this", ".", "type", "=", "type", ";", "}", "@", "Override", "public", "String", "getMessage", "(", ")", "{", "return", "\"\"", "+", "this", ".", "type", "+", "\"\"", ";", "}", "}", "</s>" ]
8,379
[ "<s>", "package", "dcll", ".", "tarti", ".", "tartiquizz", ";", "import", "elementMoodle", ".", "QuizzMoodle", ";", "import", "exception", ".", "AttributNotFoundException", ";", "import", "exception", ".", "TypeQuestionNotFoundException", ";", "public", "class", "App", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "ParserQuizzMoodle", "pars", "=", "new", "ParserQuizzMoodle", "(", "\"quizz.xml\"", ")", ";", "QuizzMoodle", "monQuizz", ";", "try", "{", "monQuizz", "=", "pars", ".", "createQuizz", "(", ")", ";", "System", ".", "out", ".", "println", "(", "monQuizz", ")", ";", "pars", ".", "exportQuizzMoodle", "(", "monQuizz", ",", "\"\"", ")", ";", "}", "catch", "(", "TypeQuestionNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "</s>" ]
8,380
[ "<s>", "package", "dcll", ".", "tarti", ".", "tartiquizz", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "elementMoodle", ".", "QuizzMoodle", ";", "import", "exception", ".", "TypeQuestionNotFoundException", ";", "import", "org", ".", "jdom", ".", "Document", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "org", ".", "jdom", ".", "JDOMException", ";", "import", "org", ".", "jdom", ".", "input", ".", "SAXBuilder", ";", "import", "org", ".", "jdom", ".", "output", ".", "Format", ";", "import", "org", ".", "jdom", ".", "output", ".", "XMLOutputter", ";", "public", "class", "ParserQuizzMoodle", "{", "private", "Document", "doc", ";", "private", "Element", "racine", ";", "public", "ParserQuizzMoodle", "(", "String", "file", ")", "{", "SAXBuilder", "sxb", "=", "new", "SAXBuilder", "(", ")", ";", "try", "{", "doc", "=", "sxb", ".", "build", "(", "new", "File", "(", "file", ")", ")", ";", "}", "catch", "(", "JDOMException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "racine", "=", "doc", ".", "getRootElement", "(", ")", ";", "}", "public", "QuizzMoodle", "createQuizz", "(", ")", "throws", "TypeQuestionNotFoundException", "{", "QuizzMoodle", "quizz", "=", "null", ";", "quizz", "=", "new", "QuizzMoodle", "(", "this", ".", "racine", ")", ";", "return", "quizz", ";", "}", "public", "void", "exportQuizzMoodle", "(", "QuizzMoodle", "quizz", ",", "String", "file", ")", "{", "Document", "document", "=", "new", "Document", "(", "quizz", ".", "export", "(", ")", ")", ";", "try", "{", "XMLOutputter", "sortie", "=", "new", "XMLOutputter", "(", "Format", ".", "getPrettyFormat", "(", ")", ")", ";", "sortie", ".", "output", "(", "document", ",", "new", "FileOutputStream", "(", "file", ")", ")", ";", "}", "catch", "(", "java", ".", "io", ".", "IOException", "e", ")", "{", "}", "}", "public", "String", "getRacineName", "(", ")", "{", "return", "this", ".", "racine", ".", "getName", "(", ")", ";", "}", "}", "</s>" ]
8,381
[ "<s>", "package", "elementMoodle", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "org", ".", "jdom", ".", "Attribute", ";", "import", "exception", ".", "AttributNotFoundException", ";", "public", "class", "MultichoiceQuestion", "extends", "QuestionMoodle", "{", "private", "String", "single", ";", "private", "String", "shuffleanswers", ";", "private", "String", "correctfeedback", ";", "private", "String", "partiallycorrectfeedback", ";", "private", "String", "incorrectfeedback", ";", "private", "String", "answernumbering", ";", "private", "List", "<", "AnswerMoodle", ">", "answers", ";", "public", "MultichoiceQuestion", "(", "final", "Element", "element", ")", "{", "super", "(", "element", ")", ";", "if", "(", "element", ".", "getChildText", "(", "\"single\"", ")", "!=", "null", ")", "{", "this", ".", "single", "=", "element", ".", "getChildText", "(", "\"single\"", ")", ";", "}", "if", "(", "element", ".", "getChildText", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "shuffleanswers", "=", "element", ".", "getChildText", "(", "\"\"", ")", ";", "}", "if", "(", "element", ".", "getChildText", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "correctfeedback", "=", "element", ".", "getChild", "(", "\"\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "}", "if", "(", "element", ".", "getChildText", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "partiallycorrectfeedback", "=", "element", ".", "getChild", "(", "\"\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "}", "if", "(", "element", ".", "getChildText", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "incorrectfeedback", "=", "element", ".", "getChild", "(", "\"\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "}", "if", "(", "element", ".", "getChildText", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "answernumbering", "=", "element", ".", "getChildText", "(", "\"\"", ")", ";", "}", "answers", "=", "new", "ArrayList", "<", "AnswerMoodle", ">", "(", ")", ";", "List", "<", "Element", ">", "elementsAnswer", "=", "element", ".", "getChildren", "(", "\"answer\"", ")", ";", "for", "(", "Element", "currant", ":", "elementsAnswer", ")", "{", "answers", ".", "add", "(", "new", "AnswerMoodle", "(", "currant", ")", ")", ";", "}", "}", "@", "Override", "public", "final", "Element", "export", "(", ")", "{", "Element", "element", "=", "super", ".", "export", "(", ")", ";", "element", ".", "setAttribute", "(", "new", "Attribute", "(", "\"type\"", ",", "\"multichoice\"", ")", ")", ";", "if", "(", "this", ".", "shuffleanswers", "!=", "null", ")", "{", "Element", "tmp", "=", "new", "Element", "(", "\"\"", ")", ";", "tmp", ".", "setText", "(", "this", ".", "shuffleanswers", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "if", "(", "this", ".", "single", "!=", "null", ")", "{", "Element", "tmp", "=", "new", "Element", "(", "\"single\"", ")", ";", "tmp", ".", "setText", "(", "this", ".", "single", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "if", "(", "this", ".", "answernumbering", "!=", "null", ")", "{", "Element", "tmp", "=", "new", "Element", "(", "\"\"", ")", ";", "tmp", ".", "setText", "(", "this", ".", "answernumbering", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "for", "(", "AnswerMoodle", "current", ":", "this", ".", "answers", ")", "{", "Element", "tmp", "=", "current", ".", "export", "(", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "if", "(", "this", ".", "correctfeedback", "!=", "null", ")", "{", "Element", "text", "=", "new", "Element", "(", "\"text\"", ")", ";", "text", ".", "setText", "(", "this", ".", "correctfeedback", ")", ";", "Element", "tmp", "=", "new", "Element", "(", "\"\"", ")", ";", "tmp", ".", "addContent", "(", "text", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "if", "(", "this", ".", "partiallycorrectfeedback", "!=", "null", ")", "{", "Element", "text", "=", "new", "Element", "(", "\"text\"", ")", ";", "text", ".", "setText", "(", "this", ".", "partiallycorrectfeedback", ")", ";", "Element", "tmp", "=", "new", "Element", "(", "\"\"", ")", ";", "tmp", ".", "addContent", "(", "text", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "if", "(", "this", ".", "incorrectfeedback", "!=", "null", ")", "{", "Element", "text", "=", "new", "Element", "(", "\"text\"", ")", ";", "text", ".", "setText", "(", "this", ".", "incorrectfeedback", ")", ";", "Element", "tmp", "=", "new", "Element", "(", "\"\"", ")", ";", "tmp", ".", "addContent", "(", "text", ")", ";", "element", ".", "addContent", "(", "tmp", ")", ";", "}", "return", "element", ";", "}", "@", "Override", "public", "final", "String", "getAttribut", "(", "final", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "if", "(", "attribut", ".", "equals", "(", "\"single\"", ")", "&&", "this", ".", "single", "!=", "null", ")", "{", "return", "this", ".", "single", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "shuffleanswers", "!=", "null", ")", "{", "return", "this", ".", "shuffleanswers", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "correctfeedback", "!=", "null", ")", "{", "return", "this", ".", "correctfeedback", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "partiallycorrectfeedback", "!=", "null", ")", "{", "return", "this", ".", "partiallycorrectfeedback", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "incorrectfeedback", "!=", "null", ")", "{", "return", "this", ".", "incorrectfeedback", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "answernumbering", "!=", "null", ")", "{", "return", "this", ".", "answernumbering", ";", "}", "return", "super", ".", "getAttribut", "(", "attribut", ")", ";", "}", "@", "Override", "public", "final", "List", "<", "String", ">", "getAnswers", "(", ")", "{", "List", "<", "String", ">", "listAnswer", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "answer", ";", "for", "(", "AnswerMoodle", "currant", ":", "answers", ")", "{", "try", "{", "answer", "=", "currant", ".", "getAttribut", "(", "\"text\"", ")", "+", "\"", "=>", "\"", "+", "currant", ".", "getAttribut", "(", "\"feedback\"", ")", "+", "\"", "(\"", "+", "currant", ".", "getAttribut", "(", "\"fraction\"", ")", "+", "\")\"", ";", "listAnswer", ".", "add", "(", "answer", ")", ";", "}", "catch", "(", "AttributNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "listAnswer", ";", "}", "@", "Override", "public", "final", "String", "toString", "(", ")", "{", "int", "i", "=", "1", ";", "String", "mess", "=", "\"Multichoice", "\"", "+", "super", ".", "toString", "(", ")", ";", "for", "(", "AnswerMoodle", "currant", ":", "answers", ")", "{", "mess", "+=", "\"t\"", "+", "i", "+", "\".", "\"", "+", "currant", ";", "i", "++", ";", "}", "return", "mess", ";", "}", "}", "</s>" ]
8,382
[ "<s>", "package", "elementMoodle", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "jdom", ".", "Attribute", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "exception", ".", "AttributNotFoundException", ";", "public", "abstract", "class", "QuestionMoodle", "extends", "ElementMoodle", "{", "private", "String", "name", ";", "private", "String", "questiontext", ";", "private", "String", "format", ";", "private", "String", "penalty", ";", "private", "String", "generalfeedback", ";", "private", "String", "defaultgrade", ";", "private", "String", "hidden", ";", "private", "String", "image", ";", "private", "String", "image_base64", ";", "public", "QuestionMoodle", "(", "Element", "element", ")", "{", "super", "(", "element", ")", ";", "this", ".", "name", "=", "element", ".", "getChild", "(", "\"name\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "this", ".", "questiontext", "=", "element", ".", "getChild", "(", "\"questiontext\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "this", ".", "format", "=", "element", ".", "getChild", "(", "\"questiontext\"", ")", ".", "getAttributeValue", "(", "\"format\"", ")", ";", "if", "(", "element", ".", "getChild", "(", "\"penalty\"", ")", "!=", "null", ")", "{", "this", ".", "penalty", "=", "element", ".", "getChildText", "(", "\"penalty\"", ")", ";", "}", "if", "(", "element", ".", "getChild", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "generalfeedback", "=", "element", ".", "getChild", "(", "\"\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "}", "if", "(", "element", ".", "getChild", "(", "\"defaultgrade\"", ")", "!=", "null", ")", "{", "this", ".", "defaultgrade", "=", "element", ".", "getChildText", "(", "\"defaultgrade\"", ")", ";", "}", "if", "(", "element", ".", "getChild", "(", "\"hidden\"", ")", "!=", "null", ")", "{", "this", ".", "hidden", "=", "element", ".", "getChildText", "(", "\"hidden\"", ")", ";", "}", "if", "(", "element", ".", "getChild", "(", "\"image\"", ")", "!=", "null", ")", "{", "this", ".", "image", "=", "element", ".", "getChildText", "(", "\"image\"", ")", ";", "}", "if", "(", "element", ".", "getChild", "(", "\"image_base64\"", ")", "!=", "null", ")", "{", "this", ".", "image_base64", "=", "element", ".", "getChildText", "(", "\"image_base64\"", ")", ";", "}", "}", "public", "Element", "export", "(", ")", "{", "Element", "element", "=", "new", "Element", "(", "\"question\"", ")", ";", "Element", "name", "=", "new", "Element", "(", "\"name\"", ")", ";", "Element", "textName", "=", "new", "Element", "(", "\"text\"", ")", ";", "textName", ".", "setText", "(", "this", ".", "name", ")", ";", "name", ".", "addContent", "(", "textName", ")", ";", "element", ".", "addContent", "(", "name", ")", ";", "Element", "questiontext", "=", "new", "Element", "(", "\"questiontext\"", ")", ";", "questiontext", ".", "setAttribute", "(", "new", "Attribute", "(", "\"format\"", ",", "this", ".", "format", ")", ")", ";", "Element", "textQuestiontext", "=", "new", "Element", "(", "\"text\"", ")", ";", "textQuestiontext", ".", "setText", "(", "this", ".", "questiontext", ")", ";", "questiontext", ".", "addContent", "(", "textQuestiontext", ")", ";", "element", ".", "addContent", "(", "questiontext", ")", ";", "if", "(", "this", ".", "penalty", "!=", "null", ")", "{", "Element", "penalty", "=", "new", "Element", "(", "\"penalty\"", ")", ";", "penalty", ".", "setText", "(", "this", ".", "penalty", ")", ";", "element", ".", "addContent", "(", "penalty", ")", ";", "}", "if", "(", "this", ".", "generalfeedback", "!=", "null", ")", "{", "Element", "generalfeedback", "=", "new", "Element", "(", "\"\"", ")", ";", "Element", "textGeneralfeedback", "=", "new", "Element", "(", "\"text\"", ")", ";", "textGeneralfeedback", ".", "setText", "(", "this", ".", "generalfeedback", ")", ";", "generalfeedback", ".", "addContent", "(", "textGeneralfeedback", ")", ";", "element", ".", "addContent", "(", "generalfeedback", ")", ";", "}", "if", "(", "this", ".", "defaultgrade", "!=", "null", ")", "{", "Element", "defaultgrade", "=", "new", "Element", "(", "\"defaultgrade\"", ")", ";", "defaultgrade", ".", "setText", "(", "this", ".", "defaultgrade", ")", ";", "element", ".", "addContent", "(", "defaultgrade", ")", ";", "}", "if", "(", "this", ".", "hidden", "!=", "null", ")", "{", "Element", "hidden", "=", "new", "Element", "(", "\"hidden\"", ")", ";", "hidden", ".", "setText", "(", "this", ".", "hidden", ")", ";", "element", ".", "addContent", "(", "hidden", ")", ";", "}", "if", "(", "this", ".", "image", "!=", "null", ")", "{", "Element", "image", "=", "new", "Element", "(", "\"image\"", ")", ";", "image", ".", "setText", "(", "this", ".", "image", ")", ";", "element", ".", "addContent", "(", "image", ")", ";", "}", "if", "(", "this", ".", "image_base64", "!=", "null", ")", "{", "Element", "image_base64", "=", "new", "Element", "(", "\"image_base64\"", ")", ";", "image_base64", ".", "setText", "(", "this", ".", "image_base64", ")", ";", "element", ".", "addContent", "(", "image_base64", ")", ";", "}", "return", "element", ";", "}", "public", "String", "getAttribut", "(", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "if", "(", "attribut", ".", "equals", "(", "\"name\"", ")", ")", "{", "return", "this", ".", "name", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"questiontext\"", ")", ")", "{", "return", "this", ".", "questiontext", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"format\"", ")", ")", "{", "return", "this", ".", "format", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"penalty\"", ")", "&&", "this", ".", "penalty", "!=", "null", ")", "{", "return", "this", ".", "penalty", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "generalfeedback", "!=", "null", ")", "{", "return", "this", ".", "generalfeedback", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"defaultgrade\"", ")", "&&", "this", ".", "defaultgrade", "!=", "null", ")", "{", "return", "this", ".", "defaultgrade", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"hidden\"", ")", "&&", "this", ".", "hidden", "!=", "null", ")", "{", "return", "this", ".", "hidden", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"image\"", ")", "&&", "this", ".", "image", "!=", "null", ")", "{", "return", "this", ".", "image", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"image_base64\"", ")", "&&", "this", ".", "image_base64", "!=", "null", ")", "{", "return", "this", ".", "image_base64", ";", "}", "throw", "new", "AttributNotFoundException", "(", "attribut", ")", ";", "}", "public", "abstract", "List", "<", "String", ">", "getAnswers", "(", ")", ";", "public", "String", "toString", "(", ")", "{", "return", "\"Question:", "\"", "+", "this", ".", "name", "+", "\"n\"", "+", "questiontext", "+", "\"n\"", ";", "}", "}", "</s>" ]
8,383
[ "<s>", "package", "elementMoodle", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "jdom", ".", "Attribute", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "exception", ".", "AttributNotFoundException", ";", "public", "class", "TrueFalseQuestion", "extends", "QuestionMoodle", "{", "private", "String", "shuffleanswers", ";", "private", "List", "<", "AnswerMoodle", ">", "answers", ";", "public", "TrueFalseQuestion", "(", "final", "Element", "element", ")", "{", "super", "(", "element", ")", ";", "if", "(", "element", ".", "getChild", "(", "\"\"", ")", "!=", "null", ")", "{", "this", ".", "shuffleanswers", "=", "element", ".", "getChildText", "(", "\"\"", ")", ";", "}", "answers", "=", "new", "ArrayList", "<", "AnswerMoodle", ">", "(", ")", ";", "List", "<", "Element", ">", "answeelem", "=", "element", ".", "getChildren", "(", "\"answer\"", ")", ";", "for", "(", "Element", "currant", ":", "answeelem", ")", "{", "answers", ".", "add", "(", "new", "AnswerMoodle", "(", "currant", ")", ")", ";", "}", "}", "@", "Override", "public", "final", "Element", "export", "(", ")", "{", "Element", "element", "=", "super", ".", "export", "(", ")", ";", "element", ".", "setAttribute", "(", "new", "Attribute", "(", "\"type\"", ",", "\"truefalse\"", ")", ")", ";", "for", "(", "AnswerMoodle", "ans", ":", "answers", ")", "{", "element", ".", "addContent", "(", "ans", ".", "export", "(", ")", ")", ";", "}", "if", "(", "this", ".", "shuffleanswers", "!=", "null", ")", "{", "Element", "shuffleanswersE", "=", "new", "Element", "(", "\"\"", ")", ";", "shuffleanswersE", ".", "setText", "(", "this", ".", "shuffleanswers", ")", ";", "element", ".", "addContent", "(", "shuffleanswersE", ")", ";", "}", "return", "element", ";", "}", "@", "Override", "public", "final", "List", "<", "String", ">", "getAnswers", "(", ")", "{", "List", "<", "String", ">", "lisAnswer", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "res", "=", "null", ";", "for", "(", "AnswerMoodle", "courant", ":", "answers", ")", "{", "try", "{", "res", "=", "courant", ".", "getAttribut", "(", "\"text\"", ")", "+", "\"", "=>", "\"", "+", "courant", ".", "getAttribut", "(", "\"feedback\"", ")", "+", "\"", "(\"", "+", "courant", ".", "getAttribut", "(", "\"fraction\"", ")", "+", "\")\"", ";", "}", "catch", "(", "AttributNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "lisAnswer", ".", "add", "(", "res", ")", ";", "}", "return", "lisAnswer", ";", "}", "@", "Override", "public", "final", "String", "getAttribut", "(", "final", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "if", "(", "attribut", ".", "equals", "(", "\"\"", ")", "&&", "this", ".", "shuffleanswers", "!=", "null", ")", "{", "return", "shuffleanswers", ";", "}", "return", "super", ".", "getAttribut", "(", "attribut", ")", ";", "}", "@", "Override", "public", "final", "String", "toString", "(", ")", "{", "int", "i", "=", "1", ";", "String", "mess", "=", "\"TrueFalse", "\"", "+", "super", ".", "toString", "(", ")", ";", "for", "(", "AnswerMoodle", "currant", ":", "answers", ")", "{", "mess", "+=", "\"t\"", "+", "i", "+", "\".", "\"", "+", "currant", ";", "i", "++", ";", "}", "return", "mess", ";", "}", "}", "</s>" ]
8,384
[ "<s>", "package", "elementMoodle", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "org", ".", "jdom", ".", "filter", ".", "Filter", ";", "import", "exception", ".", "AttributNotFoundException", ";", "import", "exception", ".", "TypeQuestionNotFoundException", ";", "public", "class", "QuizzMoodle", "extends", "ElementMoodle", "{", "List", "<", "QuestionMoodle", ">", "questions", ";", "public", "QuizzMoodle", "(", "Element", "element", ")", "throws", "TypeQuestionNotFoundException", "{", "super", "(", "element", ")", ";", "this", ".", "questions", "=", "new", "ArrayList", "<", "QuestionMoodle", ">", "(", ")", ";", "Filter", "questionFilter", "=", "new", "Filter", "(", ")", "{", "public", "boolean", "matches", "(", "Object", "arg0", ")", "{", "boolean", "isQuestion", "=", "false", ";", "if", "(", "!", "(", "arg0", "instanceof", "Element", ")", ")", "{", "return", "false", ";", "}", "Element", "element", "=", "(", "Element", ")", "arg0", ";", "return", "!", "element", ".", "getAttributeValue", "(", "\"type\"", ")", ".", "equals", "(", "\"category\"", ")", ";", "}", "}", ";", "boolean", "typeNotFound", ";", "List", "<", "Element", ">", "elementsQuestion", "=", "element", ".", "getContent", "(", "questionFilter", ")", ";", "for", "(", "Element", "currant", ":", "elementsQuestion", ")", "{", "typeNotFound", "=", "true", ";", "if", "(", "currant", ".", "getAttributeValue", "(", "\"type\"", ")", ".", "equals", "(", "\"multichoice\"", ")", ")", "{", "questions", ".", "add", "(", "new", "MultichoiceQuestion", "(", "currant", ")", ")", ";", "typeNotFound", "=", "false", ";", "}", "if", "(", "currant", ".", "getAttributeValue", "(", "\"type\"", ")", ".", "equals", "(", "\"truefalse\"", ")", ")", "{", "questions", ".", "add", "(", "new", "TrueFalseQuestion", "(", "currant", ")", ")", ";", "typeNotFound", "=", "false", ";", "}", "if", "(", "typeNotFound", ")", "{", "throw", "new", "TypeQuestionNotFoundException", "(", "currant", ".", "getAttributeValue", "(", "\"type\"", ")", ")", ";", "}", "}", "}", "public", "Element", "export", "(", ")", "{", "Element", "element", "=", "new", "Element", "(", "\"quiz\"", ")", ";", "for", "(", "QuestionMoodle", "currant", ":", "questions", ")", "{", "element", ".", "addContent", "(", "currant", ".", "export", "(", ")", ")", ";", "}", "return", "element", ";", "}", "public", "String", "getAttributQuestion", "(", "int", "indexQuestion", ",", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "return", "this", ".", "questions", ".", "get", "(", "indexQuestion", "-", "1", ")", ".", "getAttribut", "(", "attribut", ")", ";", "}", "public", "List", "<", "String", ">", "getAnswers", "(", "int", "indexQuestion", ")", "{", "return", "questions", ".", "get", "(", "indexQuestion", "-", "1", ")", ".", "getAnswers", "(", ")", ";", "}", "@", "Override", "public", "String", "getAttribut", "(", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "throw", "new", "AttributNotFoundException", "(", "attribut", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "String", "listQuestion", "=", "\"\"", ";", "int", "i", "=", "1", ";", "for", "(", "QuestionMoodle", "currant", ":", "questions", ")", "{", "listQuestion", "+=", "i", "+", "\")", "\"", "+", "currant", "+", "\"n\"", ";", "i", "++", ";", "}", "return", "listQuestion", ";", "}", "}", "</s>" ]
8,385
[ "<s>", "package", "elementMoodle", ";", "import", "org", ".", "jdom", ".", "Attribute", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "exception", ".", "AttributNotFoundException", ";", "public", "class", "AnswerMoodle", "extends", "ElementMoodle", "{", "private", "String", "fraction", ";", "private", "String", "text", ";", "private", "String", "feedback", ";", "public", "AnswerMoodle", "(", "Element", "element", ")", "{", "super", "(", "element", ")", ";", "this", ".", "fraction", "=", "element", ".", "getAttributeValue", "(", "\"fraction\"", ")", ";", "this", ".", "text", "=", "element", ".", "getChildText", "(", "\"text\"", ")", ";", "this", ".", "feedback", "=", "element", ".", "getChild", "(", "\"feedback\"", ")", ".", "getChildText", "(", "\"text\"", ")", ";", "}", "@", "Override", "public", "Element", "export", "(", ")", "{", "Element", "element", "=", "new", "Element", "(", "\"answer\"", ")", ";", "element", ".", "setAttribute", "(", "new", "Attribute", "(", "\"fraction\"", ",", "this", ".", "fraction", ")", ")", ";", "Element", "text", "=", "new", "Element", "(", "\"text\"", ")", ";", "text", ".", "setText", "(", "this", ".", "text", ")", ";", "element", ".", "addContent", "(", "text", ")", ";", "Element", "feedback", "=", "new", "Element", "(", "\"feedback\"", ")", ";", "Element", "textFeedback", "=", "new", "Element", "(", "\"text\"", ")", ";", "textFeedback", ".", "setText", "(", "this", ".", "feedback", ")", ";", "feedback", ".", "addContent", "(", "textFeedback", ")", ";", "element", ".", "addContent", "(", "feedback", ")", ";", "return", "element", ";", "}", "@", "Override", "public", "String", "getAttribut", "(", "String", "attribut", ")", "throws", "AttributNotFoundException", "{", "if", "(", "attribut", ".", "equals", "(", "\"fraction\"", ")", "&&", "this", ".", "fraction", "!=", "null", ")", "{", "return", "this", ".", "fraction", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"text\"", ")", "&&", "this", ".", "text", "!=", "null", ")", "{", "return", "this", ".", "text", ";", "}", "if", "(", "attribut", ".", "equals", "(", "\"feedback\"", ")", "&&", "this", ".", "feedback", "!=", "null", ")", "{", "return", "this", ".", "feedback", ";", "}", "throw", "new", "AttributNotFoundException", "(", "attribut", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "this", ".", "text", "+", "\"n\"", ";", "}", "}", "</s>" ]
8,386
[ "<s>", "package", "elementMoodle", ";", "import", "org", ".", "jdom", ".", "Element", ";", "import", "exception", ".", "AttributNotFoundException", ";", "public", "abstract", "class", "ElementMoodle", "{", "public", "ElementMoodle", "(", "Element", "element", ")", "{", "}", "public", "abstract", "Element", "export", "(", ")", ";", "public", "abstract", "String", "getAttribut", "(", "String", "attribut", ")", "throws", "AttributNotFoundException", ";", "public", "abstract", "String", "toString", "(", ")", ";", "}", "</s>" ]
8,387
[ "<s>", "package", "me", ".", "NerdsWBNerds", ".", "SimpleWarps", ";", "import", "org", ".", "bukkit", ".", "Location", ";", "public", "class", "Warp", "{", "public", "String", "name", ";", "public", "Location", "location", ";", "public", "Warp", "(", "String", "s", ",", "Location", "l", ")", "{", "name", "=", "s", ";", "location", "=", "l", ";", "}", "}", "</s>" ]
8,388
[ "<s>", "package", "me", ".", "NerdsWBNerds", ".", "SimpleWarps", ";", "import", "org", ".", "bukkit", ".", "ChatColor", ";", "import", "org", ".", "bukkit", ".", "Material", ";", "import", "org", ".", "bukkit", ".", "block", ".", "Sign", ";", "import", "org", ".", "bukkit", ".", "entity", ".", "Player", ";", "import", "org", ".", "bukkit", ".", "event", ".", "EventHandler", ";", "import", "org", ".", "bukkit", ".", "event", ".", "Listener", ";", "import", "org", ".", "bukkit", ".", "event", ".", "block", ".", "Action", ";", "import", "org", ".", "bukkit", ".", "event", ".", "block", ".", "SignChangeEvent", ";", "import", "org", ".", "bukkit", ".", "event", ".", "player", ".", "PlayerInteractEvent", ";", "public", "class", "SWListener", "implements", "Listener", "{", "public", "SimpleWarps", "plugin", ";", "public", "SWListener", "(", "SimpleWarps", "p", ")", "{", "plugin", "=", "p", ";", "}", "@", "EventHandler", "public", "void", "onInteract", "(", "PlayerInteractEvent", "e", ")", "{", "if", "(", "e", ".", "getAction", "(", ")", "==", "Action", ".", "RIGHT_CLICK_BLOCK", ")", "{", "if", "(", "e", ".", "getClickedBlock", "(", ")", ".", "getType", "(", ")", "==", "Material", ".", "WALL_SIGN", "||", "e", ".", "getClickedBlock", "(", ")", ".", "getType", "(", ")", "==", "Material", ".", "SIGN_POST", "||", "e", ".", "getClickedBlock", "(", ")", ".", "getType", "(", ")", "==", "Material", ".", "SIGN", ")", "{", "Sign", "sign", "=", "(", "Sign", ")", "e", ".", "getClickedBlock", "(", ")", ".", "getState", "(", ")", ";", "if", "(", "ChatColor", ".", "stripColor", "(", "sign", ".", "getLine", "(", "0", ")", ")", ".", "equalsIgnoreCase", "(", "\"[SIMPLEWARP]\"", ")", "||", "ChatColor", ".", "stripColor", "(", "sign", ".", "getLine", "(", "0", ")", ")", ".", "equalsIgnoreCase", "(", "\"[SWARP]\"", ")", "||", "ChatColor", ".", "stripColor", "(", "sign", ".", "getLine", "(", "0", ")", ")", ".", "equalsIgnoreCase", "(", "\"[WARP]\"", ")", ")", "{", "String", "warp", "=", "ChatColor", ".", "stripColor", "(", "sign", ".", "getLine", "(", "1", ")", ")", ";", "if", "(", "!", "SimpleWarps", ".", "isWarp", "(", "warp", ")", ")", "{", "sign", ".", "setLine", "(", "0", ",", "ChatColor", ".", "DARK_RED", "+", "\"!ERROR!\"", ")", ";", "sign", ".", "setLine", "(", "1", ",", "\"warp", "does\"", ")", ";", "sign", ".", "setLine", "(", "2", ",", "\"not", "exist.\"", ")", ";", "sign", ".", "setLine", "(", "3", ",", "\"\"", ")", ";", "return", ";", "}", "if", "(", "!", "e", ".", "getPlayer", "(", ")", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "e", ".", "getPlayer", "(", ")", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", ";", "}", "if", "(", "e", ".", "getPlayer", "(", ")", ".", "hasPermission", "(", "\"\"", ")", "||", "e", ".", "getPlayer", "(", ")", ".", "hasPermission", "(", "\"\"", "+", "warp", ")", ")", "{", "e", ".", "getPlayer", "(", ")", ".", "teleport", "(", "SimpleWarps", ".", "getWarp", "(", "warp", ")", ".", "location", ")", ";", "e", ".", "getPlayer", "(", ")", ".", "sendMessage", "(", "SimpleWarps", ".", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "warp", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "}", "else", "{", "e", ".", "getPlayer", "(", ")", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "warp", ")", ";", "}", "}", "}", "}", "}", "@", "EventHandler", "public", "void", "onSignCreate", "(", "SignChangeEvent", "e", ")", "{", "Player", "player", "=", "e", ".", "getPlayer", "(", ")", ";", "if", "(", "e", ".", "getLine", "(", "0", ")", ".", "equalsIgnoreCase", "(", "\"[SIMPLEWARP]\"", ")", "||", "e", ".", "getLine", "(", "0", ")", ".", "equalsIgnoreCase", "(", "\"[SWARP]\"", ")", "||", "e", ".", "getLine", "(", "0", ")", ".", "equalsIgnoreCase", "(", "\"[WARP]\"", ")", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "e", ".", "setLine", "(", "0", ",", "ChatColor", ".", "DARK_RED", "+", "\"!ERROR!\"", ")", ";", "e", ".", "setLine", "(", "1", ",", "\"\"", ")", ";", "e", ".", "setLine", "(", "2", ",", "\"\"", ")", ";", "e", ".", "setLine", "(", "3", ",", "\"\"", ")", ";", "return", ";", "}", "if", "(", "!", "SimpleWarps", ".", "isWarp", "(", "e", ".", "getLine", "(", "1", ")", ")", ")", "{", "e", ".", "setLine", "(", "0", ",", "ChatColor", ".", "DARK_RED", "+", "\"!ERROR!\"", ")", ";", "e", ".", "setLine", "(", "1", ",", "\"this", "warp\"", ")", ";", "e", ".", "setLine", "(", "2", ",", "\"does", "not\"", ")", ";", "e", ".", "setLine", "(", "3", ",", "\"exist\"", ")", ";", "}", "else", "{", "e", ".", "setLine", "(", "0", ",", "ChatColor", ".", "WHITE", "+", "\"[SIMPLEWARP]\"", ")", ";", "e", ".", "setLine", "(", "1", ",", "ChatColor", ".", "BOLD", "+", "e", ".", "getLine", "(", "1", ")", ")", ";", "e", ".", "setLine", "(", "2", ",", "player", ".", "getName", "(", ")", ")", ";", "e", ".", "setLine", "(", "3", ",", "ChatColor", ".", "DARK_GRAY", "+", "e", ".", "getLine", "(", "3", ")", ")", ";", "player", ".", "sendMessage", "(", "SimpleWarps", ".", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", ")", ";", "}", "}", "}", "}", "</s>" ]
8,389
[ "<s>", "package", "me", ".", "NerdsWBNerds", ".", "SimpleWarps", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "ObjectInputStream", ";", "import", "java", ".", "io", ".", "ObjectOutputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "org", ".", "bukkit", ".", "Bukkit", ";", "import", "org", ".", "bukkit", ".", "ChatColor", ";", "import", "org", ".", "bukkit", ".", "Location", ";", "import", "org", ".", "bukkit", ".", "command", ".", "Command", ";", "import", "org", ".", "bukkit", ".", "command", ".", "CommandSender", ";", "import", "org", ".", "bukkit", ".", "entity", ".", "Player", ";", "import", "org", ".", "bukkit", ".", "plugin", ".", "java", ".", "JavaPlugin", ";", "public", "class", "SimpleWarps", "extends", "JavaPlugin", "{", "public", "Logger", "log", ";", "public", "static", "ArrayList", "<", "Warp", ">", "warps", "=", "new", "ArrayList", "<", "Warp", ">", "(", ")", ";", "public", "static", "String", "prefix", "=", "ChatColor", ".", "GOLD", "+", "\"\"", "+", "ChatColor", ".", "WHITE", ";", "public", "void", "onEnable", "(", ")", "{", "log", "=", "getServer", "(", ")", ".", "getLogger", "(", ")", ";", "getServer", "(", ")", ".", "getPluginManager", "(", ")", ".", "registerEvents", "(", "new", "SWListener", "(", "this", ")", ",", "this", ")", ";", "loadWarps", "(", ")", ";", "}", "public", "void", "onDisable", "(", ")", "{", "saveWarps", "(", ")", ";", "}", "public", "boolean", "onCommand", "(", "CommandSender", "sender", ",", "Command", "cmd", ",", "String", "label", ",", "String", "args", "[", "]", ")", "{", "if", "(", "sender", "instanceof", "Player", ")", "{", "Player", "player", "=", "(", "Player", ")", "sender", ";", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "\"warp\"", ")", ")", "{", "if", "(", "args", ".", "length", "==", "0", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "String", "list", "=", "\"\"", ";", "for", "(", "Warp", "w", ":", "warps", ")", "{", "list", "+=", "\"", "*\"", "+", "w", ".", "name", ";", "}", "player", ".", "sendMessage", "(", "ChatColor", ".", "DARK_AQUA", "+", "\"\"", ")", ";", "if", "(", "list", ".", "length", "(", ")", ">", "1", ")", "player", ".", "sendMessage", "(", "ChatColor", ".", "GREEN", "+", "list", ".", "substring", "(", "1", ")", ")", ";", "else", "player", ".", "sendMessage", "(", "ChatColor", ".", "GREEN", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "args", ".", "length", "==", "1", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "isWarp", "(", "args", "[", "0", "]", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "0", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", "+", "args", "[", "0", "]", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "0", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "player", ".", "teleport", "(", "getWarp", "(", "args", "[", "0", "]", ")", ".", "location", ")", ";", "player", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "0", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "return", "true", ";", "}", "if", "(", "args", ".", "length", "==", "2", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "Player", "target", "=", "getServer", "(", ")", ".", "getPlayer", "(", "args", "[", "0", "]", ")", ";", "if", "(", "target", "==", "null", "||", "!", "target", ".", "isOnline", "(", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "isWarp", "(", "args", "[", "1", "]", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "1", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", "+", "args", "[", "0", "]", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "1", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "target", ".", "teleport", "(", "getWarp", "(", "args", "[", "1", "]", ")", ".", "location", ")", ";", "player", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "target", ".", "getName", "(", ")", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "to", "the", "\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "1", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "target", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "1", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "return", "true", ";", "}", "}", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "\"setwarp\"", ")", "&&", "args", ".", "length", "==", "1", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "args", "[", "0", "]", ".", "length", "(", ")", ">", "13", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "isWarp", "(", "args", "[", "0", "]", ")", ")", "{", "getWarp", "(", "args", "[", "0", "]", ")", ".", "location", "=", "player", ".", "getLocation", "(", ")", ";", "}", "else", "{", "addWarp", "(", "args", "[", "0", "]", ",", "player", ".", "getLocation", "(", ")", ")", ";", "}", "player", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "0", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"\"", ")", ";", "saveWarps", "(", ")", ";", "return", "true", ";", "}", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "\"delwarp\"", ")", "&&", "args", ".", "length", "==", "1", ")", "{", "if", "(", "!", "player", ".", "hasPermission", "(", "\"\"", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "isWarp", "(", "args", "[", "0", "]", ")", ")", "{", "player", ".", "sendMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "0", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "removeWarp", "(", "args", "[", "0", "]", ")", ";", "player", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "0", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"\"", ")", ";", "saveWarps", "(", ")", ";", "return", "true", ";", "}", "}", "else", "{", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "\"warp\"", ")", ")", "{", "if", "(", "args", ".", "length", "==", "0", ")", "{", "String", "list", "=", "\"\"", ";", "for", "(", "Warp", "w", ":", "warps", ")", "{", "list", "+=", "\"", "*\"", "+", "w", ".", "name", ";", "}", "consoleMessage", "(", "ChatColor", ".", "DARK_AQUA", "+", "\"\"", ")", ";", "consoleMessage", "(", "ChatColor", ".", "GREEN", "+", "list", ".", "substring", "(", "1", ")", ")", ";", "return", "true", ";", "}", "if", "(", "args", ".", "length", "==", "2", ")", "{", "Player", "target", "=", "getServer", "(", ")", ".", "getPlayer", "(", "args", "[", "0", "]", ")", ";", "if", "(", "target", "==", "null", "||", "!", "target", ".", "isOnline", "(", ")", ")", "{", "consoleMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", ")", ";", "return", "true", ";", "}", "if", "(", "!", "isWarp", "(", "args", "[", "1", "]", ")", ")", "{", "consoleMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "1", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "target", ".", "teleport", "(", "getWarp", "(", "args", "[", "1", "]", ")", ".", "location", ")", ";", "consoleMessage", "(", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "target", ".", "getName", "(", ")", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "to", "the", "\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "1", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "target", ".", "sendMessage", "(", "prefix", "+", "ChatColor", ".", "GREEN", "+", "\"\"", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "1", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"", "warp.\"", ")", ";", "return", "true", ";", "}", "}", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "\"delwarp\"", ")", "&&", "args", ".", "length", "==", "1", ")", "{", "if", "(", "!", "isWarp", "(", "args", "[", "0", "]", ")", ")", "{", "consoleMessage", "(", "ChatColor", ".", "RED", "+", "\"\"", "+", "args", "[", "0", "]", "+", "\"\"", ")", ";", "return", "true", ";", "}", "removeWarp", "(", "args", "[", "0", "]", ")", ";", "consoleMessage", "(", "prefix", "+", "ChatColor", ".", "AQUA", "+", "\"'\"", "+", "args", "[", "0", "]", "+", "\"'\"", "+", "ChatColor", ".", "GREEN", "+", "\"\"", ")", ";", "saveWarps", "(", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "void", "consoleMessage", "(", "String", "m", ")", "{", "Bukkit", ".", "getConsoleSender", "(", ")", ".", "sendMessage", "(", "m", ")", ";", "}", "public", "static", "boolean", "isWarp", "(", "String", "s", ")", "{", "for", "(", "Warp", "w", ":", "warps", ")", "{", "if", "(", "w", ".", "name", ".", "equalsIgnoreCase", "(", "s", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "public", "static", "Warp", "getWarp", "(", "String", "s", ")", "{", "if", "(", "isWarp", "(", "s", ")", ")", "{", "for", "(", "Warp", "w", ":", "warps", ")", "{", "if", "(", "w", ".", "name", ".", "equalsIgnoreCase", "(", "s", ")", ")", "return", "w", ";", "}", "}", "return", "null", ";", "}", "public", "static", "void", "removeWarp", "(", "String", "s", ")", "{", "if", "(", "isWarp", "(", "s", ")", ")", "{", "warps", ".", "remove", "(", "getWarp", "(", "s", ")", ")", ";", "}", "}", "public", "static", "void", "addWarp", "(", "String", "s", ",", "Location", "l", ")", "{", "warps", ".", "add", "(", "new", "Warp", "(", "s", ",", "l", ")", ")", ";", "}", "public", "void", "saveWarps", "(", ")", "{", "String", "fName", "=", "\"warps.data\"", ";", "ArrayList", "<", "String", ">", "format", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "Warp", "w", ":", "warps", ")", "{", "String", "toAdd", "=", "w", ".", "name", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getWorld", "(", ")", ".", "getName", "(", ")", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getBlockX", "(", ")", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getBlockY", "(", ")", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getBlockZ", "(", ")", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getYaw", "(", ")", ";", "toAdd", "+=", "\",\"", "+", "w", ".", "location", ".", "getPitch", "(", ")", ";", "format", ".", "add", "(", "toAdd", ")", ";", "}", "File", "file", "=", "new", "File", "(", "\"\"", "+", "fName", ")", ";", "new", "File", "(", "\"plugins/\"", ")", ".", "mkdir", "(", ")", ";", "new", "File", "(", "\"\"", ")", ".", "mkdir", "(", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "try", "{", "file", ".", "createNewFile", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "try", "{", "ObjectOutputStream", "oos", "=", "new", "ObjectOutputStream", "(", "new", "FileOutputStream", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "oos", ".", "writeObject", "(", "format", ")", ";", "oos", ".", "flush", "(", ")", ";", "oos", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "loadWarps", "(", ")", "{", "String", "fName", "=", "\"warps.data\"", ";", "File", "file", "=", "new", "File", "(", "\"\"", "+", "fName", ")", ";", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "try", "{", "ObjectInputStream", "ois", "=", "new", "ObjectInputStream", "(", "new", "FileInputStream", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "Object", "result", "=", "ois", ".", "readObject", "(", ")", ";", "ois", ".", "close", "(", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "ArrayList", "<", "String", ">", "parse", "=", "(", "ArrayList", "<", "String", ">", ")", "result", ";", "for", "(", "String", "i", ":", "parse", ")", "{", "try", "{", "String", "[", "]", "args", "=", "i", ".", "split", "(", "\",\"", ")", ";", "Location", "warpL", "=", "new", "Location", "(", "getServer", "(", ")", ".", "getWorld", "(", "args", "[", "1", "]", ")", ",", "Integer", ".", "parseInt", "(", "args", "[", "2", "]", ")", ",", "Integer", ".", "parseInt", "(", "args", "[", "3", "]", ")", ",", "Integer", ".", "parseInt", "(", "args", "[", "4", "]", ")", ",", "Float", ".", "parseFloat", "(", "args", "[", "5", "]", ")", ",", "Float", ".", "parseFloat", "(", "args", "[", "6", "]", ")", ")", ";", "Warp", "warp", "=", "new", "Warp", "(", "args", "[", "0", "]", ",", "warpL", ")", ";", "warps", ".", "add", "(", "warp", ")", ";", "ois", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "}", "}", "</s>" ]
8,390
[ "<s>", "package", "org", ".", "wadael", ".", "gwtcleaner", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileFilter", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleActivator", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "public", "class", "Activator", "implements", "BundleActivator", "{", "static", "String", "[", "]", "GWT_PREFIXES", "=", "{", "\"uiBinder_\"", ",", "\"gwt\"", "}", ";", "static", "String", "FOLDER_TO_CLEAN", "=", "System", ".", "getProperty", "(", "\"\"", ")", ";", "FileFilter", "toBeDeletedFiles_fileFilter", "=", "new", "FileFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "file", ")", "{", "for", "(", "String", "prefix", ":", "GWT_PREFIXES", ")", "{", "if", "(", "file", ".", "getName", "(", ")", ".", "startsWith", "(", "prefix", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "}", ";", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "cleanGWTTempFiles", "(", ")", ";", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "cleanGWTTempFiles", "(", ")", ";", "}", "public", "void", "cleanGWTTempFiles", "(", ")", "{", "File", "toBeCleaned", "=", "new", "File", "(", "FOLDER_TO_CLEAN", ")", ";", "File", "[", "]", "extraFiles", "=", "toBeCleaned", ".", "listFiles", "(", "toBeDeletedFiles_fileFilter", ")", ";", "int", "counter", "=", "0", ";", "int", "errors", "=", "0", ";", "long", "sizesSum", "=", "0", ";", "for", "(", "File", "erase", ":", "extraFiles", ")", "{", "long", "size", "=", "erase", ".", "length", "(", ")", ";", "if", "(", "erase", ".", "delete", "(", ")", ")", "{", "sizesSum", "+=", "size", ";", "counter", "++", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"Error", "on", "\"", "+", "erase", ".", "getName", "(", ")", ")", ";", "errors", "++", ";", "}", "}", "System", ".", "out", ".", "println", "(", "\"\"", "+", "counter", "+", "\"\"", "+", "(", "sizesSum", "/", "(", "1024", "*", "1024", ")", ")", "+", "\"MB", "(errors:", "\"", "+", "errors", "+", "\"\"", ")", ";", "}", "}", "</s>" ]
8,391
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2otis", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "*", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "class", "OtisModelWriter", "extends", "OtisWriter", "{", "BlockArrayList", "inputBlocks", ";", "BlockArrayList", "outputBlocks", ";", "int", "nextCalVarNumber", ";", "String", "CLdef", ";", "String", "CDdef", ";", "String", "Cmdef", ";", "static", "final", "int", "MAX_COMMENT_LENGTH", "=", "72", ";", "public", "OtisModelWriter", "(", "Model", "theModel", ",", "String", "sourceFileName", ")", "throws", "IOException", "{", "super", "(", "theModel", ",", "sourceFileName", ")", ";", "inputBlocks", "=", "new", "BlockArrayList", "(", "10", ")", ";", "outputBlocks", "=", "new", "BlockArrayList", "(", "10", ")", ";", "nextCalVarNumber", "=", "1", ";", "CLdef", "=", "null", ";", "CDdef", "=", "null", ";", "Cmdef", "=", "null", ";", "}", "public", "void", "writeln", "(", "String", "cbuf", ")", "throws", "IOException", "{", "super", ".", "write", "(", "cbuf", "+", "\"n\"", ")", ";", "}", "public", "void", "writeModel", "(", "BlockArrayList", "sortedBlocks", ",", "String", "modelName", ")", "throws", "IOException", "{", "CodeAndVarNames", "cvn", "=", "new", "CodeAndVarNames", "(", ")", ";", "Iterator", "<", "Block", ">", "blkIt", ";", "Block", "blk", ";", "ourModel", ".", "setCodeDialect", "(", "Model", ".", "DT_FORTRAN", ")", ";", "blkIt", "=", "sortedBlocks", ".", "iterator", "(", ")", ";", "while", "(", "blkIt", ".", "hasNext", "(", ")", ")", "{", "blk", "=", "blkIt", ".", "next", "(", ")", ";", "boolean", "skip", "=", "false", ";", "if", "(", "blk", "instanceof", "BlockLimiter", "||", "blk", "instanceof", "BlockMathSwitch", ")", "blk", ".", "getOutput", "(", ")", ".", "clearDerivedFlag", "(", ")", ";", "Signal", "outSig", "=", "blk", ".", "getOutput", "(", ")", ";", "if", "(", "outSig", "!=", "null", ")", "if", "(", "outSig", ".", "isDerived", "(", ")", ")", "{", "skip", "=", "true", ";", "}", "if", "(", "blk", "instanceof", "BlockBP", ")", "{", "}", "else", "if", "(", "blk", "instanceof", "BlockInput", ")", "{", "inputBlocks", ".", "add", "(", "blk", ")", ";", "translateInputBlockVarID", "(", "blk", ")", ";", "skip", "=", "true", ";", "}", "else", "if", "(", "blk", "instanceof", "BlockOutput", ")", "{", "outputBlocks", ".", "add", "(", "blk", ")", ";", "translateOutputBlockVarID", "(", "blk", ")", ";", "skip", "=", "true", ";", "}", "else", "if", "(", "blk", "instanceof", "BlockFuncTable", ")", "{", "cvn", ".", "appendCode", "(", "this", ".", "generateTableCall", "(", "(", "BlockFuncTable", ")", "blk", ")", ")", ";", "}", "else", "{", "if", "(", "!", "skip", ")", "cvn", ".", "append", "(", "blk", ".", "genCode", "(", ")", ")", ";", "}", "}", "writeModelHeader", "(", "modelName", ")", ";", "writeAsOtisCalc", "(", "cvn", ".", "getCode", "(", ")", ")", ";", "writeModelFooter", "(", "modelName", ",", "\"17000.\"", ",", "\"323.27\"", ")", ";", "}", "private", "String", "generateTableCall", "(", "BlockFuncTable", "bft", ")", "{", "String", "outVarID", "=", "bft", ".", "getOutputVarID", "(", ")", ";", "return", "outVarID", "+", "\"=TAB(\"", "+", "outVarID", "+", "\")n\"", ";", "}", "void", "writeModelHeader", "(", "String", "modelName", ")", "{", "try", "{", "writeln", "(", "\"!", "\"", "+", "modelName", "+", "\"\"", ")", ";", "writeln", "(", "\"$OTISIN\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!", "\"", ")", ";", "writeln", "(", "\"!", "Output\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "int", "xparNumber", "=", "1", ";", "Iterator", "<", "Block", ">", "blkIt", "=", "inputBlocks", ".", "iterator", "(", ")", ";", "while", "(", "blkIt", ".", "hasNext", "(", ")", ")", "{", "Block", "inputBlk", "=", "blkIt", ".", "next", "(", ")", ";", "Signal", "theSignal", "=", "inputBlk", ".", "getOutput", "(", ")", ";", "if", "(", "!", "theSignal", ".", "isMarked", "(", ")", ")", "{", "writeln", "(", "\"!", "\"", "+", "theSignal", ".", "getVarID", "(", ")", ".", "trim", "(", ")", "+", "\"", "(\"", "+", "theSignal", ".", "getName", "(", ")", ".", "trim", "(", ")", "+", "\"):\"", ")", ";", "String", "description", "=", "theSignal", ".", "getDescription", "(", ")", ".", "trim", "(", ")", ";", "while", "(", "description", ".", "length", "(", ")", ">", "(", "MAX_COMMENT_LENGTH", "-", "4", ")", ")", "{", "int", "finalSpace", "=", "description", ".", "lastIndexOf", "(", "\"", "\"", ")", ";", "writeln", "(", "\"!", "\"", "+", "description", ".", "substring", "(", "0", ",", "finalSpace", ")", ")", ";", "description", "=", "description", ".", "substring", "(", "finalSpace", "+", "1", ")", ";", "}", "writeln", "(", "\"!", "\"", "+", "description", ")", ";", "writeln", "(", "\"!\"", ")", ";", "String", "icVal", "=", "\"0.0\"", ";", "if", "(", "theSignal", ".", "hasIC", "(", ")", ")", "icVal", "=", "theSignal", ".", "getIC", "(", ")", ";", "writeln", "(", "\"xpar(\"", "+", "xparNumber", "+", "\")=\"", "+", "icVal", ")", ";", "writeln", "(", "\"!\"", ")", ";", "xparNumber", "++", ";", "}", "}", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "blkIt", "=", "inputBlocks", ".", "iterator", "(", ")", ";", "while", "(", "blkIt", ".", "hasNext", "(", ")", ")", "{", "Block", "inputBlk", "=", "blkIt", ".", "next", "(", ")", ";", "Signal", "theSignal", "=", "inputBlk", ".", "getOutput", "(", ")", ";", "if", "(", "!", "theSignal", ".", "isMarked", "(", ")", ")", "{", "writeln", "(", "\"cal(\"", "+", "nextCalVarNumber", "+", "\")='DEF=XPAR(\"", "+", "nextCalVarNumber", "+", "\"):NAM=\"", "+", "theSignal", ".", "getVarID", "(", ")", ".", "trim", "(", ")", "+", "\":LOC=10',\"", ")", ";", "nextCalVarNumber", "++", ";", "}", "}", "writeln", "(", "\"!\"", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "Logger", ".", "getLogger", "(", "OtisModelWriter", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "}", "}", "private", "void", "writeAsOtisCalc", "(", "String", "codeBody", ")", "throws", "IOException", "{", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "String", "lines", "[", "]", "=", "null", ";", "try", "{", "lines", "=", "convertIfBlocks", "(", "codeBody", ")", ";", "}", "catch", "(", "DAVEException", "ex", ")", "{", "Logger", ".", "getLogger", "(", "OtisModelWriter", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "int", "numLines", "=", "lines", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numLines", ";", "i", "++", ")", "{", "String", "equationParts", "[", "]", "=", "lines", "[", "i", "]", ".", "split", "(", "\"=\"", ")", ";", "if", "(", "equationParts", ".", "length", "!=", "2", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "lines", "[", "i", "]", ")", ";", "}", "else", "{", "boolean", "skip", "=", "false", ";", "String", "varName", "=", "equationParts", "[", "0", "]", ";", "String", "rhs", "=", "equationParts", "[", "1", "]", ";", "if", "(", "varName", ".", "equals", "(", "\"CL\"", ")", ")", "{", "CLdef", "=", "rhs", ";", "skip", "=", "true", ";", "}", "if", "(", "varName", ".", "equals", "(", "\"CD\"", ")", ")", "{", "CDdef", "=", "rhs", ";", "skip", "=", "true", ";", "}", "if", "(", "varName", ".", "equals", "(", "\"CM\"", ")", ")", "{", "Cmdef", "=", "rhs", ";", "skip", "=", "true", ";", "}", "if", "(", "varName", ".", "equals", "(", "\"MACH\"", ")", ")", "{", "skip", "=", "true", ";", "}", "if", "(", "!", "skip", ")", "{", "writeln", "(", "\"cal(\"", "+", "nextCalVarNumber", "+", "\")='NAM=\"", "+", "varName", "+", "\":def=\"", "+", "rhs", "+", "\":LOC=10',\"", ")", ";", "nextCalVarNumber", "+=", "1", ";", "}", "}", "}", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "}", "private", "String", "[", "]", "convertIfBlocks", "(", "String", "codeBody", ")", "throws", "DAVEException", "{", "String", "line", "[", "]", "=", "codeBody", ".", "replace", "(", "\"", "\"", ",", "\"\"", ")", ".", "split", "(", "\"n\"", ")", ";", "ArrayList", "<", "String", ">", "outLines", "=", "new", "ArrayList", "<", "String", ">", "(", "50", ")", ";", "String", "parts", "[", "]", ";", "String", "newLine", "=", "\"\"", ";", "int", "numLines", "=", "line", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "(", "numLines", "-", "3", ")", ";", "i", "++", ")", "{", "if", "(", "(", "line", "[", "i", "+", "1", "]", ".", "startsWith", "(", "\"IF\"", ")", ")", "&&", "(", "line", "[", "i", "+", "3", "]", ".", "startsWith", "(", "\"ENDIF\"", ")", ")", ")", "{", "parts", "=", "line", "[", "i", "]", ".", "split", "(", "\"=\"", ")", ";", "if", "(", "parts", ".", "length", "!=", "2", ")", "throw", "new", "DAVEException", "(", "\"line", "\"", "+", "i", "+", "\"\"", "+", "line", "[", "i", "]", ")", ";", "String", "varname", "=", "parts", "[", "0", "]", ";", "String", "z", "=", "parts", "[", "1", "]", ";", "parts", "=", "line", "[", "i", "+", "1", "]", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "parts", ".", "length", "!=", "3", ")", "throw", "new", "DAVEException", "(", "\"line", "\"", "+", "(", "i", "+", "1", ")", "+", "\"\"", "+", "line", "[", "i", "+", "1", "]", ")", ";", "String", "a", "=", "parts", "[", "0", "]", ".", "replace", "(", "\"IF((\"", ",", "\"\"", ")", ";", "String", "test", "=", "parts", "[", "1", "]", ";", "String", "b", "=", "parts", "[", "2", "]", ".", "replace", "(", "\"))THEN\"", ",", "\"\"", ")", ";", "String", "relTest", "=", "\"><\"", ";", "if", "(", "test", ".", "equals", "(", "\"LT\"", ")", ")", "relTest", "=", "\"<\"", ";", "if", "(", "test", ".", "equals", "(", "\"LE\"", ")", ")", "relTest", "=", "\"<=\"", ";", "if", "(", "test", ".", "equals", "(", "\"EQ\"", ")", ")", "relTest", "=", "\"==\"", ";", "if", "(", "test", ".", "equals", "(", "\"GE\"", ")", ")", "relTest", "=", "\">=\"", ";", "if", "(", "test", ".", "equals", "(", "\"GT\"", ")", ")", "relTest", "=", "\">\"", ";", "if", "(", "test", ".", "equals", "(", "\"NE\"", ")", ")", "relTest", "=", "\"!=\"", ";", "String", "x", "=", "a", "+", "relTest", "+", "b", ";", "parts", "=", "line", "[", "i", "+", "2", "]", ".", "split", "(", "\"=\"", ")", ";", "if", "(", "parts", ".", "length", "!=", "2", ")", "throw", "new", "DAVEException", "(", "\"line", "\"", "+", "(", "i", "+", "2", ")", "+", "\"\"", "+", "line", "[", "i", "+", "2", "]", ")", ";", "String", "y", "=", "parts", "[", "1", "]", ";", "newLine", "+=", "x", "+", "\",\"", "+", "y", ";", "newLine", "=", "varname", "+", "\"=IF(\"", "+", "x", "+", "\",\"", "+", "y", "+", "\",\"", "+", "z", "+", "\")\"", ";", "outLines", ".", "add", "(", "newLine", ")", ";", "i", "=", "i", "+", "3", ";", "}", "else", "{", "outLines", ".", "add", "(", "line", "[", "i", "]", ")", ";", "}", "}", "outLines", ".", "add", "(", "line", "[", "numLines", "-", "3", "]", ")", ";", "outLines", ".", "add", "(", "line", "[", "numLines", "-", "2", "]", ")", ";", "outLines", ".", "add", "(", "line", "[", "numLines", "-", "1", "]", ")", ";", "return", "outLines", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}", "private", "void", "writeModelFooter", "(", "String", "vehicleName", ",", "String", "vehicleWeight", ",", "String", "vehicleRefArea", ")", "{", "try", "{", "writeln", "(", "\"$END\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"$PHASIN\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"ph_type='E',\"", ")", ";", "writeln", "(", "\"ph_title='\"", "+", "vehicleName", "+", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"cb_flat=0.,\"", ")", ";", "writeln", "(", "\"cb_rot=0.,\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"sref='def=\"", "+", "vehicleRefArea", "+", "\"',\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "int", "aeroNumber", "=", "1", ";", "if", "(", "CLdef", "!=", "null", ")", "{", "writeln", "(", "\"aero(\"", "+", "aeroNumber", "+", "\"\"", "+", "CLdef", "+", "\"',\"", ")", ";", "aeroNumber", "++", ";", "}", "if", "(", "CLdef", "!=", "null", ")", "{", "writeln", "(", "\"aero(\"", "+", "aeroNumber", "+", "\"\"", "+", "CDdef", "+", "\"',\"", ")", ";", "aeroNumber", "++", ";", "}", "if", "(", "Cmdef", "!=", "null", ")", "{", "writeln", "(", "\"aero(\"", "+", "aeroNumber", "+", "\"\"", "+", "Cmdef", "+", "\"',\"", ")", ";", "aeroNumber", "++", ";", "}", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"eqm_type=2,\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"ic_type=2,\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", "+", "vehicleWeight", "+", "\"',\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!", "\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"!", "\"", ")", ";", "writeln", "(", "\"$END\"", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "Logger", ".", "getLogger", "(", "OtisModelWriter", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "}", "}", "private", "void", "translateInputBlockVarID", "(", "Block", "blk", ")", "{", "String", "dmlVarID", "=", "blk", ".", "getOutputVarID", "(", ")", ";", "if", "(", "this", ".", "needsTranslation", "(", "dmlVarID", ")", ")", "{", "String", "otisVarID", "=", "this", ".", "translate", "(", "dmlVarID", ")", ";", "Signal", "sig", "=", "blk", ".", "getOutput", "(", ")", ";", "sig", ".", "mark", "(", ")", ";", "sig", ".", "setVarID", "(", "otisVarID", ")", ";", "}", "}", "private", "void", "translateOutputBlockVarID", "(", "Block", "blk", ")", "{", "Signal", "inputSig", "=", "blk", ".", "getInput", "(", "0", ")", ";", "String", "dmlVarID", "=", "inputSig", ".", "getVarID", "(", ")", ";", "if", "(", "this", ".", "needsTranslation", "(", "dmlVarID", ")", ")", "{", "String", "otisVarID", "=", "this", ".", "translate", "(", "dmlVarID", ")", ";", "inputSig", ".", "mark", "(", ")", ";", "inputSig", ".", "setVarID", "(", "otisVarID", ")", ";", "}", "}", "}", "</s>" ]
8,392
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2otis", ";", "</s>" ]
8,393
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2otis", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "Model", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "Signal", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "abstract", "class", "OtisWriter", "extends", "FileWriter", "{", "Map", "<", "String", ",", "String", ">", "idMap", ";", "Model", "ourModel", ";", "public", "OtisWriter", "(", "Model", "theModel", ",", "String", "tableFileName", ")", "throws", "IOException", "{", "super", "(", "tableFileName", ")", ";", "ourModel", "=", "theModel", ";", "}", "protected", "String", "translate", "(", "String", "varID", ")", "{", "String", "output", "=", "varID", ";", "if", "(", "idMap", "==", "null", ")", "this", ".", "setupMap", "(", ")", ";", "Signal", "signal", "=", "ourModel", ".", "getSignals", "(", ")", ".", "findByID", "(", "varID", ")", ";", "if", "(", "signal", ".", "isStdAIAA", "(", ")", ")", "{", "String", "aiaaName", "=", "this", ".", "getAIAAName", "(", "signal", ")", ";", "String", "otisName", "=", "idMap", ".", "get", "(", "aiaaName", ")", ";", "if", "(", "otisName", "!=", "null", ")", "{", "output", "=", "otisName", ";", "}", "}", "return", "output", ";", "}", "private", "void", "setupMap", "(", ")", "{", "idMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"ALPHA\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"ALPHAD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"BETA\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"BETAD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"CD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"CL\"", ")", ";", "idMap", ".", "put", "(", "\"mach\"", ",", "\"MACH\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"PHIG\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"PHIGD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"PSIG\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"PSIGD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"Q\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"THETG\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"THETGD\"", ")", ";", "idMap", ".", "put", "(", "\"\"", ",", "\"VEL\"", ")", ";", "}", "private", "String", "getAIAAName", "(", "Signal", "signal", ")", "{", "String", "varName", "=", "signal", ".", "getName", "(", ")", ";", "String", "units", "=", "signal", ".", "getUnits", "(", ")", ";", "String", "aiaaName", "=", "varName", ";", "String", "axisName", "=", "\"\"", ";", "int", "underbar", "=", "varName", ".", "indexOf", "(", "\"_\"", ")", ";", "int", "varNameLen", "=", "varName", ".", "length", "(", ")", ";", "if", "(", "underbar", ">", "0", ")", "{", "axisName", "=", "varName", ".", "substring", "(", "underbar", ",", "(", "varNameLen", "-", "underbar", ")", ")", ";", "aiaaName", "=", "varName", ".", "substring", "(", "underbar", ")", ";", "}", "if", "(", "!", "units", ".", "equalsIgnoreCase", "(", "\"nd\"", ")", ")", "{", "aiaaName", "=", "varName", "+", "\"_\"", "+", "units", ";", "}", "aiaaName", "+=", "axisName", ";", "return", "aiaaName", ";", "}", "public", "String", "normalize", "(", "String", "input", ")", "{", "if", "(", "input", "!=", "null", ")", "{", "input", "=", "input", ".", "replace", "(", "'\\n'", ",", "'", "'", ")", ";", "input", "=", "input", ".", "replace", "(", "'\\t'", ",", "'", "'", ")", ";", "input", "=", "input", ".", "replace", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "input", "=", "input", ".", "replace", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "}", "return", "input", ";", "}", "public", "boolean", "needsTranslation", "(", "String", "varID", ")", "{", "String", "output", "=", "varID", ";", "if", "(", "idMap", "==", "null", ")", "this", ".", "setupMap", "(", ")", ";", "Signal", "signal", "=", "ourModel", ".", "getSignals", "(", ")", ".", "findByID", "(", "varID", ")", ";", "if", "(", "signal", ".", "isStdAIAA", "(", ")", ")", "{", "String", "aiaaName", "=", "this", ".", "getAIAAName", "(", "signal", ")", ";", "String", "otisName", "=", "idMap", ".", "get", "(", "aiaaName", ")", ";", "if", "(", "otisName", "!=", "null", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", "</s>" ]
8,394
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2otis", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "*", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "class", "OtisTableWriter", "extends", "OtisWriter", "{", "int", "tableNumber", ",", "tableRefNumber", ";", "int", "lineWrapLen", ";", "BlockFuncTable", "bft", ";", "FuncTable", "ft", ";", "String", "outVarID", ";", "String", "outOtisName", ";", "String", "indent", ";", "int", "[", "]", "dims", ";", "int", "[", "]", "coords", ";", "int", "numDims", ";", "public", "OtisTableWriter", "(", "Model", "theModel", ",", "String", "tableFileName", ")", "throws", "IOException", "{", "super", "(", "theModel", ",", "tableFileName", ")", ";", "indent", "=", "\"\"", ";", "lineWrapLen", "=", "72", ";", "ft", "=", "null", ";", "outVarID", "=", "\"\"", ";", "outOtisName", "=", "\"\"", ";", "dims", "=", "null", ";", "numDims", "=", "-", "1", ";", "idMap", "=", "null", ";", "}", "private", "void", "writeln", "(", "String", "cbuf", ")", "throws", "IOException", "{", "super", ".", "write", "(", "cbuf", "+", "\"n\"", ")", ";", "}", "private", "void", "writeln", "(", ")", "throws", "IOException", "{", "this", ".", "writeln", "(", "\"\"", ")", ";", "}", "void", "generateTableDescription", "(", ")", "{", "ft", "=", "bft", ".", "getFunctionTableDef", "(", ")", ";", "outVarID", "=", "bft", ".", "getOutputVarID", "(", ")", ";", "outOtisName", "=", "outVarID", ";", "dims", "=", "ft", ".", "getDimensions", "(", ")", ";", "numDims", "=", "dims", ".", "length", ";", "try", "{", "this", ".", "writeTable", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "Logger", ".", "getLogger", "(", "OtisTableWriter", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "}", "}", "private", "void", "writeTable", "(", ")", "throws", "IOException", "{", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "indent", "+", "outVarID", ")", ";", "writeln", "(", "\"*", "Table", "name\"", ")", ";", "writeln", "(", "indent", "+", "outOtisName", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "indent", "+", "\"1.0\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "String", "descr", "=", "bft", ".", "getDescription", "(", ")", ";", "this", ".", "writeTextComment", "(", "normalize", "(", "descr", ")", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "indent", "+", "\"1\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "writeln", "(", "indent", "+", "\"NCOEF1\"", ")", ";", "write", "(", "indent", "+", "\"\"", ")", ";", "if", "(", "numDims", "==", "1", ")", "write", "(", "\"one", "thing:", "\"", ")", ";", "else", "write", "(", "numDims", "+", "\"", "things:", "\"", ")", ";", "for", "(", "int", "dim", "=", "numDims", ";", "dim", ">=", "1", ";", "dim", "--", ")", "{", "write", "(", "bft", ".", "getVarID", "(", "dim", ")", ")", ";", "if", "(", "dim", ">", "2", ")", "write", "(", "\",", "\"", ")", ";", "if", "(", "dim", "==", "2", ")", "write", "(", "\"", "and", "\"", ")", ";", "}", "writeln", "(", ")", ";", "writeln", "(", "indent", "+", "numDims", ")", ";", "this", ".", "writeIndependentValues", "(", ")", ";", "this", ".", "writeDependentValues", "(", ")", ";", "writeln", "(", "\"*\"", ")", ";", "writeln", "(", "\"\"", ")", ";", "}", "private", "void", "writeIndependentValues", "(", ")", "throws", "IOException", "{", "for", "(", "int", "dim", "=", "numDims", ";", "dim", ">=", "1", ";", "dim", "--", ")", "{", "String", "inVarID", "=", "bft", ".", "getVarID", "(", "dim", ")", ";", "String", "inOtisName", "=", "inVarID", ";", "String", "bpID", "=", "ft", ".", "getBPID", "(", "dim", ")", ";", "ArrayList", "<", "Double", ">", "bps", "=", "ourModel", ".", "getBPSetByID", "(", "bpID", ")", ".", "values", "(", ")", ";", "Iterator", "<", "Double", ">", "bpIt", "=", "bps", ".", "iterator", "(", ")", ";", "writeln", "(", "indent", "+", "inOtisName", ")", ";", "writeln", "(", "indent", "+", "\"*", "number", "of", "\"", "+", "inOtisName", "+", "\"s\"", ")", ";", "writeln", "(", "indent", "+", "bps", ".", "size", "(", ")", ")", ";", "writeln", "(", "indent", "+", "\"*", "\"", "+", "inOtisName", "+", "\"", "values\"", ")", ";", "String", "origIndent", "=", "indent", ";", "indent", "=", "indent", "+", "\"", "\"", ";", "String", "buffer", "=", "indent", ";", "while", "(", "bpIt", ".", "hasNext", "(", ")", ")", "{", "double", "breakpointVal", "=", "bpIt", ".", "next", "(", ")", ";", "String", "testBuffer", "=", "buffer", "+", "breakpointVal", "+", "\"", "\"", ";", "if", "(", "testBuffer", ".", "length", "(", ")", ">", "lineWrapLen", ")", "{", "writeln", "(", "buffer", ")", ";", "buffer", "=", "indent", "+", "breakpointVal", "+", "\"", "\"", ";", "}", "else", "{", "buffer", "=", "testBuffer", ";", "}", "}", "writeln", "(", "buffer", ")", ";", "indent", "=", "origIndent", ";", "}", "}", "private", "void", "writeDependentValues", "(", ")", "throws", "IOException", "{", "ArrayList", "<", "Double", ">", "pts", "=", "ft", ".", "getValues", "(", ")", ";", "Iterator", "<", "Double", ">", "ptIt", "=", "pts", ".", "iterator", "(", ")", ";", "coords", "=", "dims", ".", "clone", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "coords", ".", "length", ";", "i", "++", ")", "{", "coords", "[", "i", "]", "=", "0", ";", "}", "write", "(", "indent", "+", "\"*", "\"", "+", "outOtisName", "+", "\"", "values\"", ")", ";", "if", "(", "numDims", ">", "1", ")", "writeln", "(", "\"\"", "+", "bft", ".", "getVarID", "(", "numDims", ")", ")", ";", "else", "writeln", "(", ")", ";", "writeIndepValsWithHdr", "(", "ptIt", ",", "1", ")", ";", "}", "private", "void", "writeIndepValsWithHdr", "(", "Iterator", "<", "Double", ">", "ptIt", ",", "int", "dim", ")", "throws", "IOException", "{", "if", "(", "dim", "<", "numDims", ")", "{", "String", "bpID", "=", "ft", ".", "getBPID", "(", "dim", ")", ";", "ArrayList", "<", "Double", ">", "bps", "=", "ourModel", ".", "getBPSetByID", "(", "bpID", ")", ".", "values", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bps", ".", "size", "(", ")", ";", "i", "++", ")", "{", "coords", "[", "dim", "]", "=", "i", ";", "double", "bpVal", "=", "bps", ".", "get", "(", "coords", "[", "dim", "]", ")", ";", "writeln", "(", "indent", "+", "\"*", "for", "\"", "+", "bft", ".", "getVarID", "(", "dim", ")", "+", "\"", "=", "\"", "+", "bpVal", "+", "\"", "\"", ")", ";", "writeIndepValsWithHdr", "(", "ptIt", ",", "dim", "+", "1", ")", ";", "}", "}", "else", "{", "String", "lastBpID", "=", "ft", ".", "getBPID", "(", "numDims", ")", ";", "int", "numLastBps", "=", "ourModel", ".", "getBPSetByID", "(", "lastBpID", ")", ".", "values", "(", ")", ".", "size", "(", ")", ";", "String", "buffer", "=", "indent", "+", "\"", "\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numLastBps", ";", "i", "++", ")", "{", "double", "val", "=", "ptIt", ".", "next", "(", ")", ";", "String", "testBuffer", "=", "buffer", "+", "val", "+", "\"", "\"", ";", "if", "(", "testBuffer", ".", "length", "(", ")", ">", "lineWrapLen", ")", "{", "writeln", "(", "buffer", ")", ";", "buffer", "=", "indent", "+", "\"", "\"", "+", "val", "+", "\"", "\"", ";", "}", "else", "{", "buffer", "=", "testBuffer", ";", "}", "}", "writeln", "(", "buffer", ")", ";", "}", "}", "private", "void", "writeTextComment", "(", "String", "input", ")", "throws", "IOException", "{", "String", "buffer", "=", "\"\"", ";", "String", "testBuffer", ";", "if", "(", "input", "!=", "null", ")", "{", "input", "=", "normalize", "(", "input", ")", ";", "String", "[", "]", "word", "=", "input", ".", "split", "(", "\"", "\"", ")", ";", "buffer", "=", "indent", "+", "\"*\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "word", ".", "length", ";", "i", "++", ")", "{", "testBuffer", "=", "buffer", "+", "\"", "\"", "+", "word", "[", "i", "]", ";", "if", "(", "testBuffer", ".", "length", "(", ")", ">", "lineWrapLen", ")", "{", "writeln", "(", "buffer", ")", ";", "buffer", "=", "indent", "+", "\"*", "\"", "+", "word", "[", "i", "]", ";", "}", "else", "{", "buffer", "=", "testBuffer", ";", "}", "}", "}", "writeln", "(", "buffer", ")", ";", "}", "void", "writeTables", "(", "BlockArrayList", "blocks", ")", "{", "Iterator", "<", "Block", ">", "it", "=", "blocks", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Block", "blk", "=", "it", ".", "next", "(", ")", ";", "if", "(", "blk", "instanceof", "BlockFuncTable", ")", "{", "bft", "=", "(", "BlockFuncTable", ")", "blk", ";", "this", ".", "generateTableDescription", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
8,395
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2otis", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "*", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "public", "class", "DAVE2OTIS", "extends", "DAVE", "{", "String", "tableFileName", ";", "String", "modelFileName", ";", "public", "DAVE2OTIS", "(", ")", "{", "super", "(", ")", ";", "}", "public", "DAVE2OTIS", "(", "String", "[", "]", "args", ")", "{", "this", "(", ")", ";", "this", ".", "parseOptions", "(", "args", ")", ";", "if", "(", "this", ".", "isVerbose", "(", ")", ")", "{", "this", ".", "getModel", "(", ")", ".", "makeVerbose", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setInputFileName", "(", "String", "fn", ")", "{", "super", ".", "setInputFileName", "(", "fn", ")", ";", "this", ".", "tableFileName", "=", "this", ".", "getStubName", "(", ")", "+", "\".dat\"", ";", "this", ".", "modelFileName", "=", "this", ".", "getStubName", "(", ")", "+", "\".inl\"", ";", "}", "private", "void", "parseOptions", "(", "String", "inArgs", "[", "]", ")", "{", "String", "exampleUse", "=", "\"\"", ";", "int", "numArgs", "=", "inArgs", ".", "length", ";", "this", ".", "setArgs", "(", "inArgs", ")", ";", "if", "(", "numArgs", ">", "0", ")", "{", "int", "parsedArgs", "=", "0", ";", "if", "(", "this", ".", "matchOptionArgs", "(", "\"c\"", ",", "\"count\"", ")", ")", "{", "this", ".", "setGenStatsFlag", "(", ")", ";", "parsedArgs", "++", ";", "}", "if", "(", "this", ".", "matchOptionArgs", "(", "\"d\"", ",", "\"debug\"", ")", ")", "{", "this", ".", "makeVerbose", "(", ")", ";", "parsedArgs", "++", ";", "}", "if", "(", "matchOptionArgs", "(", "\"v\"", ",", "\"version\"", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "getVersion", "(", ")", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "if", "(", "parsedArgs", "<", "(", "numArgs", "-", "1", ")", ")", "{", "if", "(", "numArgs", "==", "2", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "getArgs", "(", ")", "[", "2", "]", "+", "\"'.\"", ")", ";", "}", "else", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "(", "numArgs", "-", "1", ")", "+", "\"\"", ")", ";", "}", "System", ".", "err", ".", "println", "(", "exampleUse", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "}", "else", "{", "System", ".", "out", ".", "println", "(", "exampleUse", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "this", ".", "setInputFileName", "(", "inArgs", "[", "numArgs", "-", "1", "]", ")", ";", "}", "public", "void", "createModel", "(", ")", "throws", "IOException", "{", "Model", "theModel", "=", "this", ".", "getModel", "(", ")", ";", "File", "file", "=", "new", "File", "(", "this", ".", "getStubName", "(", ")", ")", ";", "String", "modelName", "=", "file", ".", "getName", "(", ")", ";", "theModel", ".", "clearSelections", "(", ")", ";", "if", "(", "!", "theModel", ".", "selectOutputByName", "(", "\"\"", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "if", "(", "!", "theModel", ".", "selectOutputByName", "(", "\"\"", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "OtisTableWriter", "tableWriter", "=", "new", "OtisTableWriter", "(", "theModel", ",", "this", ".", "tableFileName", ")", ";", "OtisModelWriter", "modelWriter", "=", "new", "OtisModelWriter", "(", "theModel", ",", "this", ".", "modelFileName", ")", ";", "BlockArrayList", "sortedBlocks", "=", "null", ";", "try", "{", "sortedBlocks", "=", "theModel", ".", "getSelectedBlocks", "(", ")", ";", "if", "(", "sortedBlocks", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "if", "(", "sortedBlocks", ".", "isEmpty", "(", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "}", "catch", "(", "DAVEException", "ex", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "modelWriter", ".", "writeModel", "(", "sortedBlocks", ",", "modelName", ")", ";", "tableWriter", ".", "writeTables", "(", "sortedBlocks", ")", ";", "tableWriter", ".", "close", "(", ")", ";", "modelWriter", ".", "close", "(", ")", ";", "}", "public", "static", "void", "main", "(", "String", "args", "[", "]", ")", "{", "boolean", "success", "=", "false", ";", "DAVE2OTIS", "dave2otis", "=", "new", "DAVE2OTIS", "(", "args", ")", ";", "try", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "success", "=", "dave2otis", ".", "parseFile", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "!", "success", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "try", "{", "if", "(", "dave2otis", ".", "hasCheckcases", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "if", "(", "!", "dave2otis", ".", "verify", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "}", "}", "catch", "(", "NoSuchMethodError", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "try", "{", "if", "(", "dave2otis", ".", "getGenStatsFlag", "(", ")", ")", "{", "dave2otis", ".", "reportStats", "(", ")", ";", "}", "}", "catch", "(", "NoSuchMethodError", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "try", "{", "dave2otis", ".", "createModel", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", "+", "dave2otis", ".", "getStubName", "(", ")", "+", "\".\"", ")", ";", "}", "}", "</s>" ]
8,396
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2sl", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "NameList", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "MDLNameList", "extends", "NameList", "{", "public", "MDLNameList", "(", ")", "{", "super", "(", ")", ";", "}", "public", "MDLNameList", "(", "int", "initialCapacity", ")", "{", "super", "(", "initialCapacity", ")", ";", "}", "public", "static", "String", "convertToMDLString", "(", "String", "s", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "s", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "switch", "(", "sb", ".", "charAt", "(", "i", ")", ")", "{", "case", "'", "'", ":", "case", "'-'", ":", "case", "':'", ":", "case", "'/'", ":", "case", "'\\\\'", ":", "case", "'%'", ":", "case", "'('", ":", "case", "')'", ":", "case", "'['", ":", "case", "']'", ":", "case", "'{'", ":", "case", "'}'", ":", "case", "'*'", ":", "case", "'&'", ":", "case", "'+'", ":", "case", "','", ":", "case", "'.'", ":", "case", "'#'", ":", "case", "';'", ":", "case", "'!'", ":", "case", "'`'", ":", "case", "'~'", ":", "case", "'^'", ":", "sb", ".", "setCharAt", "(", "i", ",", "'_'", ")", ";", "break", ";", "default", ":", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "String", "fixName", "(", "String", "s", ")", "{", "return", "convertToMDLString", "(", "s", ")", ";", "}", "}", "</s>" ]
8,397
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2sl", ";", "import", "gov", ".", "nasa", ".", "daveml", ".", "dave", ".", "*", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "class", "SLDiagram", "{", "Model", "model", ";", "ArrayList", "<", "SLRowColumnVector", ">", "rows", ";", "ArrayList", "<", "SLRowColumnVector", ">", "cols", ";", "ArrayList", "<", "SLCell", ">", "cells", ";", "ArrayList", "<", "SLBlock", ">", "slblockList", ";", "ArrayList", "<", "String", ">", "inputNames", ";", "ArrayList", "<", "String", ">", "outputNames", ";", "boolean", "verboseFlag", ";", "double", "SLversion", ";", "boolean", "warnOnClip", ";", "boolean", "resetOutputsWhenDisabled", ";", "boolean", "makeLib", ";", "boolean", "makeEnabledSubSys", ";", "static", "int", "padding", "=", "20", ";", "static", "int", "xMargin", "=", "10", ";", "static", "int", "yMargin", "=", "10", ";", "public", "SLDiagram", "(", "Model", "theModel", ")", "{", "int", "row", "=", "0", ";", "SLBlock", "slb", "=", "null", ";", "this", ".", "inputNames", "=", "new", "ArrayList", "<", "String", ">", "(", "20", ")", ";", "this", ".", "outputNames", "=", "new", "ArrayList", "<", "String", ">", "(", "20", ")", ";", "this", ".", "SLversion", "=", "6.2", ";", "this", ".", "warnOnClip", "=", "false", ";", "this", ".", "resetOutputsWhenDisabled", "=", "true", ";", "this", ".", "makeLib", "=", "false", ";", "this", ".", "makeEnabledSubSys", "=", "false", ";", "if", "(", "theModel", ".", "isVerbose", "(", ")", ")", "this", ".", "makeVerbose", "(", ")", ";", "if", "(", "this", ".", "isVerbose", "(", ")", ")", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "this", ".", "model", "=", "theModel", ";", "this", ".", "slblockList", "=", "new", "ArrayList", "<", "SLBlock", ">", "(", "this", ".", "model", ".", "getNumBlocks", "(", ")", ")", ";", "MDLNameList", "nl", "=", "new", "MDLNameList", "(", "this", ".", "model", ".", "getNumBlocks", "(", ")", ")", ";", "if", "(", "this", ".", "isVerbose", "(", ")", ")", "System", ".", "out", ".", "println", "(", "\"\"", "+", "this", ".", "model", ".", "getNumBlocks", "(", ")", "+", "\"\"", ")", ";", "BlockArrayList", "bal", "=", "this", ".", "model", ".", "getBlocks", "(", ")", ";", "if", "(", "bal", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "for", "(", "Iterator", "<", "Block", ">", "iBlks", "=", "bal", ".", "iterator", "(", ")", ";", "iBlks", ".", "hasNext", "(", ")", ";", ")", "{", "Block", "b", "=", "iBlks", ".", "next", "(", ")", ";", "if", "(", "b", "!=", "null", ")", "{", "slb", "=", "new", "SLBlock", "(", "this", ",", "b", ")", ";", "b", ".", "setMask", "(", "slb", ")", ";", "}", "else", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "try", "{", "b", ".", "setNameList", "(", "nl", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "b", ".", "getType", "(", ")", "+", "\"block", "'\"", "+", "b", ".", "getName", "(", ")", "+", "\"'.\"", ")", ";", "}", "this", ".", "slblockList", ".", "add", "(", "slb", ")", ";", "}", "for", "(", "Iterator", "<", "SLBlock", ">", "islb", "=", "this", ".", "slblockList", ".", "iterator", "(", ")", ";", "islb", ".", "hasNext", "(", ")", ";", ")", "{", "slb", "=", "islb", ".", "next", "(", ")", ";", "slb", ".", "findChildren", "(", ")", ";", "Block", "b", "=", "slb", ".", "getBlock", "(", ")", ";", "if", "(", "b", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "if", "(", "(", "b", "instanceof", "BlockInput", ")", "||", "(", "b", "instanceof", "BlockMathConstant", ")", ")", "{", "row", "=", "slb", ".", "setPosition", "(", "row", "+", "1", ",", "1", ")", ";", "}", "}", "int", "numRows", "=", "1", ";", "int", "numCols", "=", "1", ";", "Iterator", "<", "SLBlock", ">", "iblk", "=", "this", ".", "slblockList", ".", "iterator", "(", ")", ";", "while", "(", "iblk", ".", "hasNext", "(", ")", ")", "{", "slb", "=", "iblk", ".", "next", "(", ")", ";", "int", "theRow", "=", "slb", ".", "getRow", "(", ")", ";", "int", "theCol", "=", "slb", ".", "getCol", "(", ")", ";", "if", "(", "theRow", ">", "numRows", ")", "numRows", "=", "theRow", ";", "if", "(", "theCol", ">", "numCols", ")", "numCols", "=", "theCol", ";", "}", "if", "(", "this", ".", "isVerbose", "(", ")", ")", "{", "System", ".", "out", ".", "print", "(", "\"", "Found", "\"", "+", "numRows", "+", "\"", "rows", "and\"", ")", ";", "System", ".", "out", ".", "println", "(", "\"", "\"", "+", "numCols", "+", "\"", "columns.\"", ")", ";", "}", "this", ".", "rows", "=", "new", "ArrayList", "<", "SLRowColumnVector", ">", "(", "numRows", "+", "1", ")", ";", "this", ".", "cols", "=", "new", "ArrayList", "<", "SLRowColumnVector", ">", "(", "numCols", "+", "1", ")", ";", "this", ".", "cells", "=", "new", "ArrayList", "<", "SLCell", ">", "(", "numRows", "*", "numCols", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numRows", ";", "i", "++", ")", "this", ".", "rows", ".", "add", "(", "i", ",", "new", "SLRowColumnVector", "(", "numCols", "+", "1", ",", "true", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numCols", ";", "i", "++", ")", "this", ".", "cols", ".", "add", "(", "i", ",", "new", "SLRowColumnVector", "(", "numRows", "+", "1", ",", "false", ")", ")", ";", "iblk", "=", "this", ".", "slblockList", ".", "iterator", "(", ")", ";", "while", "(", "iblk", ".", "hasNext", "(", ")", ")", "{", "slb", "=", "iblk", ".", "next", "(", ")", ";", "SLCell", "cell", "=", "new", "SLCell", "(", "slb", ",", "this", ")", ";", "this", ".", "cells", ".", "add", "(", "cell", ")", ";", "int", "rowIndex", "=", "slb", ".", "getRow", "(", ")", "-", "1", ";", "int", "colIndex", "=", "slb", ".", "getCol", "(", ")", "-", "1", ";", "SLRowColumnVector", "rowv", "=", "this", ".", "rows", ".", "get", "(", "rowIndex", ")", ";", "SLRowColumnVector", "colv", "=", "this", ".", "cols", ".", "get", "(", "colIndex", ")", ";", "rowv", ".", "set", "(", "colIndex", ",", "cell", ")", ";", "colv", ".", "set", "(", "rowIndex", ",", "cell", ")", ";", "}", "}", "void", "setWarnOnClip", "(", ")", "{", "this", ".", "warnOnClip", "=", "true", ";", "}", "boolean", "getWarnOnClip", "(", ")", "{", "return", "this", ".", "warnOnClip", ";", "}", "void", "setVerFlag4", "(", ")", "{", "this", ".", "SLversion", "=", "4.0", ";", "}", "boolean", "getVerFlag4", "(", ")", "{", "return", "this", ".", "SLversion", "==", "4.0", ";", "}", "void", "setVerFlag5", "(", ")", "{", "this", ".", "SLversion", "=", "5.0", ";", "}", "boolean", "getVerFlag5", "(", ")", "{", "return", "this", ".", "SLversion", "==", "5.0", ";", "}", "void", "setLibFlag", "(", ")", "{", "this", ".", "makeLib", "=", "true", ";", "}", "boolean", "getLibFlag", "(", ")", "{", "return", "this", ".", "makeLib", ";", "}", "void", "setEnabledFlag", "(", ")", "{", "this", ".", "makeEnabledSubSys", "=", "true", ";", "}", "boolean", "getEnabledFlag", "(", ")", "{", "return", "this", ".", "makeEnabledSubSys", ";", "}", "public", "int", "getPadding", "(", ")", "{", "return", "SLDiagram", ".", "padding", ";", "}", "public", "int", "getNumInputs", "(", ")", "{", "return", "this", ".", "model", ".", "getNumInputBlocks", "(", ")", ";", "}", "public", "int", "getNumOutputs", "(", ")", "{", "return", "this", ".", "model", ".", "getNumOutputBlocks", "(", ")", ";", "}", "public", "void", "makeVerbose", "(", ")", "{", "this", ".", "verboseFlag", "=", "true", ";", "if", "(", "rows", "!=", "null", ")", "{", "Iterator", "<", "SLRowColumnVector", ">", "it", "=", "rows", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLRowColumnVector", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "if", "(", "cols", "!=", "null", ")", "{", "Iterator", "<", "SLRowColumnVector", ">", "it", "=", "cols", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLRowColumnVector", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "if", "(", "slblockList", "!=", "null", ")", "{", "Iterator", "<", "SLBlock", ">", "it", "=", "slblockList", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLBlock", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "}", "public", "boolean", "isVerbose", "(", ")", "{", "return", "this", ".", "verboseFlag", ";", "}", "public", "void", "silence", "(", ")", "{", "this", ".", "verboseFlag", "=", "false", ";", "if", "(", "rows", "!=", "null", ")", "{", "Iterator", "<", "SLRowColumnVector", ">", "it", "=", "rows", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLRowColumnVector", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "if", "(", "cols", "!=", "null", ")", "{", "Iterator", "<", "SLRowColumnVector", ">", "it", "=", "cols", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLRowColumnVector", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "if", "(", "slblockList", "!=", "null", ")", "{", "Iterator", "<", "SLBlock", ">", "it", "=", "slblockList", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "SLBlock", "dude", "=", "it", ".", "next", "(", ")", ";", "dude", ".", "makeVerbose", "(", ")", ";", "}", "}", "}", "public", "SLCell", "getCell", "(", "int", "rowIndex", ",", "int", "colIndex", ")", "{", "SLRowColumnVector", "row", "=", "this", ".", "rows", ".", "get", "(", "rowIndex", ")", ";", "SLCell", "theCell", "=", "row", ".", "get", "(", "colIndex", ")", ";", "return", "theCell", ";", "}", "public", "SLCell", "getCell", "(", "SLBlock", "b", ")", "{", "int", "rowIndex", "=", "b", ".", "getRow", "(", ")", "-", "1", ";", "int", "colIndex", "=", "b", ".", "getCol", "(", ")", "-", "1", ";", "return", "this", ".", "getCell", "(", "rowIndex", ",", "colIndex", ")", ";", "}", "public", "SLRowColumnVector", "getRow", "(", "int", "index", ")", "{", "return", "this", ".", "rows", ".", "get", "(", "index", ")", ";", "}", "public", "SLRowColumnVector", "getCol", "(", "int", "index", ")", "{", "return", "this", ".", "cols", ".", "get", "(", "index", ")", ";", "}", "public", "void", "addInput", "(", "int", "seqNum", ",", "String", "name", ")", "{", "if", "(", "seqNum", "<", "1", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "name", "+", "\"\"", "+", "seqNum", "+", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "while", "(", "inputNames", ".", "size", "(", ")", "<", "seqNum", ")", "inputNames", ".", "add", "(", "null", ")", ";", "this", ".", "inputNames", ".", "set", "(", "seqNum", "-", "1", ",", "name", ")", ";", "}", "public", "ArrayList", "<", "String", ">", "getInputNames", "(", ")", "{", "return", "this", ".", "inputNames", ";", "}", "public", "void", "addOutput", "(", "int", "seqNum", ",", "String", "name", ")", "{", "if", "(", "seqNum", "<", "1", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "name", "+", "\"\"", "+", "seqNum", "+", "\"\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "while", "(", "outputNames", ".", "size", "(", ")", "<", "seqNum", ")", "outputNames", ".", "add", "(", "null", ")", ";", "this", ".", "outputNames", ".", "set", "(", "seqNum", "-", "1", ",", "name", ")", ";", "}", "public", "ArrayList", "<", "String", ">", "getOutputNames", "(", ")", "{", "return", "this", ".", "outputNames", ";", "}", "public", "void", "describeSelf", "(", "PrintStream", "printer", ")", "{", "final", "int", "width", "=", "3", ";", "printer", ".", "println", "(", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "width", ";", "k", "++", ")", "printer", ".", "print", "(", "\"", "\"", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "cols", ".", "size", "(", ")", ";", "j", "++", ")", "{", "SLRowColumnVector", "col", "=", "cols", ".", "get", "(", "j", ")", ";", "printer", ".", "print", "(", "col", ".", "cableTray", ".", "size", "(", ")", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "width", ";", "k", "++", ")", "printer", ".", "print", "(", "\"", "\"", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ".", "size", "(", ")", ";", "i", "++", ")", "{", "SLRowColumnVector", "row", "=", "rows", ".", "get", "(", "i", ")", ";", "printer", ".", "println", "(", ")", ";", "printer", ".", "print", "(", "\"", "*\"", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "cols", ".", "size", "(", ")", ";", "j", "++", ")", "{", "SLCell", "cell", "=", "row", ".", "get", "(", "j", ")", ";", "if", "(", "cell", "!=", "null", ")", "{", "SLBlock", "b", "=", "cell", ".", "getBlock", "(", ")", ";", "printer", ".", "print", "(", "\"", "\"", ")", ";", "if", "(", "b", "==", "null", ")", "for", "(", "int", "k", "=", "0", ";", "k", "<", "width", ";", "k", "++", ")", "printer", ".", "print", "(", "\"", "\"", ")", ";", "else", "{", "String", "s", "=", "b", ".", "getName", "(", ")", ";", "if", "(", "s", ".", "length", "(", ")", "<", "width", ")", "{", "printer", ".", "print", "(", "s", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "(", "width", "-", "s", ".", "length", "(", ")", ")", ";", "k", "++", ")", "printer", ".", "print", "(", "\"", "\"", ")", ";", "}", "else", "printer", ".", "print", "(", "s", ".", "substring", "(", "0", ",", "width", ")", ")", ";", "}", "}", "else", "{", "printer", ".", "print", "(", "\"", "\"", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "width", ";", "k", "++", ")", "printer", ".", "print", "(", "\"", "\"", ")", ";", "}", "printer", ".", "print", "(", "\"", "*\"", ")", ";", "}", "printer", ".", "print", "(", "\"n\"", "+", "row", ".", "cableTray", ".", "size", "(", ")", ")", ";", "}", "printer", ".", "println", "(", ")", ";", "printer", ".", "println", "(", ")", ";", "}", "public", "void", "createModel", "(", "SLFileWriter", "writer", ",", "MatFileWriter", "mWriter", ")", "throws", "IOException", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ".", "size", "(", ")", ";", "i", "++", ")", "{", "SLRowColumnVector", "row", "=", "rows", ".", "get", "(", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "cols", ".", "size", "(", ")", ";", "j", "++", ")", "{", "SLCell", "cell", "=", "row", ".", "get", "(", "j", ")", ";", "if", "(", "cell", "!=", "null", ")", "{", "SLBlock", "b", "=", "cell", ".", "getBlock", "(", ")", ";", "int", "oldRow", "=", "b", ".", "getRow", "(", ")", ";", "int", "oldCol", "=", "b", ".", "getCol", "(", ")", ";", "if", "(", "oldRow", "!=", "i", "+", "1", ")", "System", ".", "err", ".", "println", "(", "\"\"", "+", "b", ".", "getName", "(", ")", "+", "\"", "to", "\"", "+", "(", "i", "+", "1", ")", "+", "\";", "was", "\"", "+", "oldRow", ")", ";", "if", "(", "oldCol", "!=", "j", "+", "1", ")", "System", ".", "err", ".", "println", "(", "\"\"", "+", "b", ".", "getName", "(", ")", "+", "\"", "to", "\"", "+", "(", "j", "+", "1", ")", "+", "\";", "was", "\"", "+", "oldCol", ")", ";", "b", ".", "setRowCol", "(", "i", "+", "1", ",", "j", "+", "1", ")", ";", "}", "}", "}", "int", "rowOffset", "=", "xMargin", ";", "for", "(", "int", "rowIndex", "=", "0", ";", "rowIndex", "<", "this", ".", "rows", ".", "size", "(", ")", ";", "rowIndex", "++", ")", "{", "int", "rowSize", "=", "this", ".", "getRow", "(", "rowIndex", ")", ".", "getSize", "(", ")", ";", "int", "y", "=", "rowOffset", "+", "rowSize", "/", "2", ";", "int", "colOffset", "=", "yMargin", ";", "for", "(", "int", "colIndex", "=", "0", ";", "colIndex", "<", "this", ".", "cols", ".", "size", "(", ")", ";", "colIndex", "++", ")", "{", "int", "colSize", "=", "this", ".", "getCol", "(", "colIndex", ")", ".", "getSize", "(", ")", ";", "int", "x", "=", "colOffset", "+", "colSize", "/", "2", ";", "SLCell", "theCell", "=", "this", ".", "getCell", "(", "rowIndex", ",", "colIndex", ")", ";", "if", "(", "theCell", "!=", "null", ")", "{", "SLBlock", "theBlock", "=", "theCell", ".", "getBlock", "(", ")", ";", "if", "(", "theBlock", "!=", "null", ")", "{", "theBlock", ".", "createM", "(", "writer", ",", "x", ",", "y", ")", ";", "theBlock", ".", "writeMat", "(", "mWriter", ")", ";", "}", "}", "colOffset", "=", "colOffset", "+", "colSize", ";", "}", "rowOffset", "=", "rowOffset", "+", "rowSize", ";", "}", "SignalArrayList", "sigs", "=", "model", ".", "getSignals", "(", ")", ";", "Iterator", "<", "Signal", ">", "isig", "=", "sigs", ".", "iterator", "(", ")", ";", "while", "(", "isig", ".", "hasNext", "(", ")", ")", "{", "Signal", "oldSig", "=", "isig", ".", "next", "(", ")", ";", "SLSignal", "newSig", "=", "new", "SLSignal", "(", "oldSig", ",", "this", ")", ";", "newSig", ".", "createAddLine", "(", "writer", ")", ";", "}", "}", "}", "</s>" ]
8,398
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2sl", ";", "public", "class", "SLCell", "{", "SLDiagram", "myParent", ";", "SLBlock", "myBlock", ";", "SLRowColumnVector", "myRow", ";", "SLRowColumnVector", "myCol", ";", "public", "SLCell", "(", ")", "{", "myParent", "=", "null", ";", "myBlock", "=", "null", ";", "}", "public", "SLCell", "(", "SLBlock", "b", ",", "SLDiagram", "theDiagram", ")", "{", "this", "(", ")", ";", "this", ".", "myBlock", "=", "b", ";", "this", ".", "myParent", "=", "theDiagram", ";", "}", "public", "SLBlock", "getBlock", "(", ")", "{", "return", "this", ".", "myBlock", ";", "}", "public", "int", "getRowIndex", "(", ")", "{", "return", "myCol", ".", "getOffset", "(", "this", ")", ";", "}", "public", "int", "getColIndex", "(", ")", "{", "return", "myRow", ".", "getOffset", "(", "this", ")", ";", "}", "public", "SLRowColumnVector", "getRow", "(", ")", "{", "return", "this", ".", "myRow", ";", "}", "public", "SLRowColumnVector", "getCol", "(", ")", "{", "return", "this", ".", "myCol", ";", "}", "public", "SLCell", "previousCellInColumn", "(", ")", "{", "return", "myParent", ".", "getCell", "(", "this", ".", "getRowIndex", "(", ")", "-", "1", ",", "this", ".", "getColIndex", "(", ")", ")", ";", "}", "public", "SLCell", "previousCellInRow", "(", ")", "{", "return", "myParent", ".", "getCell", "(", "this", ".", "getRowIndex", "(", ")", ",", "this", ".", "getColIndex", "(", ")", "-", "1", ")", ";", "}", "public", "SLCell", "nextCellInColumn", "(", ")", "{", "return", "myParent", ".", "getCell", "(", "this", ".", "getRowIndex", "(", ")", "+", "1", ",", "this", ".", "getColIndex", "(", ")", ")", ";", "}", "public", "SLCell", "nextCellInRow", "(", ")", "{", "return", "myParent", ".", "getCell", "(", "this", ".", "getRowIndex", "(", ")", ",", "this", ".", "getColIndex", "(", ")", "+", "1", ")", ";", "}", "public", "void", "setRow", "(", "SLRowColumnVector", "theRow", ")", "{", "this", ".", "myRow", "=", "theRow", ";", "}", "public", "void", "setCol", "(", "SLRowColumnVector", "theCol", ")", "{", "this", ".", "myCol", "=", "theCol", ";", "}", "public", "int", "getMinWidth", "(", ")", "{", "return", "this", ".", "myBlock", ".", "getMDLWidth", "(", ")", "+", "2", "*", "this", ".", "myParent", ".", "getPadding", "(", ")", ";", "}", "public", "int", "getMinHeight", "(", ")", "{", "return", "this", ".", "myBlock", ".", "getMDLHeight", "(", ")", "+", "this", ".", "myParent", ".", "getPadding", "(", ")", ";", "}", "public", "int", "getWidth", "(", ")", "{", "return", "myCol", ".", "getSize", "(", ")", ";", "}", "public", "int", "getHeight", "(", ")", "{", "return", "myRow", ".", "getSize", "(", ")", ";", "}", "public", "int", "distToEdge", "(", ")", "{", "return", "(", "this", ".", "getWidth", "(", ")", "-", "this", ".", "myBlock", ".", "getMDLWidth", "(", ")", ")", "/", "2", ";", "}", "}", "</s>" ]
8,399
[ "<s>", "package", "gov", ".", "nasa", ".", "daveml", ".", "dave2sl", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "SLCableTray", "extends", "ArrayList", "<", "Object", ">", "{", "static", "int", "offset", "=", "5", ";", "public", "SLCableTray", "(", ")", "{", "super", "(", ")", ";", "}", "public", "SLCableTray", "(", "int", "count", ")", "{", "super", "(", "count", ")", ";", "}", "public", "boolean", "add", "(", "Object", "theObject", ")", "{", "if", "(", "!", "this", ".", "contains", "(", "theObject", ")", ")", "return", "super", ".", "add", "(", "theObject", ")", ";", "return", "false", ";", "}", "public", "int", "getSize", "(", ")", "{", "if", "(", "this", ".", "size", "(", ")", ">", "0", ")", "return", "(", "this", ".", "size", "(", ")", "-", "1", ")", "*", "offset", ";", "else", "return", "0", ";", "}", "public", "int", "getStandoff", "(", "SLSignal", "theSignal", ")", "{", "return", "this", ".", "indexOf", "(", "theSignal", ")", "*", "offset", ";", "}", "}", "</s>" ]