id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
88960_36 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder("<file");
sb.append(attr("name", result.getName()));
sb.append(">\n");
for (Issue issue : result.getIssues()) {
sb.append("<error");
sb.append(attr("line", Integer.toString(issue.getLine())));
sb.append(attr("column", Integer.toString(issue.getCharacter())));
// Based on com.puppycrawl.tools.checkstyle.api.SeverityLevel.
sb.append(attr("severity", "warning"));
sb.append(attr("message", issue.getReason()));
sb.append(attr("source", JSLint.class.getName()));
sb.append("/>\n");
}
sb.append("</file>");
return sb.toString();
} |
88960_37 | public String format(JSLintResult result) {
// TODO use a proper serializer
StringBuilder sb = new StringBuilder("<testsuite");
List<Issue> issues = result.getIssues();
String testFailures = issues.isEmpty() ? "0" : "1";
sb.append(attr("failures", testFailures));
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("skipped", "0"));
sb.append(attr("errors", testFailures));
sb.append(attr("tests", "1"));
sb.append(attr("name", result.getName()));
sb.append(">");
sb.append("<testcase");
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("classname", TEST_CLASSNAME));
sb.append(attr("name", result.getName()));
sb.append(">");
if (!issues.isEmpty()) {
sb.append("<failure");
String msg = String.format("Found %d problem%s", issues.size(), s(issues.size()));
sb.append(attr("message", msg));
sb.append(attr("type", AssertionError.class.getName()));
sb.append(">");
for (Issue issue : issues) {
sb.append(escape(issue.toString()));
sb.append(System.getProperty("line.separator"));
}
sb.append("</failure>");
}
sb.append("</testcase>");
sb.append("</testsuite>");
return sb.toString();
} |
88960_38 | public String format(JSLintResult result) {
// TODO use a proper serializer
StringBuilder sb = new StringBuilder("<testsuite");
List<Issue> issues = result.getIssues();
String testFailures = issues.isEmpty() ? "0" : "1";
sb.append(attr("failures", testFailures));
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("skipped", "0"));
sb.append(attr("errors", testFailures));
sb.append(attr("tests", "1"));
sb.append(attr("name", result.getName()));
sb.append(">");
sb.append("<testcase");
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("classname", TEST_CLASSNAME));
sb.append(attr("name", result.getName()));
sb.append(">");
if (!issues.isEmpty()) {
sb.append("<failure");
String msg = String.format("Found %d problem%s", issues.size(), s(issues.size()));
sb.append(attr("message", msg));
sb.append(attr("type", AssertionError.class.getName()));
sb.append(">");
for (Issue issue : issues) {
sb.append(escape(issue.toString()));
sb.append(System.getProperty("line.separator"));
}
sb.append("</failure>");
}
sb.append("</testcase>");
sb.append("</testsuite>");
return sb.toString();
} |
88960_39 | public String format(JSLintResult result) {
// TODO use a proper serializer
StringBuilder sb = new StringBuilder("<testsuite");
List<Issue> issues = result.getIssues();
String testFailures = issues.isEmpty() ? "0" : "1";
sb.append(attr("failures", testFailures));
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("skipped", "0"));
sb.append(attr("errors", testFailures));
sb.append(attr("tests", "1"));
sb.append(attr("name", result.getName()));
sb.append(">");
sb.append("<testcase");
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("classname", TEST_CLASSNAME));
sb.append(attr("name", result.getName()));
sb.append(">");
if (!issues.isEmpty()) {
sb.append("<failure");
String msg = String.format("Found %d problem%s", issues.size(), s(issues.size()));
sb.append(attr("message", msg));
sb.append(attr("type", AssertionError.class.getName()));
sb.append(">");
for (Issue issue : issues) {
sb.append(escape(issue.toString()));
sb.append(System.getProperty("line.separator"));
}
sb.append("</failure>");
}
sb.append("</testcase>");
sb.append("</testsuite>");
return sb.toString();
} |
88960_40 | public String format(JSLintResult result) {
// TODO use a proper serializer
StringBuilder sb = new StringBuilder("<testsuite");
List<Issue> issues = result.getIssues();
String testFailures = issues.isEmpty() ? "0" : "1";
sb.append(attr("failures", testFailures));
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("skipped", "0"));
sb.append(attr("errors", testFailures));
sb.append(attr("tests", "1"));
sb.append(attr("name", result.getName()));
sb.append(">");
sb.append("<testcase");
sb.append(attr("time", formatTimeAsSeconds(result.getDuration())));
sb.append(attr("classname", TEST_CLASSNAME));
sb.append(attr("name", result.getName()));
sb.append(">");
if (!issues.isEmpty()) {
sb.append("<failure");
String msg = String.format("Found %d problem%s", issues.size(), s(issues.size()));
sb.append(attr("message", msg));
sb.append(attr("type", AssertionError.class.getName()));
sb.append(">");
for (Issue issue : issues) {
sb.append(escape(issue.toString()));
sb.append(System.getProperty("line.separator"));
}
sb.append("</failure>");
}
sb.append("</testcase>");
sb.append("</testsuite>");
return sb.toString();
} |
88960_41 | protected String escape(String str) {
if (str == null)
return "";
return str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
} |
88960_42 | protected String escape(String str) {
if (str == null)
return "";
return str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
} |
88960_43 | protected String attr(String key, String value) {
if (key == null)
throw new IllegalArgumentException("key cannot be null");
if (value == null) {
value = "";
}
StringBuilder sb = new StringBuilder(' ');
sb.append(' ');
sb.append(escapeAttr(key));
sb.append("='");
sb.append(escapeAttr(value));
sb.append("'");
return sb.toString();
} |
88960_44 | protected String attr(String key, String value) {
if (key == null)
throw new IllegalArgumentException("key cannot be null");
if (value == null) {
value = "";
}
StringBuilder sb = new StringBuilder(' ');
sb.append(' ');
sb.append(escapeAttr(key));
sb.append("='");
sb.append(escapeAttr(value));
sb.append("'");
return sb.toString();
} |
88960_45 | protected String attr(String key, String value) {
if (key == null)
throw new IllegalArgumentException("key cannot be null");
if (value == null) {
value = "";
}
StringBuilder sb = new StringBuilder(' ');
sb.append(' ');
sb.append(escapeAttr(key));
sb.append("='");
sb.append(escapeAttr(value));
sb.append("'");
return sb.toString();
} |
88960_46 | protected String attr(String key, String value) {
if (key == null)
throw new IllegalArgumentException("key cannot be null");
if (value == null) {
value = "";
}
StringBuilder sb = new StringBuilder(' ');
sb.append(' ');
sb.append(escapeAttr(key));
sb.append("='");
sb.append(escapeAttr(value));
sb.append("'");
return sb.toString();
} |
88960_47 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder();
for (Issue issue : result.getIssues()) {
sb.append(outputOneIssue(issue));
}
return sb.toString();
} |
88960_48 | public String footer() {
return null;
} |
88960_49 | public String header() {
return null;
} |
88960_50 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder();
for (Issue issue : result.getIssues()) {
sb.append(outputOneIssue(issue));
}
return sb.toString();
} |
88960_51 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder();
for (Issue issue : result.getIssues()) {
sb.append(outputOneIssue(issue));
}
return sb.toString();
} |
88960_52 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder();
for (Issue issue : result.getIssues()) {
sb.append(outputOneIssue(issue));
}
return sb.toString();
} |
88960_53 | @Override
public String footer() {
return "</body></html>";
} |
88960_54 | @Override
public String header() {
return "<html><head></head><body>";
} |
88960_55 | public String format(JSLintResult result) {
String name = result.getName();
StringBuilder sb = new StringBuilder();
sb.append("<div class='file'>");
sb.append("<h1");
sb.append(attr("id", name));
sb.append(">");
sb.append(escape(name));
sb.append("</h1>");
sb.append(result.getReport());
sb.append("</div>"); // try to fix somewhat crappy JSLint markup.
sb.append("</div>"); // close the file div.
return sb.toString();
} |
88960_56 | public String format(JSLintResult result) {
String name = result.getName();
StringBuilder sb = new StringBuilder();
sb.append("<div class='file'>");
sb.append("<h1");
sb.append(attr("id", name));
sb.append(">");
sb.append(escape(name));
sb.append("</h1>");
sb.append(result.getReport());
sb.append("</div>"); // try to fix somewhat crappy JSLint markup.
sb.append("</div>"); // close the file div.
return sb.toString();
} |
88960_57 | public <T> T parse(Class<T> clazz, String value) {
try {
Method method = clazz.getMethod("valueOf", String.class);
// There's no contract for this, but in the cases we need it for, it
// should work.
@SuppressWarnings("unchecked")
T rv = (T) method.invoke(null, value);
return rv;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// Can never happen. If the method can't be accessed, we get a NoSuchMethodException
// first, instead.
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
// Attempt to rethrow original exception.
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
} |
88960_58 | public <T> T parse(Class<T> clazz, String value) {
try {
Method method = clazz.getMethod("valueOf", String.class);
// There's no contract for this, but in the cases we need it for, it
// should work.
@SuppressWarnings("unchecked")
T rv = (T) method.invoke(null, value);
return rv;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// Can never happen. If the method can't be accessed, we get a NoSuchMethodException
// first, instead.
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
// Attempt to rethrow original exception.
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
} |
88960_59 | public <T> T parse(Class<T> clazz, String value) {
try {
Method method = clazz.getMethod("valueOf", String.class);
// There's no contract for this, but in the cases we need it for, it
// should work.
@SuppressWarnings("unchecked")
T rv = (T) method.invoke(null, value);
return rv;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// Can never happen. If the method can't be accessed, we get a NoSuchMethodException
// first, instead.
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
// Attempt to rethrow original exception.
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
} |
88960_60 | public <T> T parse(Class<T> clazz, String value) {
try {
Method method = clazz.getMethod("valueOf", String.class);
// There's no contract for this, but in the cases we need it for, it
// should work.
@SuppressWarnings("unchecked")
T rv = (T) method.invoke(null, value);
return rv;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// Can never happen. If the method can't be accessed, we get a NoSuchMethodException
// first, instead.
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
// Attempt to rethrow original exception.
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
} |
88960_61 | public <T> T parse(Class<T> clazz, String value) {
try {
Method method = clazz.getMethod("valueOf", String.class);
// There's no contract for this, but in the cases we need it for, it
// should work.
@SuppressWarnings("unchecked")
T rv = (T) method.invoke(null, value);
return rv;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// Can never happen. If the method can't be accessed, we get a NoSuchMethodException
// first, instead.
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
// Attempt to rethrow original exception.
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
} |
88960_62 | @Override
public String toString() {
return getSystemId() + ":" + getLine() + ":" + getCharacter() + ":" + getReason();
} |
88960_63 | static boolean booleanValue(String name, Scriptable scope) {
Object val = scope.get(name, scope);
if (val == UniqueTag.NOT_FOUND) {
return false;
} else {
return Context.toBoolean(val);
}
} |
88960_64 | static boolean booleanValue(String name, Scriptable scope) {
Object val = scope.get(name, scope);
if (val == UniqueTag.NOT_FOUND) {
return false;
} else {
return Context.toBoolean(val);
}
} |
88960_65 | static boolean booleanValue(String name, Scriptable scope) {
Object val = scope.get(name, scope);
if (val == UniqueTag.NOT_FOUND) {
return false;
} else {
return Context.toBoolean(val);
}
} |
88960_66 | static int intValue(String name, Scriptable scope) {
if (scope == null) {
return 0;
}
Object o = scope.get(name, scope);
return o == Scriptable.NOT_FOUND ? 0 : (int) Context.toNumber(o);
} |
88960_67 | static int intValue(String name, Scriptable scope) {
if (scope == null) {
return 0;
}
Object o = scope.get(name, scope);
return o == Scriptable.NOT_FOUND ? 0 : (int) Context.toNumber(o);
} |
88960_68 | static int intValue(String name, Scriptable scope) {
if (scope == null) {
return 0;
}
Object o = scope.get(name, scope);
return o == Scriptable.NOT_FOUND ? 0 : (int) Context.toNumber(o);
} |
88960_69 | static int intValue(String name, Scriptable scope) {
if (scope == null) {
return 0;
}
Object o = scope.get(name, scope);
return o == Scriptable.NOT_FOUND ? 0 : (int) Context.toNumber(o);
} |
88960_70 | static Object javaToJS(Object o, Scriptable scope) {
Class<?> cls = o.getClass();
if (cls.isArray()) {
return new NativeArray((Object[]) o);
} else {
return Context.javaToJS(o, scope);
}
} |
88960_71 | static <T> List<T> listValue(String name, Scriptable scope, Converter<T> c) {
Object val = scope.get(name, scope);
if (val == UniqueTag.NOT_FOUND || val instanceof Undefined) {
return new ArrayList<T>();
}
Scriptable ary = (Scriptable) val;
int count = intValue("length", ary);
List<T> list = new ArrayList<T>(count);
for (int i = 0; i < count; i++) {
list.add(c.convert(ary.get(i, ary)));
}
return list;
} |
88960_72 | static <T> List<T> listValueOfType(String name, Class<T> class1, Scriptable scope) {
return listValue(name, scope, new Converter<T>() {
public T convert(Object obj) {
@SuppressWarnings("unchecked")
T value = (T) obj;
return value;
}
});
} |
88960_73 | static <T> List<T> listValueOfType(String name, Class<T> class1, Scriptable scope) {
return listValue(name, scope, new Converter<T>() {
public T convert(Object obj) {
@SuppressWarnings("unchecked")
T value = (T) obj;
return value;
}
});
} |
88960_74 | static <T> List<T> listValueOfType(String name, Class<T> class1, Scriptable scope) {
return listValue(name, scope, new Converter<T>() {
public T convert(Object obj) {
@SuppressWarnings("unchecked")
T value = (T) obj;
return value;
}
});
} |
88960_75 | static <T> List<T> listValueOfType(String name, Class<T> class1, Scriptable scope) {
return listValue(name, scope, new Converter<T>() {
public T convert(Object obj) {
@SuppressWarnings("unchecked")
T value = (T) obj;
return value;
}
});
} |
88960_76 | static <T> List<T> listValue(String name, Scriptable scope, Converter<T> c) {
Object val = scope.get(name, scope);
if (val == UniqueTag.NOT_FOUND || val instanceof Undefined) {
return new ArrayList<T>();
}
Scriptable ary = (Scriptable) val;
int count = intValue("length", ary);
List<T> list = new ArrayList<T>(count);
for (int i = 0; i < count; i++) {
list.add(c.convert(ary.get(i, ary)));
}
return list;
} |
88960_77 | static String readerToString(Reader reader) throws IOException {
StringBuffer sb = new StringBuffer();
int c;
while ((c = reader.read()) != -1) {
sb.append((char) c);
}
return sb.toString();
} |
88960_78 | static String stringValue(String name, Scriptable scope) {
if (scope == null) {
return null;
}
Object o = scope.get(name, scope);
return o instanceof String ? (String) o : null;
} |
88960_79 | static String stringValue(String name, Scriptable scope) {
if (scope == null) {
return null;
}
Object o = scope.get(name, scope);
return o instanceof String ? (String) o : null;
} |
88960_80 | static String stringValue(String name, Scriptable scope) {
if (scope == null) {
return null;
}
Object o = scope.get(name, scope);
return o instanceof String ? (String) o : null;
} |
88960_81 | static String stringValue(String name, Scriptable scope) {
if (scope == null) {
return null;
}
Object o = scope.get(name, scope);
return o instanceof String ? (String) o : null;
} |
88960_82 | public final synchronized UnicodeBomInputStream skipBOM() throws IOException {
if (!skipped) {
skip(bom.bytes.length);
skipped = true;
}
return this;
} |
88960_83 | public final synchronized UnicodeBomInputStream skipBOM() throws IOException {
if (!skipped) {
skip(bom.bytes.length);
skipped = true;
}
return this;
} |
88960_84 | public JSLint fromClasspathResource(String resource) throws IOException {
return fromClasspathResource(resource, UTF8);
} |
88960_85 | public JSLint fromDefault() {
try {
return fromClasspathResource(JSLINT_FILE);
} catch (IOException e) {
// We wrap and rethrow, as there's nothing a caller can do in this
// case.
throw new RuntimeException(e);
}
} |
88960_86 | public JSLint fromFile(File f) throws IOException {
return fromFile(f, UTF8);
} |
88960_87 | @NeedsContext
public JSLint fromReader(Reader reader, String name) throws IOException {
try {
Context cx = contextFactory.enterContext();
ScriptableObject scope = cx.initStandardObjects();
cx.evaluateReader(scope, reader, name, 1, null);
Function lintFunc = (Function) scope.get("JSLINT", scope);
return new JSLint(contextFactory, lintFunc);
} finally {
Context.exit();
}
} |
88960_88 | public JSLint fromDefault() {
try {
return fromClasspathResource(JSLINT_FILE);
} catch (IOException e) {
// We wrap and rethrow, as there's nothing a caller can do in this
// case.
throw new RuntimeException(e);
}
} |
88960_89 | public static String[] valueOf(String str) {
return str.split("\\s*,\\s*");
} |
88960_90 | public Charset convert(String value) {
try {
return Charset.forName(value);
} catch (IllegalCharsetNameException e) {
throw new ParameterException("unknown encoding '" + value + "'");
} catch (UnsupportedCharsetException e) {
throw new ParameterException("unknown encoding '" + value + "'");
}
} |
88960_91 | public Charset convert(String value) {
try {
return Charset.forName(value);
} catch (IllegalCharsetNameException e) {
throw new ParameterException("unknown encoding '" + value + "'");
} catch (UnsupportedCharsetException e) {
throw new ParameterException("unknown encoding '" + value + "'");
}
} |
88960_92 | public Charset convert(String value) {
try {
return Charset.forName(value);
} catch (IllegalCharsetNameException e) {
throw new ParameterException("unknown encoding '" + value + "'");
} catch (UnsupportedCharsetException e) {
throw new ParameterException("unknown encoding '" + value + "'");
}
} |
88960_93 | private void version() {
// TODO: display jslint4java version as well.
if (lint == null) {
lint = lintBuilder.fromDefault();
}
info("using jslint version " + lint.getEdition());
throw new DieException(null, 0);
} |
88960_94 | @Override
public String toString() {
return String.format("function %s()", getName());
} |
889932_0 | @Override
public T onCompleted(com.ning.http.client.Response ningResponse) {
try {
final Map<String, String> headersMap = new HashMap<>();
for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) {
final StringBuilder value = new StringBuilder();
for (String str : header.getValue()) {
value.append(str);
}
headersMap.put(header.getKey(), value.toString());
}
final Response response = new Response(ningResponse.getStatusCode(), ningResponse.getStatusText(),
headersMap, ningResponse.getResponseBodyAsStream());
@SuppressWarnings("unchecked")
final T t = converter == null ? (T) response : converter.convert(response);
if (callback != null) {
callback.onCompleted(t);
}
return t;
} catch (IOException | RuntimeException e) {
onThrowable(e);
return null;
}
} |
889932_1 | @Override
public T onCompleted(com.ning.http.client.Response ningResponse) {
try {
final Map<String, String> headersMap = new HashMap<>();
for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) {
final StringBuilder value = new StringBuilder();
for (String str : header.getValue()) {
value.append(str);
}
headersMap.put(header.getKey(), value.toString());
}
final Response response = new Response(ningResponse.getStatusCode(), ningResponse.getStatusText(),
headersMap, ningResponse.getResponseBodyAsStream());
@SuppressWarnings("unchecked")
final T t = converter == null ? (T) response : converter.convert(response);
if (callback != null) {
callback.onCompleted(t);
}
return t;
} catch (IOException | RuntimeException e) {
onThrowable(e);
return null;
}
} |
889932_2 | @Override
public void generateError(String rawResponse) throws IOException {
final JsonNode errorNode = OAuth2AccessTokenJsonExtractor.OBJECT_MAPPER.readTree(rawResponse)
.get("errors").get(0);
OAuth2Error errorCode;
try {
errorCode = OAuth2Error.parseFrom(extractRequiredParameter(errorNode, "errorType", rawResponse).asText());
} catch (IllegalArgumentException iaE) {
//non oauth standard error code
errorCode = null;
}
throw new OAuth2AccessTokenErrorResponse(errorCode, errorNode.get("message").asText(), null, rawResponse);
} |
889932_3 | @Override
public void onResponse(Call call, okhttp3.Response okHttpResponse) {
try {
final Response response = OkHttpHttpClient.convertResponse(okHttpResponse);
try {
@SuppressWarnings("unchecked")
final T t = converter == null ? (T) response : converter.convert(response);
okHttpFuture.setResult(t);
if (callback != null) {
callback.onCompleted(t);
}
} catch (IOException | RuntimeException e) {
okHttpFuture.setException(e);
if (callback != null) {
callback.onThrowable(e);
}
}
} finally {
okHttpFuture.finish();
}
} |
889932_4 | @Override
public void onResponse(Call call, okhttp3.Response okHttpResponse) {
try {
final Response response = OkHttpHttpClient.convertResponse(okHttpResponse);
try {
@SuppressWarnings("unchecked")
final T t = converter == null ? (T) response : converter.convert(response);
okHttpFuture.setResult(t);
if (callback != null) {
callback.onCompleted(t);
}
} catch (IOException | RuntimeException e) {
okHttpFuture.setException(e);
if (callback != null) {
callback.onThrowable(e);
}
}
} finally {
okHttpFuture.finish();
}
} |
889932_5 | @Override
public void onResponse(Call call, okhttp3.Response okHttpResponse) {
try {
final Response response = OkHttpHttpClient.convertResponse(okHttpResponse);
try {
@SuppressWarnings("unchecked")
final T t = converter == null ? (T) response : converter.convert(response);
okHttpFuture.setResult(t);
if (callback != null) {
callback.onCompleted(t);
}
} catch (IOException | RuntimeException e) {
okHttpFuture.setException(e);
if (callback != null) {
callback.onThrowable(e);
}
}
} finally {
okHttpFuture.finish();
}
} |
889932_6 | @Override
public void onFailure(Call call, IOException exception) {
try {
okHttpFuture.setException(exception);
if (callback != null) {
callback.onThrowable(exception);
}
} finally {
okHttpFuture.finish();
}
} |
889932_7 | @Override
public String getSignatureMethod() {
return METHOD;
} |
889932_8 | @Override
public String getSignature(String baseString, String apiSecret, String tokenSecret) {
try {
Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string");
Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string");
return doSign(baseString, OAuthEncoder.encode(apiSecret) + '&' + OAuthEncoder.encode(tokenSecret));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException | RuntimeException e) {
throw new OAuthSignatureException(baseString, e);
}
} |
889932_9 | @Override
public String getSignature(String baseString, String apiSecret, String tokenSecret) {
try {
Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string");
Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string");
return doSign(baseString, OAuthEncoder.encode(apiSecret) + '&' + OAuthEncoder.encode(tokenSecret));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException | RuntimeException e) {
throw new OAuthSignatureException(baseString, e);
}
} |
892275_0 | public static Java8OptionalConverterFactory create() {
return new Java8OptionalConverterFactory();
} |
892275_1 | public static JaxbConverterFactory create() {
return new JaxbConverterFactory(null);
} |
892275_2 | public MoshiConverterFactory asLenient() {
return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls);
} |
892275_3 | public MoshiConverterFactory failOnUnknown() {
return new MoshiConverterFactory(moshi, lenient, true, serializeNulls);
} |
892275_4 | public static GuavaOptionalConverterFactory create() {
return new GuavaOptionalConverterFactory();
} |
892275_5 | @SuppressWarnings("ConstantConditions") // Guarding public API nullability.
public static RxJava3CallAdapterFactory createWithScheduler(Scheduler scheduler) {
if (scheduler == null) throw new NullPointerException("scheduler == null");
return new RxJava3CallAdapterFactory(scheduler, false);
} |
892275_6 | @Override
public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);
if (rawType == Completable.class) {
// Completable is not parameterized (which is what the rest of this method deals with) so it
// can only be created with a single configuration.
return new RxJava3CallAdapter(
Void.class, scheduler, isAsync, false, true, false, false, false, true);
}
boolean isFlowable = rawType == Flowable.class;
boolean isSingle = rawType == Single.class;
boolean isMaybe = rawType == Maybe.class;
if (rawType != Observable.class && !isFlowable && !isSingle && !isMaybe) {
return null;
}
boolean isResult = false;
boolean isBody = false;
Type responseType;
if (!(returnType instanceof ParameterizedType)) {
String name =
isFlowable ? "Flowable" : isSingle ? "Single" : isMaybe ? "Maybe" : "Observable";
throw new IllegalStateException(
name
+ " return type must be parameterized"
+ " as "
+ name
+ "<Foo> or "
+ name
+ "<? extends Foo>");
}
Type observableType = getParameterUpperBound(0, (ParameterizedType) returnType);
Class<?> rawObservableType = getRawType(observableType);
if (rawObservableType == Response.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Response must be parameterized" + " as Response<Foo> or Response<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
} else if (rawObservableType == Result.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Result must be parameterized" + " as Result<Foo> or Result<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
isResult = true;
} else {
responseType = observableType;
isBody = true;
}
return new RxJava3CallAdapter(
responseType, scheduler, isAsync, isResult, isBody, isFlowable, isSingle, isMaybe, false);
} |
892275_7 | @Override
public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);
if (rawType == Completable.class) {
// Completable is not parameterized (which is what the rest of this method deals with) so it
// can only be created with a single configuration.
return new RxJava3CallAdapter(
Void.class, scheduler, isAsync, false, true, false, false, false, true);
}
boolean isFlowable = rawType == Flowable.class;
boolean isSingle = rawType == Single.class;
boolean isMaybe = rawType == Maybe.class;
if (rawType != Observable.class && !isFlowable && !isSingle && !isMaybe) {
return null;
}
boolean isResult = false;
boolean isBody = false;
Type responseType;
if (!(returnType instanceof ParameterizedType)) {
String name =
isFlowable ? "Flowable" : isSingle ? "Single" : isMaybe ? "Maybe" : "Observable";
throw new IllegalStateException(
name
+ " return type must be parameterized"
+ " as "
+ name
+ "<Foo> or "
+ name
+ "<? extends Foo>");
}
Type observableType = getParameterUpperBound(0, (ParameterizedType) returnType);
Class<?> rawObservableType = getRawType(observableType);
if (rawObservableType == Response.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Response must be parameterized" + " as Response<Foo> or Response<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
} else if (rawObservableType == Result.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Result must be parameterized" + " as Result<Foo> or Result<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
isResult = true;
} else {
responseType = observableType;
isBody = true;
}
return new RxJava3CallAdapter(
responseType, scheduler, isAsync, isResult, isBody, isFlowable, isSingle, isMaybe, false);
} |
892275_8 | @Override
public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);
if (rawType == Completable.class) {
// Completable is not parameterized (which is what the rest of this method deals with) so it
// can only be created with a single configuration.
return new RxJava3CallAdapter(
Void.class, scheduler, isAsync, false, true, false, false, false, true);
}
boolean isFlowable = rawType == Flowable.class;
boolean isSingle = rawType == Single.class;
boolean isMaybe = rawType == Maybe.class;
if (rawType != Observable.class && !isFlowable && !isSingle && !isMaybe) {
return null;
}
boolean isResult = false;
boolean isBody = false;
Type responseType;
if (!(returnType instanceof ParameterizedType)) {
String name =
isFlowable ? "Flowable" : isSingle ? "Single" : isMaybe ? "Maybe" : "Observable";
throw new IllegalStateException(
name
+ " return type must be parameterized"
+ " as "
+ name
+ "<Foo> or "
+ name
+ "<? extends Foo>");
}
Type observableType = getParameterUpperBound(0, (ParameterizedType) returnType);
Class<?> rawObservableType = getRawType(observableType);
if (rawObservableType == Response.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Response must be parameterized" + " as Response<Foo> or Response<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
} else if (rawObservableType == Result.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Result must be parameterized" + " as Result<Foo> or Result<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
isResult = true;
} else {
responseType = observableType;
isBody = true;
}
return new RxJava3CallAdapter(
responseType, scheduler, isAsync, isResult, isBody, isFlowable, isSingle, isMaybe, false);
} |
892275_9 | @Override
public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);
if (rawType == Completable.class) {
// Completable is not parameterized (which is what the rest of this method deals with) so it
// can only be created with a single configuration.
return new RxJava3CallAdapter(
Void.class, scheduler, isAsync, false, true, false, false, false, true);
}
boolean isFlowable = rawType == Flowable.class;
boolean isSingle = rawType == Single.class;
boolean isMaybe = rawType == Maybe.class;
if (rawType != Observable.class && !isFlowable && !isSingle && !isMaybe) {
return null;
}
boolean isResult = false;
boolean isBody = false;
Type responseType;
if (!(returnType instanceof ParameterizedType)) {
String name =
isFlowable ? "Flowable" : isSingle ? "Single" : isMaybe ? "Maybe" : "Observable";
throw new IllegalStateException(
name
+ " return type must be parameterized"
+ " as "
+ name
+ "<Foo> or "
+ name
+ "<? extends Foo>");
}
Type observableType = getParameterUpperBound(0, (ParameterizedType) returnType);
Class<?> rawObservableType = getRawType(observableType);
if (rawObservableType == Response.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Response must be parameterized" + " as Response<Foo> or Response<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
} else if (rawObservableType == Result.class) {
if (!(observableType instanceof ParameterizedType)) {
throw new IllegalStateException(
"Result must be parameterized" + " as Result<Foo> or Result<? extends Foo>");
}
responseType = getParameterUpperBound(0, (ParameterizedType) observableType);
isResult = true;
} else {
responseType = observableType;
isBody = true;
}
return new RxJava3CallAdapter(
responseType, scheduler, isAsync, isResult, isBody, isFlowable, isSingle, isMaybe, false);
} |
899555_0 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_1 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_2 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_3 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_4 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_5 | static Collection<String> elemental2ElementTags(final MetaClass type) {
final Collection<String> customElementTags = customElementTags(type);
if (!customElementTags.isEmpty()) {
return customElementTags;
}
return Elemental2TagMapping.getTags(type.asClass());
} |
899555_6 | static Collection<String> getTags(final Class<?> elemental2ElementClass) {
if (elemental2ElementClass == null || Element.class.equals(elemental2ElementClass)) {
return Collections.emptyList();
}
final Collection<String> tags = TAG_NAMES_BY_DOM_INTERFACE.get(elemental2ElementClass);
if (tags.isEmpty()) {
return getTags(elemental2ElementClass.getSuperclass());
}
return tags;
} |
899555_7 | @Override
public void generateDecorator(final Decorable decorable, final FactoryController controller) {
final MetaClass declaringClass = decorable.getDecorableDeclaringType();
final Templated anno = (Templated) decorable.getAnnotation();
final Class<?> templateProvider = anno.provider();
final boolean customProvider = templateProvider != Templated.DEFAULT_PROVIDER.class;
final Optional<String> styleSheetPath = getTemplateStyleSheetPath(declaringClass);
final boolean explicitStyleSheetPresent = styleSheetPath.filter(path -> Thread.currentThread().getContextClassLoader().getResource(path) != null).isPresent();
if (declaringClass.isAssignableTo(Composite.class)) {
logger.warn("The @Templated class, {}, extends Composite. This will not be supported in future versions.", declaringClass.getFullyQualifiedName());
}
if (styleSheetPath.isPresent() && !explicitStyleSheetPresent) {
throw new GenerationException("@Templated class [" + declaringClass.getFullyQualifiedName()
+ "] declared a stylesheet [" + styleSheetPath + "] that could not be found.");
}
final List<Statement> initStmts = new ArrayList<>();
generateTemplatedInitialization(decorable, controller, initStmts, customProvider);
if (customProvider) {
final Statement init =
Stmt.invokeStatic(TemplateUtil.class, "provideTemplate",
templateProvider,
getTemplateUrl(declaringClass),
Stmt.newObject(TemplateRenderingCallback.class)
.extend()
.publicOverridesMethod("renderTemplate", Parameter.of(String.class, "template", true))
.appendAll(initStmts)
.finish()
.finish());
controller.addInitializationStatements(Collections.singletonList(init));
}
else {
controller.addInitializationStatements(initStmts);
}
controller.addDestructionStatements(generateTemplateDestruction(decorable));
controller.addInitializationStatementsToEnd(Collections.<Statement>singletonList(invokeStatic(StyleBindingsRegistry.class, "get")
.invoke("updateStyles", Refs.get("instance"))));
} |
899555_8 | public static String getLocaleFromBundlePath(final String bundlePath) {
final Matcher matcher = LOCALE_IN_FILENAME_PATTERN.matcher(bundlePath);
if (matcher != null && matcher.matches()) {
final StringBuilder locale = new StringBuilder();
final String lang = matcher.group(2);
if (lang != null)
locale.append(lang);
final String region = matcher.group(3);
if (region != null)
locale.append("_").append(region.substring(1));
return locale.toString();
}
else {
return null;
}
} |
899555_9 | @SuppressWarnings({ "rawtypes", "unchecked" })
protected static Set<String> recordBundleKeys(final Map<String, Set<String>> discoveredI18nMap, final String locale, final String bundlePath) {
InputStream is = null;
final Set<String> duplicates = new HashSet<>();
try {
final Set<String> keys = discoveredI18nMap.computeIfAbsent(locale, l -> new HashSet<>());
is = TranslationServiceGenerator.class.getClassLoader().getResourceAsStream(bundlePath);
if (isJsonBundle(bundlePath)) {
final JsonFactory jsonFactory = new JsonFactory();
final JsonParser jp = jsonFactory.createJsonParser(is);
JsonToken token = jp.nextToken();
while (token != null) {
token = jp.nextToken();
if (token == JsonToken.FIELD_NAME) {
final String name = jp.getCurrentName();
if (keys.contains(name)) {
duplicates.add(name);
}
keys.add(name);
}
}
}
else {
final Properties properties = new Properties();
properties.load(is);
final Set<String> propertFileKeys = (Set) properties.keySet();
propertFileKeys
.stream()
.filter(key -> keys.contains(key))
.collect(Collectors.toCollection(() -> duplicates));
keys.addAll(propertFileKeys);
}
}
catch (final Exception e) {
throw new RuntimeException(e);
}
finally {
IOUtils.closeQuietly(is);
}
return duplicates;
} |
901534_0 | @Override
public XmlModel loadModel(InputStream xmlStream) throws ModelException {
if (xmlStream == null) {
throw new ModelException("XML model is not valid [null].");
}
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(xmlStream);
return new XmlModel(new XmlDocument(doc));
} catch (IOException ioe) {
logger.error(ioe, "Cannot load XML model.");
throw new XmlModelException("Cannot load XML model", ioe);
} catch (ParserConfigurationException pce) {
logger.error(pce, "Cannot parse XML file model.");
throw new XmlModelException("Cannot parse XML model", pce);
} catch (SAXException se) {
logger.error(se, "Cannot parse XML file model.");
throw new XmlModelException("Cannot parse XML model.", se);
}
} |
901534_1 | @Override
public UmlModel loadModel(File modelFile) throws UmlModelException {
if (modelFile == null) {
return new UmlModel(UmlModelProducer.getInstance().createUmlModel(null));
}
try {
Model model = getUmlRootModel(modelFile);
UmlModel umlModel = new UmlModel(model);
return umlModel;
} catch (IOException e) {
logger.error(e, "Canot load Template " + modelFile.getName());
throw new UmlModelException("Cannot load Template " + modelFile.getName(), e);
} catch (RuntimeException re) {
logger.error(re, "Canot load Template " + modelFile.getName());
throw new UmlModelException("Cannot load Template " + modelFile.getName(), re);
}
} |
904044_0 | public synchronized XPathRecordReader addField(String name, String xpath, boolean multiValued) {
addField0(xpath, name, multiValued, false, 0);
return this;
} |
904044_1 | ; |
904044_2 | ; |
904044_3 | ; |
904044_4 | ; |
904044_5 | ; |
904044_6 | ; |
904044_7 | ; |
904044_8 | ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.