repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Netflix/dyno | dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/hash/Murmur1Hash.java | Murmur1Hash.hash | public static int hash(ByteBuffer buf, int seed) {
// save byte order for later restoration
ByteOrder byteOrder = buf.order();
buf.order(ByteOrder.LITTLE_ENDIAN);
int m = 0x5bd1e995;
int r = 24;
int h = seed ^ buf.remaining();
while (buf.remaining() >= 4) {
int k = buf.getInt();
k *= m;
k ^= k >>> r;
k *= m;
h *= m;
h ^= k;
}
if (buf.remaining() > 0) {
ByteBuffer finish = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
// for big-endian version, use this first:
// finish.position(4-buf.remaining());
finish.put(buf).rewind();
h ^= finish.getInt();
h *= m;
}
h ^= h >>> 13;
h *= m;
h ^= h >>> 15;
buf.order(byteOrder);
return h;
} | java | public static int hash(ByteBuffer buf, int seed) {
// save byte order for later restoration
ByteOrder byteOrder = buf.order();
buf.order(ByteOrder.LITTLE_ENDIAN);
int m = 0x5bd1e995;
int r = 24;
int h = seed ^ buf.remaining();
while (buf.remaining() >= 4) {
int k = buf.getInt();
k *= m;
k ^= k >>> r;
k *= m;
h *= m;
h ^= k;
}
if (buf.remaining() > 0) {
ByteBuffer finish = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
// for big-endian version, use this first:
// finish.position(4-buf.remaining());
finish.put(buf).rewind();
h ^= finish.getInt();
h *= m;
}
h ^= h >>> 13;
h *= m;
h ^= h >>> 15;
buf.order(byteOrder);
return h;
} | [
"public",
"static",
"int",
"hash",
"(",
"ByteBuffer",
"buf",
",",
"int",
"seed",
")",
"{",
"// save byte order for later restoration",
"ByteOrder",
"byteOrder",
"=",
"buf",
".",
"order",
"(",
")",
";",
"buf",
".",
"order",
"(",
"ByteOrder",
".",
"LITTLE_ENDIAN... | Hashes the bytes in a buffer from the current position to the limit.
@param buf The bytes to hash.
@param seed The seed for the hash.
@return The 32 bit murmur hash of the bytes in the buffer. | [
"Hashes",
"the",
"bytes",
"in",
"a",
"buffer",
"from",
"the",
"current",
"position",
"to",
"the",
"limit",
"."
] | 158f807083ea8e9b09c8089cb07f98e954ad5b23 | https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/hash/Murmur1Hash.java#L48-L85 | train |
Netflix/dyno | dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java | HttpEndpointBasedTokenMapSupplier.getTopologyJsonPayload | @Override
public String getTopologyJsonPayload(Set<Host> activeHosts) {
int count = NUM_RETRIER_ACROSS_NODES;
String response;
Exception lastEx = null;
do {
try {
response = getTopologyFromRandomNodeWithRetry(activeHosts);
if (response != null) {
return response;
}
} catch (Exception e) {
lastEx = e;
} finally {
count--;
}
} while ((count > 0));
if (lastEx != null) {
if (lastEx instanceof ConnectTimeoutException) {
throw new TimeoutException("Unable to obtain topology", lastEx);
}
throw new DynoException(lastEx);
} else {
throw new DynoException("Could not contact dynomite for token map");
}
} | java | @Override
public String getTopologyJsonPayload(Set<Host> activeHosts) {
int count = NUM_RETRIER_ACROSS_NODES;
String response;
Exception lastEx = null;
do {
try {
response = getTopologyFromRandomNodeWithRetry(activeHosts);
if (response != null) {
return response;
}
} catch (Exception e) {
lastEx = e;
} finally {
count--;
}
} while ((count > 0));
if (lastEx != null) {
if (lastEx instanceof ConnectTimeoutException) {
throw new TimeoutException("Unable to obtain topology", lastEx);
}
throw new DynoException(lastEx);
} else {
throw new DynoException("Could not contact dynomite for token map");
}
} | [
"@",
"Override",
"public",
"String",
"getTopologyJsonPayload",
"(",
"Set",
"<",
"Host",
">",
"activeHosts",
")",
"{",
"int",
"count",
"=",
"NUM_RETRIER_ACROSS_NODES",
";",
"String",
"response",
";",
"Exception",
"lastEx",
"=",
"null",
";",
"do",
"{",
"try",
... | Tries to get topology information by randomly trying across nodes. | [
"Tries",
"to",
"get",
"topology",
"information",
"by",
"randomly",
"trying",
"across",
"nodes",
"."
] | 158f807083ea8e9b09c8089cb07f98e954ad5b23 | https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java#L82-L110 | train |
Netflix/dyno | dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java | HttpEndpointBasedTokenMapSupplier.getRandomHost | public Host getRandomHost(Set<Host> activeHosts) {
Random random = new Random();
List<Host> hostsUp = new ArrayList<Host>(CollectionUtils.filter(activeHosts, new Predicate<Host>() {
@Override
public boolean apply(Host x) {
return x.isUp();
}
}));
return hostsUp.get(random.nextInt(hostsUp.size()));
} | java | public Host getRandomHost(Set<Host> activeHosts) {
Random random = new Random();
List<Host> hostsUp = new ArrayList<Host>(CollectionUtils.filter(activeHosts, new Predicate<Host>() {
@Override
public boolean apply(Host x) {
return x.isUp();
}
}));
return hostsUp.get(random.nextInt(hostsUp.size()));
} | [
"public",
"Host",
"getRandomHost",
"(",
"Set",
"<",
"Host",
">",
"activeHosts",
")",
"{",
"Random",
"random",
"=",
"new",
"Random",
"(",
")",
";",
"List",
"<",
"Host",
">",
"hostsUp",
"=",
"new",
"ArrayList",
"<",
"Host",
">",
"(",
"CollectionUtils",
"... | Finds a random host from the set of active hosts to perform
cluster_describe
@param activeHosts
@return a random host | [
"Finds",
"a",
"random",
"host",
"from",
"the",
"set",
"of",
"active",
"hosts",
"to",
"perform",
"cluster_describe"
] | 158f807083ea8e9b09c8089cb07f98e954ad5b23 | https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java#L156-L168 | train |
Netflix/dyno | dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java | HttpEndpointBasedTokenMapSupplier.getTopologyFromRandomNodeWithRetry | private String getTopologyFromRandomNodeWithRetry(Set<Host> activeHosts) {
int count = NUM_RETRIES_PER_NODE;
String nodeResponse;
Exception lastEx;
final Host randomHost = getRandomHost(activeHosts);
do {
try {
lastEx = null;
nodeResponse = getResponseViaHttp(randomHost.getHostName());
if (nodeResponse != null) {
Logger.info("Received topology from " + randomHost);
return nodeResponse;
}
} catch (Exception e) {
Logger.info("cannot get topology from : " + randomHost);
lastEx = e;
} finally {
count--;
}
} while ((count > 0));
if (lastEx != null) {
if (lastEx instanceof ConnectTimeoutException) {
throw new TimeoutException("Unable to obtain topology", lastEx).setHost(randomHost);
}
throw new DynoException(String.format("Unable to obtain topology from %s", randomHost), lastEx);
} else {
throw new DynoException(String.format("Could not contact dynomite manager for token map on %s", randomHost));
}
} | java | private String getTopologyFromRandomNodeWithRetry(Set<Host> activeHosts) {
int count = NUM_RETRIES_PER_NODE;
String nodeResponse;
Exception lastEx;
final Host randomHost = getRandomHost(activeHosts);
do {
try {
lastEx = null;
nodeResponse = getResponseViaHttp(randomHost.getHostName());
if (nodeResponse != null) {
Logger.info("Received topology from " + randomHost);
return nodeResponse;
}
} catch (Exception e) {
Logger.info("cannot get topology from : " + randomHost);
lastEx = e;
} finally {
count--;
}
} while ((count > 0));
if (lastEx != null) {
if (lastEx instanceof ConnectTimeoutException) {
throw new TimeoutException("Unable to obtain topology", lastEx).setHost(randomHost);
}
throw new DynoException(String.format("Unable to obtain topology from %s", randomHost), lastEx);
} else {
throw new DynoException(String.format("Could not contact dynomite manager for token map on %s", randomHost));
}
} | [
"private",
"String",
"getTopologyFromRandomNodeWithRetry",
"(",
"Set",
"<",
"Host",
">",
"activeHosts",
")",
"{",
"int",
"count",
"=",
"NUM_RETRIES_PER_NODE",
";",
"String",
"nodeResponse",
";",
"Exception",
"lastEx",
";",
"final",
"Host",
"randomHost",
"=",
"getR... | Tries multiple nodes, and it only bubbles up the last node's exception.
We want to bubble up the exception in order for the last node to be
removed from the connection pool.
@param activeHosts
@return the topology from cluster_describe | [
"Tries",
"multiple",
"nodes",
"and",
"it",
"only",
"bubbles",
"up",
"the",
"last",
"node",
"s",
"exception",
".",
"We",
"want",
"to",
"bubble",
"up",
"the",
"exception",
"in",
"order",
"for",
"the",
"last",
"node",
"to",
"be",
"removed",
"from",
"the",
... | 158f807083ea8e9b09c8089cb07f98e954ad5b23 | https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/HttpEndpointBasedTokenMapSupplier.java#L178-L209 | train |
Netflix/dyno | dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/AbstractTokenMapSupplier.java | AbstractTokenMapSupplier.parseTokenListFromJson | List<HostToken> parseTokenListFromJson(String json) {
List<HostToken> hostTokens = new ArrayList<HostToken>();
JSONParser parser = new JSONParser();
try {
JSONArray arr = (JSONArray) parser.parse(json);
Iterator<?> iter = arr.iterator();
while (iter.hasNext()) {
Object item = iter.next();
if (!(item instanceof JSONObject)) {
continue;
}
JSONObject jItem = (JSONObject) item;
Long token = Long.parseLong((String) jItem.get("token"));
String hostname = (String) jItem.get("hostname");
String ipAddress = (String) jItem.get("ip");
String zone = (String) jItem.get("zone");
String datacenter = (String) jItem.get("dc");
String portStr = (String) jItem.get("port");
String securePortStr = (String) jItem.get("secure_port");
String hashtag = (String) jItem.get("hashtag");
int port = Host.DEFAULT_PORT;
if (portStr != null) {
port = Integer.valueOf(portStr);
}
int securePort = port;
if (securePortStr != null) {
securePort = Integer.valueOf(securePortStr);
}
Host host = new Host(hostname, ipAddress, port, securePort, zone, datacenter, Status.Up, hashtag);
if (isLocalDatacenterHost(host)) {
HostToken hostToken = new HostToken(token, host);
hostTokens.add(hostToken);
}
}
} catch (ParseException e) {
Logger.error("Failed to parse json response: " + json, e);
throw new RuntimeException(e);
}
return hostTokens;
} | java | List<HostToken> parseTokenListFromJson(String json) {
List<HostToken> hostTokens = new ArrayList<HostToken>();
JSONParser parser = new JSONParser();
try {
JSONArray arr = (JSONArray) parser.parse(json);
Iterator<?> iter = arr.iterator();
while (iter.hasNext()) {
Object item = iter.next();
if (!(item instanceof JSONObject)) {
continue;
}
JSONObject jItem = (JSONObject) item;
Long token = Long.parseLong((String) jItem.get("token"));
String hostname = (String) jItem.get("hostname");
String ipAddress = (String) jItem.get("ip");
String zone = (String) jItem.get("zone");
String datacenter = (String) jItem.get("dc");
String portStr = (String) jItem.get("port");
String securePortStr = (String) jItem.get("secure_port");
String hashtag = (String) jItem.get("hashtag");
int port = Host.DEFAULT_PORT;
if (portStr != null) {
port = Integer.valueOf(portStr);
}
int securePort = port;
if (securePortStr != null) {
securePort = Integer.valueOf(securePortStr);
}
Host host = new Host(hostname, ipAddress, port, securePort, zone, datacenter, Status.Up, hashtag);
if (isLocalDatacenterHost(host)) {
HostToken hostToken = new HostToken(token, host);
hostTokens.add(hostToken);
}
}
} catch (ParseException e) {
Logger.error("Failed to parse json response: " + json, e);
throw new RuntimeException(e);
}
return hostTokens;
} | [
"List",
"<",
"HostToken",
">",
"parseTokenListFromJson",
"(",
"String",
"json",
")",
"{",
"List",
"<",
"HostToken",
">",
"hostTokens",
"=",
"new",
"ArrayList",
"<",
"HostToken",
">",
"(",
")",
";",
"JSONParser",
"parser",
"=",
"new",
"JSONParser",
"(",
")"... | package-private for Test | [
"package",
"-",
"private",
"for",
"Test"
] | 158f807083ea8e9b09c8089cb07f98e954ad5b23 | https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-core/src/main/java/com/netflix/dyno/connectionpool/impl/lb/AbstractTokenMapSupplier.java#L210-L258 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java | ProfileRequest.start | @Override
public void start(final BaseCallback<Authentication, AuthenticationException> callback) {
credentialsRequest.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(final Credentials credentials) {
userInfoRequest
.addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken())
.start(new BaseCallback<UserProfile, AuthenticationException>() {
@Override
public void onSuccess(UserProfile profile) {
callback.onSuccess(new Authentication(profile, credentials));
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
} | java | @Override
public void start(final BaseCallback<Authentication, AuthenticationException> callback) {
credentialsRequest.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(final Credentials credentials) {
userInfoRequest
.addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken())
.start(new BaseCallback<UserProfile, AuthenticationException>() {
@Override
public void onSuccess(UserProfile profile) {
callback.onSuccess(new Authentication(profile, credentials));
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
} | [
"@",
"Override",
"public",
"void",
"start",
"(",
"final",
"BaseCallback",
"<",
"Authentication",
",",
"AuthenticationException",
">",
"callback",
")",
"{",
"credentialsRequest",
".",
"start",
"(",
"new",
"BaseCallback",
"<",
"Credentials",
",",
"AuthenticationExcept... | Starts the log in request and then fetches the user's profile
@param callback called on either success or failure | [
"Starts",
"the",
"log",
"in",
"request",
"and",
"then",
"fetches",
"the",
"user",
"s",
"profile"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java#L92-L117 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java | ProfileRequest.execute | @Override
public Authentication execute() throws Auth0Exception {
Credentials credentials = credentialsRequest.execute();
UserProfile profile = userInfoRequest
.addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken())
.execute();
return new Authentication(profile, credentials);
} | java | @Override
public Authentication execute() throws Auth0Exception {
Credentials credentials = credentialsRequest.execute();
UserProfile profile = userInfoRequest
.addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken())
.execute();
return new Authentication(profile, credentials);
} | [
"@",
"Override",
"public",
"Authentication",
"execute",
"(",
")",
"throws",
"Auth0Exception",
"{",
"Credentials",
"credentials",
"=",
"credentialsRequest",
".",
"execute",
"(",
")",
";",
"UserProfile",
"profile",
"=",
"userInfoRequest",
".",
"addHeader",
"(",
"HEA... | Logs in the user with Auth0 and fetches it's profile.
@return authentication object containing the user's tokens and profile
@throws Auth0Exception when either authentication or profile fetch fails | [
"Logs",
"in",
"the",
"user",
"with",
"Auth0",
"and",
"fetches",
"it",
"s",
"profile",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java#L125-L132 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/result/UserProfile.java | UserProfile.getExtraInfo | public Map<String, Object> getExtraInfo() {
return extraInfo != null ? new HashMap<>(extraInfo) : Collections.<String, Object>emptyMap();
} | java | public Map<String, Object> getExtraInfo() {
return extraInfo != null ? new HashMap<>(extraInfo) : Collections.<String, Object>emptyMap();
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getExtraInfo",
"(",
")",
"{",
"return",
"extraInfo",
"!=",
"null",
"?",
"new",
"HashMap",
"<>",
"(",
"extraInfo",
")",
":",
"Collections",
".",
"<",
"String",
",",
"Object",
">",
"emptyMap",
"(",
")"... | Returns extra information of the profile that is not part of the normalized profile
@return a map with user's extra information found in the profile | [
"Returns",
"extra",
"information",
"of",
"the",
"profile",
"that",
"is",
"not",
"part",
"of",
"the",
"normalized",
"profile"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/result/UserProfile.java#L129-L131 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/SignUpRequest.java | SignUpRequest.addAuthenticationParameters | @Override
public SignUpRequest addAuthenticationParameters(Map<String, Object> parameters) {
authenticationRequest.addAuthenticationParameters(parameters);
return this;
} | java | @Override
public SignUpRequest addAuthenticationParameters(Map<String, Object> parameters) {
authenticationRequest.addAuthenticationParameters(parameters);
return this;
} | [
"@",
"Override",
"public",
"SignUpRequest",
"addAuthenticationParameters",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"authenticationRequest",
".",
"addAuthenticationParameters",
"(",
"parameters",
")",
";",
"return",
"this",
";",
"}"
] | Add additional parameters sent when logging the user in
@param parameters sent with the request and must be non-null
@return itself
@see ParameterBuilder | [
"Add",
"additional",
"parameters",
"sent",
"when",
"logging",
"the",
"user",
"in"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/SignUpRequest.java#L88-L92 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/SignUpRequest.java | SignUpRequest.start | @Override
public void start(final BaseCallback<Credentials, AuthenticationException> callback) {
signUpRequest.start(new BaseCallback<DatabaseUser, AuthenticationException>() {
@Override
public void onSuccess(final DatabaseUser user) {
authenticationRequest.start(callback);
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
} | java | @Override
public void start(final BaseCallback<Credentials, AuthenticationException> callback) {
signUpRequest.start(new BaseCallback<DatabaseUser, AuthenticationException>() {
@Override
public void onSuccess(final DatabaseUser user) {
authenticationRequest.start(callback);
}
@Override
public void onFailure(AuthenticationException error) {
callback.onFailure(error);
}
});
} | [
"@",
"Override",
"public",
"void",
"start",
"(",
"final",
"BaseCallback",
"<",
"Credentials",
",",
"AuthenticationException",
">",
"callback",
")",
"{",
"signUpRequest",
".",
"start",
"(",
"new",
"BaseCallback",
"<",
"DatabaseUser",
",",
"AuthenticationException",
... | Starts to execute create user request and then logs the user in.
@param callback called on either success or failure. | [
"Starts",
"to",
"execute",
"create",
"user",
"request",
"and",
"then",
"logs",
"the",
"user",
"in",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/SignUpRequest.java#L143-L156 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java | CustomTabsController.bindService | public void bindService() {
Log.v(TAG, "Trying to bind the service");
Context context = this.context.get();
isBound = false;
if (context != null && preferredPackage != null) {
isBound = CustomTabsClient.bindCustomTabsService(context, preferredPackage, this);
}
Log.v(TAG, "Bind request result: " + isBound);
} | java | public void bindService() {
Log.v(TAG, "Trying to bind the service");
Context context = this.context.get();
isBound = false;
if (context != null && preferredPackage != null) {
isBound = CustomTabsClient.bindCustomTabsService(context, preferredPackage, this);
}
Log.v(TAG, "Bind request result: " + isBound);
} | [
"public",
"void",
"bindService",
"(",
")",
"{",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"Trying to bind the service\"",
")",
";",
"Context",
"context",
"=",
"this",
".",
"context",
".",
"get",
"(",
")",
";",
"isBound",
"=",
"false",
";",
"if",
"(",
"contex... | Attempts to bind the Custom Tabs Service to the Context. | [
"Attempts",
"to",
"bind",
"the",
"Custom",
"Tabs",
"Service",
"to",
"the",
"Context",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java#L93-L101 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java | CustomTabsController.unbindService | public void unbindService() {
Log.v(TAG, "Trying to unbind the service");
Context context = this.context.get();
if (isBound && context != null) {
context.unbindService(this);
isBound = false;
}
} | java | public void unbindService() {
Log.v(TAG, "Trying to unbind the service");
Context context = this.context.get();
if (isBound && context != null) {
context.unbindService(this);
isBound = false;
}
} | [
"public",
"void",
"unbindService",
"(",
")",
"{",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"Trying to unbind the service\"",
")",
";",
"Context",
"context",
"=",
"this",
".",
"context",
".",
"get",
"(",
")",
";",
"if",
"(",
"isBound",
"&&",
"context",
"!=",
... | Attempts to unbind the Custom Tabs Service from the Context. | [
"Attempts",
"to",
"unbind",
"the",
"Custom",
"Tabs",
"Service",
"from",
"the",
"Context",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java#L106-L113 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/PKCE.java | PKCE.getToken | public void getToken(String authorizationCode, @NonNull final AuthCallback callback) {
apiClient.token(authorizationCode, redirectUri)
.setCodeVerifier(codeVerifier)
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
callback.onSuccess(payload);
}
@Override
public void onFailure(AuthenticationException error) {
if ("Unauthorized".equals(error.getDescription())) {
Log.e(TAG, "Please go to 'https://manage.auth0.com/#/applications/" + apiClient.getClientId() + "/settings' and set 'Client Type' to 'Native' to enable PKCE.");
}
callback.onFailure(error);
}
});
} | java | public void getToken(String authorizationCode, @NonNull final AuthCallback callback) {
apiClient.token(authorizationCode, redirectUri)
.setCodeVerifier(codeVerifier)
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
callback.onSuccess(payload);
}
@Override
public void onFailure(AuthenticationException error) {
if ("Unauthorized".equals(error.getDescription())) {
Log.e(TAG, "Please go to 'https://manage.auth0.com/#/applications/" + apiClient.getClientId() + "/settings' and set 'Client Type' to 'Native' to enable PKCE.");
}
callback.onFailure(error);
}
});
} | [
"public",
"void",
"getToken",
"(",
"String",
"authorizationCode",
",",
"@",
"NonNull",
"final",
"AuthCallback",
"callback",
")",
"{",
"apiClient",
".",
"token",
"(",
"authorizationCode",
",",
"redirectUri",
")",
".",
"setCodeVerifier",
"(",
"codeVerifier",
")",
... | Performs a request to the Auth0 API to get the OAuth Token and end the PKCE flow.
The instance of this class must be disposed after this method is called.
@param authorizationCode received in the call to /authorize with a "grant_type=code"
@param callback to notify the result of this call to. | [
"Performs",
"a",
"request",
"to",
"the",
"Auth0",
"API",
"to",
"get",
"the",
"OAuth",
"Token",
"and",
"end",
"the",
"PKCE",
"flow",
".",
"The",
"instance",
"of",
"this",
"class",
"must",
"be",
"disposed",
"after",
"this",
"method",
"is",
"called",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/PKCE.java#L84-L101 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/AuthProvider.java | AuthProvider.checkPermissions | private boolean checkPermissions(Activity activity) {
String[] permissions = getRequiredAndroidPermissions();
return handler.areAllPermissionsGranted(activity, permissions);
} | java | private boolean checkPermissions(Activity activity) {
String[] permissions = getRequiredAndroidPermissions();
return handler.areAllPermissionsGranted(activity, permissions);
} | [
"private",
"boolean",
"checkPermissions",
"(",
"Activity",
"activity",
")",
"{",
"String",
"[",
"]",
"permissions",
"=",
"getRequiredAndroidPermissions",
"(",
")",
";",
"return",
"handler",
".",
"areAllPermissionsGranted",
"(",
"activity",
",",
"permissions",
")",
... | Checks if all the required Android Manifest.permissions have already been granted.
@param activity a valid activity context.
@return true if all the requested permissions are already granted, false otherwise. | [
"Checks",
"if",
"all",
"the",
"required",
"Android",
"Manifest",
".",
"permissions",
"have",
"already",
"been",
"granted",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/AuthProvider.java#L185-L188 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/AuthProvider.java | AuthProvider.requestPermissions | private void requestPermissions(Activity activity, int requestCode) {
String[] permissions = getRequiredAndroidPermissions();
handler.requestPermissions(activity, permissions, requestCode);
} | java | private void requestPermissions(Activity activity, int requestCode) {
String[] permissions = getRequiredAndroidPermissions();
handler.requestPermissions(activity, permissions, requestCode);
} | [
"private",
"void",
"requestPermissions",
"(",
"Activity",
"activity",
",",
"int",
"requestCode",
")",
"{",
"String",
"[",
"]",
"permissions",
"=",
"getRequiredAndroidPermissions",
"(",
")",
";",
"handler",
".",
"requestPermissions",
"(",
"activity",
",",
"permissi... | Starts the async Permission Request. The caller activity will be notified of the result on the
onRequestPermissionsResult method, from the ActivityCompat.OnRequestPermissionsResultCallback
interface.
@param activity a valid activity context. It will receive the permissions
request result on the onRequestPermissionsResult method.
@param requestCode the code to use for the Permissions Request. | [
"Starts",
"the",
"async",
"Permission",
"Request",
".",
"The",
"caller",
"activity",
"will",
"be",
"notified",
"of",
"the",
"result",
"on",
"the",
"onRequestPermissionsResult",
"method",
"from",
"the",
"ActivityCompat",
".",
"OnRequestPermissionsResultCallback",
"inte... | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/AuthProvider.java#L199-L202 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java | DelegationRequest.addParameters | public DelegationRequest<T> addParameters(Map<String, Object> parameters) {
request.addParameters(parameters);
return this;
} | java | public DelegationRequest<T> addParameters(Map<String, Object> parameters) {
request.addParameters(parameters);
return this;
} | [
"public",
"DelegationRequest",
"<",
"T",
">",
"addParameters",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"request",
".",
"addParameters",
"(",
"parameters",
")",
";",
"return",
"this",
";",
"}"
] | Add additional parameters to be sent in the request
@param parameters as a non-null dictionary
@return itself | [
"Add",
"additional",
"parameters",
"to",
"be",
"sent",
"in",
"the",
"request"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java#L64-L67 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java | DelegationRequest.setScope | public DelegationRequest<T> setScope(String scope) {
request.addParameter(ParameterBuilder.SCOPE_KEY, scope);
return this;
} | java | public DelegationRequest<T> setScope(String scope) {
request.addParameter(ParameterBuilder.SCOPE_KEY, scope);
return this;
} | [
"public",
"DelegationRequest",
"<",
"T",
">",
"setScope",
"(",
"String",
"scope",
")",
"{",
"request",
".",
"addParameter",
"(",
"ParameterBuilder",
".",
"SCOPE_KEY",
",",
"scope",
")",
";",
"return",
"this",
";",
"}"
] | Set the 'scope' used to make the delegation
@param scope value
@return itself | [
"Set",
"the",
"scope",
"used",
"to",
"make",
"the",
"delegation"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java#L86-L89 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java | AuthenticationAPIClient.passwordless | @SuppressWarnings("WeakerAccess")
private ParameterizableRequest<Void, AuthenticationException> passwordless() {
HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder()
.addPathSegment(PASSWORDLESS_PATH)
.addPathSegment(START_PATH)
.build();
final Map<String, Object> parameters = ParameterBuilder.newBuilder()
.setClientId(getClientId())
.asDictionary();
return factory.POST(url, client, gson, authErrorBuilder)
.addParameters(parameters);
} | java | @SuppressWarnings("WeakerAccess")
private ParameterizableRequest<Void, AuthenticationException> passwordless() {
HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder()
.addPathSegment(PASSWORDLESS_PATH)
.addPathSegment(START_PATH)
.build();
final Map<String, Object> parameters = ParameterBuilder.newBuilder()
.setClientId(getClientId())
.asDictionary();
return factory.POST(url, client, gson, authErrorBuilder)
.addParameters(parameters);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"private",
"ParameterizableRequest",
"<",
"Void",
",",
"AuthenticationException",
">",
"passwordless",
"(",
")",
"{",
"HttpUrl",
"url",
"=",
"HttpUrl",
".",
"parse",
"(",
"auth0",
".",
"getDomainUrl",
"(",
"... | Start a custom passwordless flow
@return a request to configure and start | [
"Start",
"a",
"custom",
"passwordless",
"flow"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java#L1005-L1018 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/request/internal/BaseAuthenticationRequest.java | BaseAuthenticationRequest.setConnection | @Override
public AuthenticationRequest setConnection(String connection) {
if (!hasLegacyPath()) {
Log.w(TAG, "Not setting the 'connection' parameter as the request is using a OAuth 2.0 API Authorization endpoint that doesn't support it.");
return this;
}
addParameter(CONNECTION_KEY, connection);
return this;
} | java | @Override
public AuthenticationRequest setConnection(String connection) {
if (!hasLegacyPath()) {
Log.w(TAG, "Not setting the 'connection' parameter as the request is using a OAuth 2.0 API Authorization endpoint that doesn't support it.");
return this;
}
addParameter(CONNECTION_KEY, connection);
return this;
} | [
"@",
"Override",
"public",
"AuthenticationRequest",
"setConnection",
"(",
"String",
"connection",
")",
"{",
"if",
"(",
"!",
"hasLegacyPath",
"(",
")",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Not setting the 'connection' parameter as the request is using a OAuth... | Sets the 'connection' parameter.
@param connection name of the connection
@return itself | [
"Sets",
"the",
"connection",
"parameter",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/request/internal/BaseAuthenticationRequest.java#L53-L61 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/request/internal/BaseAuthenticationRequest.java | BaseAuthenticationRequest.setRealm | @Override
public AuthenticationRequest setRealm(String realm) {
if (hasLegacyPath()) {
Log.w(TAG, "Not setting the 'realm' parameter as the request is using a Legacy Authorization API endpoint that doesn't support it.");
return this;
}
addParameter(REALM_KEY, realm);
return this;
} | java | @Override
public AuthenticationRequest setRealm(String realm) {
if (hasLegacyPath()) {
Log.w(TAG, "Not setting the 'realm' parameter as the request is using a Legacy Authorization API endpoint that doesn't support it.");
return this;
}
addParameter(REALM_KEY, realm);
return this;
} | [
"@",
"Override",
"public",
"AuthenticationRequest",
"setRealm",
"(",
"String",
"realm",
")",
"{",
"if",
"(",
"hasLegacyPath",
"(",
")",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Not setting the 'realm' parameter as the request is using a Legacy Authorization API en... | Sets the 'realm' parameter. A realm identifies the host against which the authentication will be made, and usually helps to know which username and password to use.
@param realm name of the realm
@return itself | [
"Sets",
"the",
"realm",
"parameter",
".",
"A",
"realm",
"identifies",
"the",
"host",
"against",
"which",
"the",
"authentication",
"will",
"be",
"made",
"and",
"usually",
"helps",
"to",
"know",
"which",
"username",
"and",
"password",
"to",
"use",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/request/internal/BaseAuthenticationRequest.java#L69-L77 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java | DatabaseConnectionRequest.addParameters | public DatabaseConnectionRequest<T, U> addParameters(Map<String, Object> parameters) {
request.addParameters(parameters);
return this;
} | java | public DatabaseConnectionRequest<T, U> addParameters(Map<String, Object> parameters) {
request.addParameters(parameters);
return this;
} | [
"public",
"DatabaseConnectionRequest",
"<",
"T",
",",
"U",
">",
"addParameters",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"request",
".",
"addParameters",
"(",
"parameters",
")",
";",
"return",
"this",
";",
"}"
] | Add the given parameters to the request
@param parameters to be sent with the request
@return itself | [
"Add",
"the",
"given",
"parameters",
"to",
"the",
"request"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java#L27-L30 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java | DatabaseConnectionRequest.addParameter | public DatabaseConnectionRequest<T, U> addParameter(String name, Object value) {
request.addParameter(name, value);
return this;
} | java | public DatabaseConnectionRequest<T, U> addParameter(String name, Object value) {
request.addParameter(name, value);
return this;
} | [
"public",
"DatabaseConnectionRequest",
"<",
"T",
",",
"U",
">",
"addParameter",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"request",
".",
"addParameter",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Add a parameter by name to the request
@param name of the parameter
@param value of the parameter
@return itself | [
"Add",
"a",
"parameter",
"by",
"name",
"to",
"the",
"request"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java#L38-L41 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java | DatabaseConnectionRequest.setConnection | public DatabaseConnectionRequest<T, U> setConnection(String connection) {
request.addParameter(ParameterBuilder.CONNECTION_KEY, connection);
return this;
} | java | public DatabaseConnectionRequest<T, U> setConnection(String connection) {
request.addParameter(ParameterBuilder.CONNECTION_KEY, connection);
return this;
} | [
"public",
"DatabaseConnectionRequest",
"<",
"T",
",",
"U",
">",
"setConnection",
"(",
"String",
"connection",
")",
"{",
"request",
".",
"addParameter",
"(",
"ParameterBuilder",
".",
"CONNECTION_KEY",
",",
"connection",
")",
";",
"return",
"this",
";",
"}"
] | Set the Auth0 Database Connection used for this request using its name.
@param connection name
@return itself | [
"Set",
"the",
"Auth0",
"Database",
"Connection",
"used",
"for",
"this",
"request",
"using",
"its",
"name",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/request/DatabaseConnectionRequest.java#L59-L62 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/request/internal/OkHttpClientFactory.java | OkHttpClientFactory.createClient | public OkHttpClient createClient(boolean loggingEnabled, boolean tls12Enforced, int connectTimeout, int readTimeout, int writeTimeout) {
return modifyClient(new OkHttpClient(), loggingEnabled, tls12Enforced, connectTimeout, readTimeout, writeTimeout);
} | java | public OkHttpClient createClient(boolean loggingEnabled, boolean tls12Enforced, int connectTimeout, int readTimeout, int writeTimeout) {
return modifyClient(new OkHttpClient(), loggingEnabled, tls12Enforced, connectTimeout, readTimeout, writeTimeout);
} | [
"public",
"OkHttpClient",
"createClient",
"(",
"boolean",
"loggingEnabled",
",",
"boolean",
"tls12Enforced",
",",
"int",
"connectTimeout",
",",
"int",
"readTimeout",
",",
"int",
"writeTimeout",
")",
"{",
"return",
"modifyClient",
"(",
"new",
"OkHttpClient",
"(",
"... | This method creates an instance of OKHttpClient according to the provided parameters.
It is used internally and is not intended to be used directly.
@param loggingEnabled Enable logging in the created OkHttpClient.
@param tls12Enforced Enforce TLS 1.2 in the created OkHttpClient on devices with API 16-21
@param connectTimeout Override default connect timeout for OkHttpClient
@param readTimeout Override default read timeout for OkHttpClient
@param writeTimeout Override default write timeout for OkHttpClient
@return new OkHttpClient instance created according to the parameters. | [
"This",
"method",
"creates",
"an",
"instance",
"of",
"OKHttpClient",
"according",
"to",
"the",
"provided",
"parameters",
".",
"It",
"is",
"used",
"internally",
"and",
"is",
"not",
"intended",
"to",
"be",
"used",
"directly",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/request/internal/OkHttpClientFactory.java#L43-L45 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/request/internal/OkHttpClientFactory.java | OkHttpClientFactory.enforceTls12 | private void enforceTls12(OkHttpClient client) {
// No need to modify client as TLS 1.2 is enabled by default on API21+
// Lollipop is included because some Samsung devices face the same problem on API 21.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN
|| Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
return;
}
try {
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, null, null);
client.setSslSocketFactory(new TLS12SocketFactory(sc.getSocketFactory()));
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.build();
List<ConnectionSpec> specs = new ArrayList<>();
specs.add(cs);
specs.add(ConnectionSpec.COMPATIBLE_TLS);
specs.add(ConnectionSpec.CLEARTEXT);
client.setConnectionSpecs(specs);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
Log.e(TAG, "Error while setting TLS 1.2", e);
}
} | java | private void enforceTls12(OkHttpClient client) {
// No need to modify client as TLS 1.2 is enabled by default on API21+
// Lollipop is included because some Samsung devices face the same problem on API 21.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN
|| Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
return;
}
try {
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, null, null);
client.setSslSocketFactory(new TLS12SocketFactory(sc.getSocketFactory()));
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.build();
List<ConnectionSpec> specs = new ArrayList<>();
specs.add(cs);
specs.add(ConnectionSpec.COMPATIBLE_TLS);
specs.add(ConnectionSpec.CLEARTEXT);
client.setConnectionSpecs(specs);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
Log.e(TAG, "Error while setting TLS 1.2", e);
}
} | [
"private",
"void",
"enforceTls12",
"(",
"OkHttpClient",
"client",
")",
"{",
"// No need to modify client as TLS 1.2 is enabled by default on API21+",
"// Lollipop is included because some Samsung devices face the same problem on API 21.",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK... | Enable TLS 1.2 on the OkHttpClient on API 16-21, which is supported but not enabled by default.
@link https://github.com/square/okhttp/issues/2372
@see TLS12SocketFactory | [
"Enable",
"TLS",
"1",
".",
"2",
"on",
"the",
"OkHttpClient",
"on",
"API",
"16",
"-",
"21",
"which",
"is",
"supported",
"but",
"not",
"enabled",
"by",
"default",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/request/internal/OkHttpClientFactory.java#L80-L105 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/ParameterBuilder.java | ParameterBuilder.addAll | public ParameterBuilder addAll(Map<String, Object> parameters) {
if (parameters != null) {
for (String k : parameters.keySet()) {
if (parameters.get(k) != null) {
this.parameters.put(k, parameters.get(k));
}
}
}
return this;
} | java | public ParameterBuilder addAll(Map<String, Object> parameters) {
if (parameters != null) {
for (String k : parameters.keySet()) {
if (parameters.get(k) != null) {
this.parameters.put(k, parameters.get(k));
}
}
}
return this;
} | [
"public",
"ParameterBuilder",
"addAll",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
")",
"{",
"if",
"(",
"parameters",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"k",
":",
"parameters",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"("... | Adds all parameter from a map
@param parameters map with parameters to add. Null values will be skipped.
@return itself | [
"Adds",
"all",
"parameter",
"from",
"a",
"map"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/ParameterBuilder.java#L202-L211 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/AuthorizeResult.java | AuthorizeResult.isValid | public boolean isValid(int expectedRequestCode) {
Uri uri = intent != null ? intent.getData() : null;
if (uri == null) {
Log.d(TAG, "Result is invalid: Received Intent's Uri is null.");
return false;
}
if (requestCode == MISSING_REQUEST_CODE) {
return true;
}
boolean fromRequest = getRequestCode() == expectedRequestCode;
if (!fromRequest) {
Log.d(TAG, String.format("Result is invalid: Received Request Code doesn't match the expected one. Was %d but expected %d", getRequestCode(), expectedRequestCode));
}
return fromRequest && resultCode == Activity.RESULT_OK;
} | java | public boolean isValid(int expectedRequestCode) {
Uri uri = intent != null ? intent.getData() : null;
if (uri == null) {
Log.d(TAG, "Result is invalid: Received Intent's Uri is null.");
return false;
}
if (requestCode == MISSING_REQUEST_CODE) {
return true;
}
boolean fromRequest = getRequestCode() == expectedRequestCode;
if (!fromRequest) {
Log.d(TAG, String.format("Result is invalid: Received Request Code doesn't match the expected one. Was %d but expected %d", getRequestCode(), expectedRequestCode));
}
return fromRequest && resultCode == Activity.RESULT_OK;
} | [
"public",
"boolean",
"isValid",
"(",
"int",
"expectedRequestCode",
")",
"{",
"Uri",
"uri",
"=",
"intent",
"!=",
"null",
"?",
"intent",
".",
"getData",
"(",
")",
":",
"null",
";",
"if",
"(",
"uri",
"==",
"null",
")",
"{",
"Log",
".",
"d",
"(",
"TAG"... | Checks if the received data is valid and can be parsed.
@param expectedRequestCode the request code this activity is expecting to receive
@return whether if the received uri data can be parsed or not. | [
"Checks",
"if",
"the",
"received",
"data",
"is",
"valid",
"and",
"can",
"be",
"parsed",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/AuthorizeResult.java#L71-L87 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.java | CredentialsManager.hasValidCredentials | public boolean hasValidCredentials() {
String accessToken = storage.retrieveString(KEY_ACCESS_TOKEN);
String refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN);
String idToken = storage.retrieveString(KEY_ID_TOKEN);
Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);
return !(isEmpty(accessToken) && isEmpty(idToken) ||
expiresAt == null ||
expiresAt <= getCurrentTimeInMillis() && refreshToken == null);
} | java | public boolean hasValidCredentials() {
String accessToken = storage.retrieveString(KEY_ACCESS_TOKEN);
String refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN);
String idToken = storage.retrieveString(KEY_ID_TOKEN);
Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);
return !(isEmpty(accessToken) && isEmpty(idToken) ||
expiresAt == null ||
expiresAt <= getCurrentTimeInMillis() && refreshToken == null);
} | [
"public",
"boolean",
"hasValidCredentials",
"(",
")",
"{",
"String",
"accessToken",
"=",
"storage",
".",
"retrieveString",
"(",
"KEY_ACCESS_TOKEN",
")",
";",
"String",
"refreshToken",
"=",
"storage",
".",
"retrieveString",
"(",
"KEY_REFRESH_TOKEN",
")",
";",
"Stri... | Checks if a non-expired pair of credentials can be obtained from this manager.
@return whether there are valid credentials stored on this manager. | [
"Checks",
"if",
"a",
"non",
"-",
"expired",
"pair",
"of",
"credentials",
"can",
"be",
"obtained",
"from",
"this",
"manager",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.java#L108-L117 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.java | CredentialsManager.clearCredentials | public void clearCredentials() {
storage.remove(KEY_ACCESS_TOKEN);
storage.remove(KEY_REFRESH_TOKEN);
storage.remove(KEY_ID_TOKEN);
storage.remove(KEY_TOKEN_TYPE);
storage.remove(KEY_EXPIRES_AT);
storage.remove(KEY_SCOPE);
} | java | public void clearCredentials() {
storage.remove(KEY_ACCESS_TOKEN);
storage.remove(KEY_REFRESH_TOKEN);
storage.remove(KEY_ID_TOKEN);
storage.remove(KEY_TOKEN_TYPE);
storage.remove(KEY_EXPIRES_AT);
storage.remove(KEY_SCOPE);
} | [
"public",
"void",
"clearCredentials",
"(",
")",
"{",
"storage",
".",
"remove",
"(",
"KEY_ACCESS_TOKEN",
")",
";",
"storage",
".",
"remove",
"(",
"KEY_REFRESH_TOKEN",
")",
";",
"storage",
".",
"remove",
"(",
"KEY_ID_TOKEN",
")",
";",
"storage",
".",
"remove",... | Removes the credentials from the storage if present. | [
"Removes",
"the",
"credentials",
"from",
"the",
"storage",
"if",
"present",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.java#L122-L129 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java | SecureCredentialsManager.clearCredentials | public void clearCredentials() {
storage.remove(KEY_CREDENTIALS);
storage.remove(KEY_EXPIRES_AT);
storage.remove(KEY_CAN_REFRESH);
Log.d(TAG, "Credentials were just removed from the storage");
} | java | public void clearCredentials() {
storage.remove(KEY_CREDENTIALS);
storage.remove(KEY_EXPIRES_AT);
storage.remove(KEY_CAN_REFRESH);
Log.d(TAG, "Credentials were just removed from the storage");
} | [
"public",
"void",
"clearCredentials",
"(",
")",
"{",
"storage",
".",
"remove",
"(",
"KEY_CREDENTIALS",
")",
";",
"storage",
".",
"remove",
"(",
"KEY_EXPIRES_AT",
")",
";",
"storage",
".",
"remove",
"(",
"KEY_CAN_REFRESH",
")",
";",
"Log",
".",
"d",
"(",
... | Delete the stored credentials | [
"Delete",
"the",
"stored",
"credentials"
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java#L195-L200 | train |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java | SecureCredentialsManager.hasValidCredentials | public boolean hasValidCredentials() {
String encryptedEncoded = storage.retrieveString(KEY_CREDENTIALS);
Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);
Boolean canRefresh = storage.retrieveBoolean(KEY_CAN_REFRESH);
return !(isEmpty(encryptedEncoded) ||
expiresAt == null ||
expiresAt <= getCurrentTimeInMillis() && (canRefresh == null || !canRefresh));
} | java | public boolean hasValidCredentials() {
String encryptedEncoded = storage.retrieveString(KEY_CREDENTIALS);
Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);
Boolean canRefresh = storage.retrieveBoolean(KEY_CAN_REFRESH);
return !(isEmpty(encryptedEncoded) ||
expiresAt == null ||
expiresAt <= getCurrentTimeInMillis() && (canRefresh == null || !canRefresh));
} | [
"public",
"boolean",
"hasValidCredentials",
"(",
")",
"{",
"String",
"encryptedEncoded",
"=",
"storage",
".",
"retrieveString",
"(",
"KEY_CREDENTIALS",
")",
";",
"Long",
"expiresAt",
"=",
"storage",
".",
"retrieveLong",
"(",
"KEY_EXPIRES_AT",
")",
";",
"Boolean",
... | Returns whether this manager contains a valid non-expired pair of credentials.
@return whether this manager contains a valid non-expired pair of credentials or not. | [
"Returns",
"whether",
"this",
"manager",
"contains",
"a",
"valid",
"non",
"-",
"expired",
"pair",
"of",
"credentials",
"."
] | ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156 | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java#L207-L214 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/EntryIterator.java | EntryIterator.hasNext | @Override
public boolean hasNext() {
if (!members.hasNext()) {
try {
getNextEntries();
} catch (final Exception ignored) {
LOG.error("An error occured while getting next entries", ignored);
}
}
return members.hasNext();
} | java | @Override
public boolean hasNext() {
if (!members.hasNext()) {
try {
getNextEntries();
} catch (final Exception ignored) {
LOG.error("An error occured while getting next entries", ignored);
}
}
return members.hasNext();
} | [
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"if",
"(",
"!",
"members",
".",
"hasNext",
"(",
")",
")",
"{",
"try",
"{",
"getNextEntries",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ignored",
")",
"{",
"LOG",
".",
"e... | Returns true if more entries are available. | [
"Returns",
"true",
"if",
"more",
"entries",
"are",
"available",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/EntryIterator.java#L61-L71 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/EntryIterator.java | EntryIterator.next | @Override
public ClientEntry next() {
if (hasNext()) {
final Entry romeEntry = members.next();
try {
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(null, collection, romeEntry, true);
} else {
return new ClientMediaEntry(null, collection, romeEntry, true);
}
} catch (final ProponoException e) {
throw new RuntimeException("Unexpected exception creating ClientEntry or ClientMedia", e);
}
}
throw new NoSuchElementException();
} | java | @Override
public ClientEntry next() {
if (hasNext()) {
final Entry romeEntry = members.next();
try {
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(null, collection, romeEntry, true);
} else {
return new ClientMediaEntry(null, collection, romeEntry, true);
}
} catch (final ProponoException e) {
throw new RuntimeException("Unexpected exception creating ClientEntry or ClientMedia", e);
}
}
throw new NoSuchElementException();
} | [
"@",
"Override",
"public",
"ClientEntry",
"next",
"(",
")",
"{",
"if",
"(",
"hasNext",
"(",
")",
")",
"{",
"final",
"Entry",
"romeEntry",
"=",
"members",
".",
"next",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"romeEntry",
".",
"isMediaEntry",
"(",
... | Get next entry in collection. | [
"Get",
"next",
"entry",
"in",
"collection",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/EntryIterator.java#L76-L91 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java | ClientCollection.getEntry | public ClientEntry getEntry(final String uri) throws ProponoException {
final GetMethod method = new GetMethod(uri);
authStrategy.addAuthentication(httpClient, method);
try {
httpClient.executeMethod(method);
if (method.getStatusCode() != 200) {
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
}
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(service, this, romeEntry, false);
} else {
return new ClientMediaEntry(service, this, romeEntry, false);
}
} catch (final Exception e) {
throw new ProponoException("ERROR: getting or parsing entry/media, HTTP code: ", e);
} finally {
method.releaseConnection();
}
} | java | public ClientEntry getEntry(final String uri) throws ProponoException {
final GetMethod method = new GetMethod(uri);
authStrategy.addAuthentication(httpClient, method);
try {
httpClient.executeMethod(method);
if (method.getStatusCode() != 200) {
throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
}
final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
if (!romeEntry.isMediaEntry()) {
return new ClientEntry(service, this, romeEntry, false);
} else {
return new ClientMediaEntry(service, this, romeEntry, false);
}
} catch (final Exception e) {
throw new ProponoException("ERROR: getting or parsing entry/media, HTTP code: ", e);
} finally {
method.releaseConnection();
}
} | [
"public",
"ClientEntry",
"getEntry",
"(",
"final",
"String",
"uri",
")",
"throws",
"ProponoException",
"{",
"final",
"GetMethod",
"method",
"=",
"new",
"GetMethod",
"(",
"uri",
")",
";",
"authStrategy",
".",
"addAuthentication",
"(",
"httpClient",
",",
"method",... | Get full entry specified by entry edit URI. Note that entry may or may not be associated with
this collection.
@return ClientEntry or ClientMediaEntry specified by URI. | [
"Get",
"full",
"entry",
"specified",
"by",
"entry",
"edit",
"URI",
".",
"Note",
"that",
"entry",
"may",
"or",
"may",
"not",
"be",
"associated",
"with",
"this",
"collection",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java#L100-L119 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java | ClientCollection.createMediaEntry | public ClientMediaEntry createMediaEntry(final String title, final String slug, final String contentType, final byte[] bytes) throws ProponoException {
if (!isWritable()) {
throw new ProponoException("Collection is not writable");
}
return new ClientMediaEntry(service, this, title, slug, contentType, bytes);
} | java | public ClientMediaEntry createMediaEntry(final String title, final String slug, final String contentType, final byte[] bytes) throws ProponoException {
if (!isWritable()) {
throw new ProponoException("Collection is not writable");
}
return new ClientMediaEntry(service, this, title, slug, contentType, bytes);
} | [
"public",
"ClientMediaEntry",
"createMediaEntry",
"(",
"final",
"String",
"title",
",",
"final",
"String",
"slug",
",",
"final",
"String",
"contentType",
",",
"final",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"ProponoException",
"{",
"if",
"(",
"!",
"isWritab... | Create new media entry assocaited with collection, but do not save. server. Depending on the
Atom server, you may or may not be able to persist the properties of the entry that is
returned.
@param title Title to used for uploaded file.
@param slug String to be used in file-name of stored file
@param contentType MIME content-type of file.
@param bytes Data to be uploaded as byte array.
@throws ProponoException if collecton is not writable | [
"Create",
"new",
"media",
"entry",
"assocaited",
"with",
"collection",
"but",
"do",
"not",
"save",
".",
"server",
".",
"Depending",
"on",
"the",
"Atom",
"server",
"you",
"may",
"or",
"may",
"not",
"be",
"able",
"to",
"persist",
"the",
"properties",
"of",
... | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java#L158-L163 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java | ClientCollection.createMediaEntry | public ClientMediaEntry createMediaEntry(final String title, final String slug, final String contentType, final InputStream is) throws ProponoException {
if (!isWritable()) {
throw new ProponoException("Collection is not writable");
}
return new ClientMediaEntry(service, this, title, slug, contentType, is);
} | java | public ClientMediaEntry createMediaEntry(final String title, final String slug, final String contentType, final InputStream is) throws ProponoException {
if (!isWritable()) {
throw new ProponoException("Collection is not writable");
}
return new ClientMediaEntry(service, this, title, slug, contentType, is);
} | [
"public",
"ClientMediaEntry",
"createMediaEntry",
"(",
"final",
"String",
"title",
",",
"final",
"String",
"slug",
",",
"final",
"String",
"contentType",
",",
"final",
"InputStream",
"is",
")",
"throws",
"ProponoException",
"{",
"if",
"(",
"!",
"isWritable",
"("... | Create new media entry assocaited with collection, but do not save. server. Depending on the
Atom server, you may or may not be able to. persist the properties of the entry that is
returned.
@param title Title to used for uploaded file.
@param slug String to be used in file-name of stored file
@param contentType MIME content-type of file.
@param is Data to be uploaded as InputStream.
@throws ProponoException if collecton is not writable | [
"Create",
"new",
"media",
"entry",
"assocaited",
"with",
"collection",
"but",
"do",
"not",
"save",
".",
"server",
".",
"Depending",
"on",
"the",
"Atom",
"server",
"you",
"may",
"or",
"may",
"not",
"be",
"able",
"to",
".",
"persist",
"the",
"properties",
... | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientCollection.java#L176-L181 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/rome/AppModuleParser.java | AppModuleParser.parse | @Override
public Module parse(final Element elem, final Locale locale) {
final AppModule m = new AppModuleImpl();
final Element control = elem.getChild("control", getContentNamespace());
if (control != null) {
final Element draftElem = control.getChild("draft", getContentNamespace());
if (draftElem != null) {
if ("yes".equals(draftElem.getText())) {
m.setDraft(Boolean.TRUE);
}
if ("no".equals(draftElem.getText())) {
m.setDraft(Boolean.FALSE);
}
}
}
final Element edited = elem.getChild("edited", getContentNamespace());
if (edited != null) {
try {
m.setEdited(DateParser.parseW3CDateTime(edited.getTextTrim(), locale));
} catch (final Exception ignored) {
}
}
return m;
} | java | @Override
public Module parse(final Element elem, final Locale locale) {
final AppModule m = new AppModuleImpl();
final Element control = elem.getChild("control", getContentNamespace());
if (control != null) {
final Element draftElem = control.getChild("draft", getContentNamespace());
if (draftElem != null) {
if ("yes".equals(draftElem.getText())) {
m.setDraft(Boolean.TRUE);
}
if ("no".equals(draftElem.getText())) {
m.setDraft(Boolean.FALSE);
}
}
}
final Element edited = elem.getChild("edited", getContentNamespace());
if (edited != null) {
try {
m.setEdited(DateParser.parseW3CDateTime(edited.getTextTrim(), locale));
} catch (final Exception ignored) {
}
}
return m;
} | [
"@",
"Override",
"public",
"Module",
"parse",
"(",
"final",
"Element",
"elem",
",",
"final",
"Locale",
"locale",
")",
"{",
"final",
"AppModule",
"m",
"=",
"new",
"AppModuleImpl",
"(",
")",
";",
"final",
"Element",
"control",
"=",
"elem",
".",
"getChild",
... | Parse JDOM element into module | [
"Parse",
"JDOM",
"element",
"into",
"module"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/rome/AppModuleParser.java#L51-L74 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientMediaEntry.java | ClientMediaEntry.getAsStream | public InputStream getAsStream() throws ProponoException {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
if (c.getSrc() != null) {
return getResourceAsStream();
} else if (inputStream != null) {
return inputStream;
} else if (bytes != null) {
return new ByteArrayInputStream(bytes);
} else {
throw new ProponoException("ERROR: no src URI or binary data to return");
}
} else {
throw new ProponoException("ERROR: no content found in entry");
}
} | java | public InputStream getAsStream() throws ProponoException {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
if (c.getSrc() != null) {
return getResourceAsStream();
} else if (inputStream != null) {
return inputStream;
} else if (bytes != null) {
return new ByteArrayInputStream(bytes);
} else {
throw new ProponoException("ERROR: no src URI or binary data to return");
}
} else {
throw new ProponoException("ERROR: no content found in entry");
}
} | [
"public",
"InputStream",
"getAsStream",
"(",
")",
"throws",
"ProponoException",
"{",
"if",
"(",
"getContents",
"(",
")",
"!=",
"null",
"&&",
"!",
"getContents",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Content",
"c",
"=",
"getContents",
"(... | Get media resource as an InputStream, should work regardless of whether you set the media
resource data as an InputStream or as a byte array. | [
"Get",
"media",
"resource",
"as",
"an",
"InputStream",
"should",
"work",
"regardless",
"of",
"whether",
"you",
"set",
"the",
"media",
"resource",
"data",
"as",
"an",
"InputStream",
"or",
"as",
"a",
"byte",
"array",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientMediaEntry.java#L162-L177 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientMediaEntry.java | ClientMediaEntry.update | @Override
public void update() throws ProponoException {
if (partial) {
throw new ProponoException("ERROR: attempt to update partial entry");
}
EntityEnclosingMethod method = null;
final Content updateContent = getContents().get(0);
try {
if (getMediaLinkURI() != null && getBytes() != null) {
// existing media entry and new file, so PUT file to edit-media URI
method = new PutMethod(getMediaLinkURI());
if (inputStream != null) {
method.setRequestEntity(new InputStreamRequestEntity(inputStream));
} else {
method.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(getBytes())));
}
method.setRequestHeader("Content-type", updateContent.getType());
} else if (getEditURI() != null) {
// existing media entry and NO new file, so PUT entry to edit URI
method = new PutMethod(getEditURI());
final StringWriter sw = new StringWriter();
Atom10Generator.serializeEntry(this, sw);
method.setRequestEntity(new StringRequestEntity(sw.toString(), null, null));
method.setRequestHeader("Content-type", "application/atom+xml; charset=utf8");
} else {
throw new ProponoException("ERROR: media entry has no edit URI or media-link URI");
}
getCollection().addAuthentication(method);
method.addRequestHeader("Title", getTitle());
getCollection().getHttpClient().executeMethod(method);
if (inputStream != null) {
inputStream.close();
}
final InputStream is = method.getResponseBodyAsStream();
if (method.getStatusCode() != 200 && method.getStatusCode() != 201) {
throw new ProponoException("ERROR HTTP status=" + method.getStatusCode() + " : " + Utilities.streamToString(is));
}
} catch (final Exception e) {
throw new ProponoException("ERROR: saving media entry");
}
if (method.getStatusCode() != 201) {
throw new ProponoException("ERROR HTTP status=" + method.getStatusCode());
}
} | java | @Override
public void update() throws ProponoException {
if (partial) {
throw new ProponoException("ERROR: attempt to update partial entry");
}
EntityEnclosingMethod method = null;
final Content updateContent = getContents().get(0);
try {
if (getMediaLinkURI() != null && getBytes() != null) {
// existing media entry and new file, so PUT file to edit-media URI
method = new PutMethod(getMediaLinkURI());
if (inputStream != null) {
method.setRequestEntity(new InputStreamRequestEntity(inputStream));
} else {
method.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(getBytes())));
}
method.setRequestHeader("Content-type", updateContent.getType());
} else if (getEditURI() != null) {
// existing media entry and NO new file, so PUT entry to edit URI
method = new PutMethod(getEditURI());
final StringWriter sw = new StringWriter();
Atom10Generator.serializeEntry(this, sw);
method.setRequestEntity(new StringRequestEntity(sw.toString(), null, null));
method.setRequestHeader("Content-type", "application/atom+xml; charset=utf8");
} else {
throw new ProponoException("ERROR: media entry has no edit URI or media-link URI");
}
getCollection().addAuthentication(method);
method.addRequestHeader("Title", getTitle());
getCollection().getHttpClient().executeMethod(method);
if (inputStream != null) {
inputStream.close();
}
final InputStream is = method.getResponseBodyAsStream();
if (method.getStatusCode() != 200 && method.getStatusCode() != 201) {
throw new ProponoException("ERROR HTTP status=" + method.getStatusCode() + " : " + Utilities.streamToString(is));
}
} catch (final Exception e) {
throw new ProponoException("ERROR: saving media entry");
}
if (method.getStatusCode() != 201) {
throw new ProponoException("ERROR HTTP status=" + method.getStatusCode());
}
} | [
"@",
"Override",
"public",
"void",
"update",
"(",
")",
"throws",
"ProponoException",
"{",
"if",
"(",
"partial",
")",
"{",
"throw",
"new",
"ProponoException",
"(",
"\"ERROR: attempt to update partial entry\"",
")",
";",
"}",
"EntityEnclosingMethod",
"method",
"=",
... | Update entry on server. | [
"Update",
"entry",
"on",
"server",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientMediaEntry.java#L198-L243 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaSyndFeedInfo.java | DeltaSyndFeedInfo.setSyndFeed | @Override
public final synchronized void setSyndFeed(final SyndFeed feed) {
super.setSyndFeed(feed);
changedMap.clear();
final List<SyndEntry> entries = feed.getEntries();
for (final SyndEntry entry : entries) {
final String currentEntryTag = computeEntryTag(entry);
final String previousEntryTag = entryTagsMap.get(entry.getUri());
if (previousEntryTag == null || !currentEntryTag.equals(previousEntryTag)) {
// Entry has changed
changedMap.put(entry.getUri(), Boolean.TRUE);
}
entryTagsMap.put(entry.getUri(), currentEntryTag);
}
} | java | @Override
public final synchronized void setSyndFeed(final SyndFeed feed) {
super.setSyndFeed(feed);
changedMap.clear();
final List<SyndEntry> entries = feed.getEntries();
for (final SyndEntry entry : entries) {
final String currentEntryTag = computeEntryTag(entry);
final String previousEntryTag = entryTagsMap.get(entry.getUri());
if (previousEntryTag == null || !currentEntryTag.equals(previousEntryTag)) {
// Entry has changed
changedMap.put(entry.getUri(), Boolean.TRUE);
}
entryTagsMap.put(entry.getUri(), currentEntryTag);
}
} | [
"@",
"Override",
"public",
"final",
"synchronized",
"void",
"setSyndFeed",
"(",
"final",
"SyndFeed",
"feed",
")",
"{",
"super",
".",
"setSyndFeed",
"(",
"feed",
")",
";",
"changedMap",
".",
"clear",
"(",
")",
";",
"final",
"List",
"<",
"SyndEntry",
">",
... | Overrides super class method to update changedMap and entryTagsMap for tracking changed
entries.
@param feed | [
"Overrides",
"super",
"class",
"method",
"to",
"update",
"changedMap",
"and",
"entryTagsMap",
"for",
"tracking",
"changed",
"entries",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/hub/DeltaSyndFeedInfo.java#L91-L107 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java | ClientEntry.setContent | public void setContent(final String contentString, final String type) {
final Content newContent = new Content();
newContent.setType(type == null ? Content.HTML : type);
newContent.setValue(contentString);
final ArrayList<Content> contents = new ArrayList<Content>();
contents.add(newContent);
setContents(contents);
} | java | public void setContent(final String contentString, final String type) {
final Content newContent = new Content();
newContent.setType(type == null ? Content.HTML : type);
newContent.setValue(contentString);
final ArrayList<Content> contents = new ArrayList<Content>();
contents.add(newContent);
setContents(contents);
} | [
"public",
"void",
"setContent",
"(",
"final",
"String",
"contentString",
",",
"final",
"String",
"type",
")",
"{",
"final",
"Content",
"newContent",
"=",
"new",
"Content",
"(",
")",
";",
"newContent",
".",
"setType",
"(",
"type",
"==",
"null",
"?",
"Conten... | Set content of entry.
@param contentString content string.
@param type Must be "text" for plain text, "html" for escaped HTML, "xhtml" for XHTML or a
valid MIME content-type. | [
"Set",
"content",
"of",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java#L87-L94 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java | ClientEntry.setContent | public void setContent(final Content c) {
final ArrayList<Content> contents = new ArrayList<Content>();
contents.add(c);
setContents(contents);
} | java | public void setContent(final Content c) {
final ArrayList<Content> contents = new ArrayList<Content>();
contents.add(c);
setContents(contents);
} | [
"public",
"void",
"setContent",
"(",
"final",
"Content",
"c",
")",
"{",
"final",
"ArrayList",
"<",
"Content",
">",
"contents",
"=",
"new",
"ArrayList",
"<",
"Content",
">",
"(",
")",
";",
"contents",
".",
"add",
"(",
"c",
")",
";",
"setContents",
"(",
... | Convenience method to set first content object in content collection. Atom 1.0 allows only
one content element per entry. | [
"Convenience",
"method",
"to",
"set",
"first",
"content",
"object",
"in",
"content",
"collection",
".",
"Atom",
"1",
".",
"0",
"allows",
"only",
"one",
"content",
"element",
"per",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java#L100-L104 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java | ClientEntry.getContent | public Content getContent() {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
return c;
}
return null;
} | java | public Content getContent() {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
return c;
}
return null;
} | [
"public",
"Content",
"getContent",
"(",
")",
"{",
"if",
"(",
"getContents",
"(",
")",
"!=",
"null",
"&&",
"!",
"getContents",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Content",
"c",
"=",
"getContents",
"(",
")",
".",
"get",
"(",
"0",... | Convenience method to get first content object in content collection. Atom 1.0 allows only
one content element per entry. | [
"Convenience",
"method",
"to",
"get",
"first",
"content",
"object",
"in",
"content",
"collection",
".",
"Atom",
"1",
".",
"0",
"allows",
"only",
"one",
"content",
"element",
"per",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java#L110-L116 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java | ClientEntry.remove | public void remove() throws ProponoException {
if (getEditURI() == null) {
throw new ProponoException("ERROR: cannot delete unsaved entry");
}
final DeleteMethod method = new DeleteMethod(getEditURI());
addAuthentication(method);
try {
getHttpClient().executeMethod(method);
} catch (final IOException ex) {
throw new ProponoException("ERROR: removing entry, HTTP code", ex);
} finally {
method.releaseConnection();
}
} | java | public void remove() throws ProponoException {
if (getEditURI() == null) {
throw new ProponoException("ERROR: cannot delete unsaved entry");
}
final DeleteMethod method = new DeleteMethod(getEditURI());
addAuthentication(method);
try {
getHttpClient().executeMethod(method);
} catch (final IOException ex) {
throw new ProponoException("ERROR: removing entry, HTTP code", ex);
} finally {
method.releaseConnection();
}
} | [
"public",
"void",
"remove",
"(",
")",
"throws",
"ProponoException",
"{",
"if",
"(",
"getEditURI",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"ProponoException",
"(",
"\"ERROR: cannot delete unsaved entry\"",
")",
";",
"}",
"final",
"DeleteMethod",
"method... | Remove entry from server. | [
"Remove",
"entry",
"from",
"server",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java#L171-L184 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java | ClientEntry.getEditURI | public String getEditURI() {
for (int i = 0; i < getOtherLinks().size(); i++) {
final Link link = getOtherLinks().get(i);
if (link.getRel() != null && link.getRel().equals("edit")) {
return link.getHrefResolved();
}
}
return null;
} | java | public String getEditURI() {
for (int i = 0; i < getOtherLinks().size(); i++) {
final Link link = getOtherLinks().get(i);
if (link.getRel() != null && link.getRel().equals("edit")) {
return link.getHrefResolved();
}
}
return null;
} | [
"public",
"String",
"getEditURI",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getOtherLinks",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Link",
"link",
"=",
"getOtherLinks",
"(",
")",
".",
"get",
"... | Get the URI that can be used to edit the entry via HTTP PUT or DELETE. | [
"Get",
"the",
"URI",
"that",
"can",
"be",
"used",
"to",
"edit",
"the",
"entry",
"via",
"HTTP",
"PUT",
"or",
"DELETE",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/client/ClientEntry.java#L197-L205 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaGroup.java | MediaGroup.setDefaultContentIndex | public void setDefaultContentIndex(final Integer defaultContentIndex) {
for (int i = 0; i < getContents().length; i++) {
if (i == defaultContentIndex.intValue()) {
getContents()[i].setDefaultContent(true);
} else {
getContents()[i].setDefaultContent(false);
}
}
this.defaultContentIndex = defaultContentIndex;
} | java | public void setDefaultContentIndex(final Integer defaultContentIndex) {
for (int i = 0; i < getContents().length; i++) {
if (i == defaultContentIndex.intValue()) {
getContents()[i].setDefaultContent(true);
} else {
getContents()[i].setDefaultContent(false);
}
}
this.defaultContentIndex = defaultContentIndex;
} | [
"public",
"void",
"setDefaultContentIndex",
"(",
"final",
"Integer",
"defaultContentIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getContents",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"==",
"defaultConte... | Default content index MediaContent.
@param defaultContentIndex Default content index MediaContent. | [
"Default",
"content",
"index",
"MediaContent",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/mediarss/types/MediaGroup.java#L97-L107 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/Workspace.java | Workspace.workspaceToElement | public Element workspaceToElement() {
final Workspace space = this;
final Element element = new Element("workspace", AtomService.ATOM_PROTOCOL);
final Element titleElem = new Element("title", AtomService.ATOM_FORMAT);
titleElem.setText(space.getTitle());
if (space.getTitleType() != null && !space.getTitleType().equals("TEXT")) {
titleElem.setAttribute("type", space.getTitleType(), AtomService.ATOM_FORMAT);
}
element.addContent(titleElem);
for (final Collection col : space.getCollections()) {
element.addContent(col.collectionToElement());
}
return element;
} | java | public Element workspaceToElement() {
final Workspace space = this;
final Element element = new Element("workspace", AtomService.ATOM_PROTOCOL);
final Element titleElem = new Element("title", AtomService.ATOM_FORMAT);
titleElem.setText(space.getTitle());
if (space.getTitleType() != null && !space.getTitleType().equals("TEXT")) {
titleElem.setAttribute("type", space.getTitleType(), AtomService.ATOM_FORMAT);
}
element.addContent(titleElem);
for (final Collection col : space.getCollections()) {
element.addContent(col.collectionToElement());
}
return element;
} | [
"public",
"Element",
"workspaceToElement",
"(",
")",
"{",
"final",
"Workspace",
"space",
"=",
"this",
";",
"final",
"Element",
"element",
"=",
"new",
"Element",
"(",
"\"workspace\"",
",",
"AtomService",
".",
"ATOM_PROTOCOL",
")",
";",
"final",
"Element",
"titl... | Serialize an AtomService.DefaultWorkspace object into an XML element | [
"Serialize",
"an",
"AtomService",
".",
"DefaultWorkspace",
"object",
"into",
"an",
"XML",
"element"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/Workspace.java#L119-L136 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/Workspace.java | Workspace.parseWorkspaceElement | protected void parseWorkspaceElement(final Element element) throws ProponoException {
final Element titleElem = element.getChild("title", AtomService.ATOM_FORMAT);
setTitle(titleElem.getText());
if (titleElem.getAttribute("type", AtomService.ATOM_FORMAT) != null) {
setTitleType(titleElem.getAttribute("type", AtomService.ATOM_FORMAT).getValue());
}
final List<Element> collections = element.getChildren("collection", AtomService.ATOM_PROTOCOL);
for (final Element e : collections) {
addCollection(new Collection(e));
}
} | java | protected void parseWorkspaceElement(final Element element) throws ProponoException {
final Element titleElem = element.getChild("title", AtomService.ATOM_FORMAT);
setTitle(titleElem.getText());
if (titleElem.getAttribute("type", AtomService.ATOM_FORMAT) != null) {
setTitleType(titleElem.getAttribute("type", AtomService.ATOM_FORMAT).getValue());
}
final List<Element> collections = element.getChildren("collection", AtomService.ATOM_PROTOCOL);
for (final Element e : collections) {
addCollection(new Collection(e));
}
} | [
"protected",
"void",
"parseWorkspaceElement",
"(",
"final",
"Element",
"element",
")",
"throws",
"ProponoException",
"{",
"final",
"Element",
"titleElem",
"=",
"element",
".",
"getChild",
"(",
"\"title\"",
",",
"AtomService",
".",
"ATOM_FORMAT",
")",
";",
"setTitl... | Deserialize a Atom workspace XML element into an object | [
"Deserialize",
"a",
"Atom",
"workspace",
"XML",
"element",
"into",
"an",
"object"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/Workspace.java#L139-L149 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/AtomService.java | AtomService.findWorkspace | public Workspace findWorkspace(final String title) {
for (final Object element : workspaces) {
final Workspace ws = (Workspace) element;
if (title.equals(ws.getTitle())) {
return ws;
}
}
return null;
} | java | public Workspace findWorkspace(final String title) {
for (final Object element : workspaces) {
final Workspace ws = (Workspace) element;
if (title.equals(ws.getTitle())) {
return ws;
}
}
return null;
} | [
"public",
"Workspace",
"findWorkspace",
"(",
"final",
"String",
"title",
")",
"{",
"for",
"(",
"final",
"Object",
"element",
":",
"workspaces",
")",
"{",
"final",
"Workspace",
"ws",
"=",
"(",
"Workspace",
")",
"element",
";",
"if",
"(",
"title",
".",
"eq... | Find workspace by title.
@param title Match this title
@return Matching Workspace or null if none found. | [
"Find",
"workspace",
"by",
"title",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/AtomService.java#L79-L87 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/AtomService.java | AtomService.serviceToDocument | public Document serviceToDocument() {
final AtomService service = this;
final Document doc = new Document();
final Element root = new Element("service", ATOM_PROTOCOL);
doc.setRootElement(root);
final List<Workspace> spaces = service.getWorkspaces();
for (final Workspace space : spaces) {
root.addContent(space.workspaceToElement());
}
return doc;
} | java | public Document serviceToDocument() {
final AtomService service = this;
final Document doc = new Document();
final Element root = new Element("service", ATOM_PROTOCOL);
doc.setRootElement(root);
final List<Workspace> spaces = service.getWorkspaces();
for (final Workspace space : spaces) {
root.addContent(space.workspaceToElement());
}
return doc;
} | [
"public",
"Document",
"serviceToDocument",
"(",
")",
"{",
"final",
"AtomService",
"service",
"=",
"this",
";",
"final",
"Document",
"doc",
"=",
"new",
"Document",
"(",
")",
";",
"final",
"Element",
"root",
"=",
"new",
"Element",
"(",
"\"service\"",
",",
"A... | Serialize an AtomService object into an XML document | [
"Serialize",
"an",
"AtomService",
"object",
"into",
"an",
"XML",
"document"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/AtomService.java#L105-L116 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/sle/SortableList.java | SortableList.sortOnProperty | public synchronized void sortOnProperty(final Object value, final boolean ascending, final ValueStrategy strategy) {
final int elementCount = size();
for (int i = 0; i < elementCount - 1; i++) {
for (int j = i + 1; j < elementCount; j++) {
final T entry1 = get(i);
final T entry2 = get(j);
final EntryValue oc1 = strategy.getValue(entry1, value);
final EntryValue oc2 = strategy.getValue(entry2, value);
if (oc1 != oc2) {
final boolean bothNotNull = oc1 != null && oc2 != null;
if (ascending) {
if (oc2 == null || bothNotNull && oc2.compareTo(oc1) < 0) {
// swap entries
set(i, entry2);
set(j, entry1);
}
} else {
if (oc1 == null || bothNotNull && oc1.compareTo(oc2) < 0) {
// swap entries
set(i, entry2);
set(j, entry1);
}
}
}
}
}
} | java | public synchronized void sortOnProperty(final Object value, final boolean ascending, final ValueStrategy strategy) {
final int elementCount = size();
for (int i = 0; i < elementCount - 1; i++) {
for (int j = i + 1; j < elementCount; j++) {
final T entry1 = get(i);
final T entry2 = get(j);
final EntryValue oc1 = strategy.getValue(entry1, value);
final EntryValue oc2 = strategy.getValue(entry2, value);
if (oc1 != oc2) {
final boolean bothNotNull = oc1 != null && oc2 != null;
if (ascending) {
if (oc2 == null || bothNotNull && oc2.compareTo(oc1) < 0) {
// swap entries
set(i, entry2);
set(j, entry1);
}
} else {
if (oc1 == null || bothNotNull && oc1.compareTo(oc2) < 0) {
// swap entries
set(i, entry2);
set(j, entry1);
}
}
}
}
}
} | [
"public",
"synchronized",
"void",
"sortOnProperty",
"(",
"final",
"Object",
"value",
",",
"final",
"boolean",
"ascending",
",",
"final",
"ValueStrategy",
"strategy",
")",
"{",
"final",
"int",
"elementCount",
"=",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i"... | performs a selection sort on all the beans in the List | [
"performs",
"a",
"selection",
"sort",
"on",
"all",
"the",
"beans",
"in",
"the",
"List"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/sle/SortableList.java#L34-L68 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/blogclient/metaweblog/MetaWeblogResource.java | MetaWeblogResource.getAsStream | @Override
public InputStream getAsStream() throws BlogClientException {
final HttpClient httpClient = new HttpClient();
final GetMethod method = new GetMethod(permalink);
try {
httpClient.executeMethod(method);
} catch (final Exception e) {
throw new BlogClientException("ERROR: error reading file", e);
}
if (method.getStatusCode() != 200) {
throw new BlogClientException("ERROR HTTP status=" + method.getStatusCode());
}
try {
return method.getResponseBodyAsStream();
} catch (final Exception e) {
throw new BlogClientException("ERROR: error reading file", e);
}
} | java | @Override
public InputStream getAsStream() throws BlogClientException {
final HttpClient httpClient = new HttpClient();
final GetMethod method = new GetMethod(permalink);
try {
httpClient.executeMethod(method);
} catch (final Exception e) {
throw new BlogClientException("ERROR: error reading file", e);
}
if (method.getStatusCode() != 200) {
throw new BlogClientException("ERROR HTTP status=" + method.getStatusCode());
}
try {
return method.getResponseBodyAsStream();
} catch (final Exception e) {
throw new BlogClientException("ERROR: error reading file", e);
}
} | [
"@",
"Override",
"public",
"InputStream",
"getAsStream",
"(",
")",
"throws",
"BlogClientException",
"{",
"final",
"HttpClient",
"httpClient",
"=",
"new",
"HttpClient",
"(",
")",
";",
"final",
"GetMethod",
"method",
"=",
"new",
"GetMethod",
"(",
"permalink",
")",... | Get media resource as input stream. | [
"Get",
"media",
"resource",
"as",
"input",
"stream",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/blogclient/metaweblog/MetaWeblogResource.java#L75-L92 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/WireFeedInput.java | WireFeedInput.createSAXBuilder | protected SAXBuilder createSAXBuilder() {
SAXBuilder saxBuilder;
if (validate) {
saxBuilder = new SAXBuilder(XMLReaders.DTDVALIDATING);
} else {
saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING);
}
saxBuilder.setEntityResolver(RESOLVER);
//
// This code is needed to fix the security problem outlined in
// http://www.securityfocus.com/archive/1/297714
//
// Unfortunately there isn't an easy way to check if an XML parser
// supports a particular feature, so
// we need to set it and catch the exception if it fails. We also need
// to subclass the JDom SAXBuilder
// class in order to get access to the underlying SAX parser - otherwise
// the features don't get set until
// we are already building the document, by which time it's too late to
// fix the problem.
//
// Crimson is one parser which is known not to support these features.
try {
final XMLReader parser = saxBuilder.createParser();
setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-general-entities", false);
setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-parameter-entities", false);
setFeature(saxBuilder, parser, "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
if(!allowDoctypes) {
setFeature(saxBuilder, parser, "http://apache.org/xml/features/disallow-doctype-decl", true);
}
} catch (final JDOMException e) {
throw new IllegalStateException("JDOM could not create a SAX parser", e);
}
saxBuilder.setExpandEntities(false);
return saxBuilder;
} | java | protected SAXBuilder createSAXBuilder() {
SAXBuilder saxBuilder;
if (validate) {
saxBuilder = new SAXBuilder(XMLReaders.DTDVALIDATING);
} else {
saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING);
}
saxBuilder.setEntityResolver(RESOLVER);
//
// This code is needed to fix the security problem outlined in
// http://www.securityfocus.com/archive/1/297714
//
// Unfortunately there isn't an easy way to check if an XML parser
// supports a particular feature, so
// we need to set it and catch the exception if it fails. We also need
// to subclass the JDom SAXBuilder
// class in order to get access to the underlying SAX parser - otherwise
// the features don't get set until
// we are already building the document, by which time it's too late to
// fix the problem.
//
// Crimson is one parser which is known not to support these features.
try {
final XMLReader parser = saxBuilder.createParser();
setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-general-entities", false);
setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-parameter-entities", false);
setFeature(saxBuilder, parser, "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
if(!allowDoctypes) {
setFeature(saxBuilder, parser, "http://apache.org/xml/features/disallow-doctype-decl", true);
}
} catch (final JDOMException e) {
throw new IllegalStateException("JDOM could not create a SAX parser", e);
}
saxBuilder.setExpandEntities(false);
return saxBuilder;
} | [
"protected",
"SAXBuilder",
"createSAXBuilder",
"(",
")",
"{",
"SAXBuilder",
"saxBuilder",
";",
"if",
"(",
"validate",
")",
"{",
"saxBuilder",
"=",
"new",
"SAXBuilder",
"(",
"XMLReaders",
".",
"DTDVALIDATING",
")",
";",
"}",
"else",
"{",
"saxBuilder",
"=",
"n... | Creates and sets up a org.jdom2.input.SAXBuilder for parsing.
@return a new org.jdom2.input.SAXBuilder object | [
"Creates",
"and",
"sets",
"up",
"a",
"org",
".",
"jdom2",
".",
"input",
".",
"SAXBuilder",
"for",
"parsing",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/WireFeedInput.java#L322-L365 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/utils/ProponoException.java | ProponoException.getRootCauseMessage | public String getRootCauseMessage() {
String rcmessage = null;
if (getRootCause() != null) {
if (getRootCause().getCause() != null) {
rcmessage = getRootCause().getCause().getMessage();
}
rcmessage = rcmessage == null ? getRootCause().getMessage() : rcmessage;
rcmessage = rcmessage == null ? super.getMessage() : rcmessage;
rcmessage = rcmessage == null ? "NONE" : rcmessage;
}
return rcmessage;
} | java | public String getRootCauseMessage() {
String rcmessage = null;
if (getRootCause() != null) {
if (getRootCause().getCause() != null) {
rcmessage = getRootCause().getCause().getMessage();
}
rcmessage = rcmessage == null ? getRootCause().getMessage() : rcmessage;
rcmessage = rcmessage == null ? super.getMessage() : rcmessage;
rcmessage = rcmessage == null ? "NONE" : rcmessage;
}
return rcmessage;
} | [
"public",
"String",
"getRootCauseMessage",
"(",
")",
"{",
"String",
"rcmessage",
"=",
"null",
";",
"if",
"(",
"getRootCause",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"getRootCause",
"(",
")",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"r... | Get root cause message.
@return Root cause message. | [
"Get",
"root",
"cause",
"message",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/utils/ProponoException.java#L102-L113 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/common/Categories.java | Categories.getHrefResolved | public String getHrefResolved() {
if (Atom10Parser.isAbsoluteURI(href)) {
return href;
} else if (baseURI != null && categoriesElement != null) {
return Atom10Parser.resolveURI(baseURI, categoriesElement, href);
}
return null;
} | java | public String getHrefResolved() {
if (Atom10Parser.isAbsoluteURI(href)) {
return href;
} else if (baseURI != null && categoriesElement != null) {
return Atom10Parser.resolveURI(baseURI, categoriesElement, href);
}
return null;
} | [
"public",
"String",
"getHrefResolved",
"(",
")",
"{",
"if",
"(",
"Atom10Parser",
".",
"isAbsoluteURI",
"(",
"href",
")",
")",
"{",
"return",
"href",
";",
"}",
"else",
"if",
"(",
"baseURI",
"!=",
"null",
"&&",
"categoriesElement",
"!=",
"null",
")",
"{",
... | Get unresolved URI of the collection, or null if impossible to determine | [
"Get",
"unresolved",
"URI",
"of",
"the",
"collection",
"or",
"null",
"if",
"impossible",
"to",
"determine"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/common/Categories.java#L99-L106 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Lists.java | Lists.createWhenNull | public static <T> List<T> createWhenNull(final List<T> list) {
if (list == null) {
return new ArrayList<T>();
} else {
return list;
}
} | java | public static <T> List<T> createWhenNull(final List<T> list) {
if (list == null) {
return new ArrayList<T>();
} else {
return list;
}
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"createWhenNull",
"(",
"final",
"List",
"<",
"T",
">",
"list",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"}",
"else... | Returns the list when it is not null. Returns a new list otherwise.
@param list The list to process, can be null
@return The input list when it is not null, a new list otherwise | [
"Returns",
"the",
"list",
"when",
"it",
"is",
"not",
"null",
".",
"Returns",
"a",
"new",
"list",
"otherwise",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Lists.java#L31-L37 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Lists.java | Lists.create | public static <T> List<T> create(final T item) {
final List<T> list = new ArrayList<T>();
list.add(item);
return list;
} | java | public static <T> List<T> create(final T item) {
final List<T> list = new ArrayList<T>();
list.add(item);
return list;
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"create",
"(",
"final",
"T",
"item",
")",
"{",
"final",
"List",
"<",
"T",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"list",
".",
"add",
"(",
"item",
")",
";",... | Creates a new List with the given item as the first entry.
@param item The item to add to the new list
@return List containing the given item | [
"Creates",
"a",
"new",
"List",
"with",
"the",
"given",
"item",
"as",
"the",
"first",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Lists.java#L45-L49 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Lists.java | Lists.firstEntry | public static <T> T firstEntry(final List<T> list) {
if (list != null && !list.isEmpty()) {
return list.get(0);
} else {
return null;
}
} | java | public static <T> T firstEntry(final List<T> list) {
if (list != null && !list.isEmpty()) {
return list.get(0);
} else {
return null;
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"firstEntry",
"(",
"final",
"List",
"<",
"T",
">",
"list",
")",
"{",
"if",
"(",
"list",
"!=",
"null",
"&&",
"!",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"list",
".",
"get",
"(",
"0",
")",
... | Extracts the first entry of the list when it is not null and contains values.
@param list The list to extract the first entry from, can be null
@return The first entry of the list when it is not null or empty, null otherwise | [
"Extracts",
"the",
"first",
"entry",
"of",
"the",
"list",
"when",
"it",
"is",
"not",
"null",
"and",
"contains",
"values",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Lists.java#L57-L63 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Lists.java | Lists.sizeIs | public static boolean sizeIs(final List<?> list, final int size) {
if (size == 0) {
return list == null || list.isEmpty();
} else {
return list != null && list.size() == size;
}
} | java | public static boolean sizeIs(final List<?> list, final int size) {
if (size == 0) {
return list == null || list.isEmpty();
} else {
return list != null && list.size() == size;
}
} | [
"public",
"static",
"boolean",
"sizeIs",
"(",
"final",
"List",
"<",
"?",
">",
"list",
",",
"final",
"int",
"size",
")",
"{",
"if",
"(",
"size",
"==",
"0",
")",
"{",
"return",
"list",
"==",
"null",
"||",
"list",
".",
"isEmpty",
"(",
")",
";",
"}",... | Checks whether the list has the given size. A null list is treated like a list without
entries.
@param list The list to check
@param size The size to check
@return true when the list has the given size or when size = 0 and the list is null, false
otherwise | [
"Checks",
"whether",
"the",
"list",
"has",
"the",
"given",
"size",
".",
"A",
"null",
"list",
"is",
"treated",
"like",
"a",
"list",
"without",
"entries",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Lists.java#L94-L100 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Lists.java | Lists.emptyToNull | public static <T> List<T> emptyToNull(final List<T> list) {
if (isEmpty(list)) {
return null;
} else {
return list;
}
} | java | public static <T> List<T> emptyToNull(final List<T> list) {
if (isEmpty(list)) {
return null;
} else {
return list;
}
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"emptyToNull",
"(",
"final",
"List",
"<",
"T",
">",
"list",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"list",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"list",
";",
"}... | Returns null, when the given list is empty or null
@param list The list to process
@return null when the list is empty or null, the given list otherwise | [
"Returns",
"null",
"when",
"the",
"given",
"list",
"is",
"empty",
"or",
"null"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Lists.java#L108-L114 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java | NumberParser.parseLong | public static Long parseLong(final String str) {
if (null != str) {
try {
return new Long(Long.parseLong(str.trim()));
} catch (final Exception e) {
// :IGNORE:
}
}
return null;
} | java | public static Long parseLong(final String str) {
if (null != str) {
try {
return new Long(Long.parseLong(str.trim()));
} catch (final Exception e) {
// :IGNORE:
}
}
return null;
} | [
"public",
"static",
"Long",
"parseLong",
"(",
"final",
"String",
"str",
")",
"{",
"if",
"(",
"null",
"!=",
"str",
")",
"{",
"try",
"{",
"return",
"new",
"Long",
"(",
"Long",
".",
"parseLong",
"(",
"str",
".",
"trim",
"(",
")",
")",
")",
";",
"}",... | Parses a Long out of a string.
@param str string to parse for a Long.
@return the Long represented by the given string, It returns <b>null</b> if it was not
possible to parse the the string. | [
"Parses",
"a",
"Long",
"out",
"of",
"a",
"string",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java#L42-L51 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java | NumberParser.parseFloat | public static Float parseFloat(final String str) {
if (null != str) {
try {
return new Float(Float.parseFloat(str.trim()));
} catch (final Exception e) {
// :IGNORE:
}
}
return null;
} | java | public static Float parseFloat(final String str) {
if (null != str) {
try {
return new Float(Float.parseFloat(str.trim()));
} catch (final Exception e) {
// :IGNORE:
}
}
return null;
} | [
"public",
"static",
"Float",
"parseFloat",
"(",
"final",
"String",
"str",
")",
"{",
"if",
"(",
"null",
"!=",
"str",
")",
"{",
"try",
"{",
"return",
"new",
"Float",
"(",
"Float",
".",
"parseFloat",
"(",
"str",
".",
"trim",
"(",
")",
")",
")",
";",
... | Parse a Float from a String without exceptions. If the String is not a Float then null is
returned
@param str the String to parse
@return The Float represented by the String, or null if it could not be parsed. | [
"Parse",
"a",
"Float",
"from",
"a",
"String",
"without",
"exceptions",
".",
"If",
"the",
"String",
"is",
"not",
"a",
"Float",
"then",
"null",
"is",
"returned"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java#L78-L87 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java | NumberParser.parseFloat | public static float parseFloat(final String str, final float def) {
final Float result = parseFloat(str);
if (result == null) {
return def;
} else {
return result.floatValue();
}
} | java | public static float parseFloat(final String str, final float def) {
final Float result = parseFloat(str);
if (result == null) {
return def;
} else {
return result.floatValue();
}
} | [
"public",
"static",
"float",
"parseFloat",
"(",
"final",
"String",
"str",
",",
"final",
"float",
"def",
")",
"{",
"final",
"Float",
"result",
"=",
"parseFloat",
"(",
"str",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"return",
"def",
";",
... | Parse a float from a String, with a default value
@param str
@param def the value to return if the String cannot be parsed | [
"Parse",
"a",
"float",
"from",
"a",
"String",
"with",
"a",
"default",
"value"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java#L95-L102 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java | NumberParser.parseLong | public static long parseLong(final String str, final long def) {
final Long ret = parseLong(str);
if (ret == null) {
return def;
} else {
return ret.longValue();
}
} | java | public static long parseLong(final String str, final long def) {
final Long ret = parseLong(str);
if (ret == null) {
return def;
} else {
return ret.longValue();
}
} | [
"public",
"static",
"long",
"parseLong",
"(",
"final",
"String",
"str",
",",
"final",
"long",
"def",
")",
"{",
"final",
"Long",
"ret",
"=",
"parseLong",
"(",
"str",
")",
";",
"if",
"(",
"ret",
"==",
"null",
")",
"{",
"return",
"def",
";",
"}",
"els... | Parses a long out of a string.
@param str string to parse for a long.
@param def default value to return if it is not possible to parse the the string.
@return the long represented by the given string, or the default. | [
"Parses",
"a",
"long",
"out",
"of",
"a",
"string",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/NumberParser.java#L111-L118 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/PropertiesLoader.java | PropertiesLoader.getPropertiesLoader | public static PropertiesLoader getPropertiesLoader() {
synchronized (PropertiesLoader.class) {
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
PropertiesLoader loader = clMap.get(classLoader);
if (loader == null) {
try {
loader = new PropertiesLoader(MASTER_PLUGIN_FILE, EXTRA_PLUGIN_FILE);
clMap.put(classLoader, loader);
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
}
return loader;
}
} | java | public static PropertiesLoader getPropertiesLoader() {
synchronized (PropertiesLoader.class) {
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
PropertiesLoader loader = clMap.get(classLoader);
if (loader == null) {
try {
loader = new PropertiesLoader(MASTER_PLUGIN_FILE, EXTRA_PLUGIN_FILE);
clMap.put(classLoader, loader);
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
}
return loader;
}
} | [
"public",
"static",
"PropertiesLoader",
"getPropertiesLoader",
"(",
")",
"{",
"synchronized",
"(",
"PropertiesLoader",
".",
"class",
")",
"{",
"final",
"ClassLoader",
"classLoader",
"=",
"ConfigurableClassLoader",
".",
"INSTANCE",
".",
"getClassLoader",
"(",
")",
";... | Returns the PropertiesLoader singleton used by ROME to load plugin
components.
@return PropertiesLoader singleton. | [
"Returns",
"the",
"PropertiesLoader",
"singleton",
"used",
"by",
"ROME",
"to",
"load",
"plugin",
"components",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/PropertiesLoader.java#L57-L71 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/Atom10Generator.java | Atom10Generator.serializeEntry | public static void serializeEntry(final Entry entry, final Writer writer) throws IllegalArgumentException, FeedException, IOException {
// Build a feed containing only the entry
final List<Entry> entries = new ArrayList<Entry>();
entries.add(entry);
final Feed feed1 = new Feed();
feed1.setFeedType("atom_1.0");
feed1.setEntries(entries);
// Get Rome to output feed as a JDOM document
final WireFeedOutput wireFeedOutput = new WireFeedOutput();
final Document feedDoc = wireFeedOutput.outputJDom(feed1);
// Grab entry element from feed and get JDOM to serialize it
final Element entryElement = feedDoc.getRootElement().getChildren().get(0);
final XMLOutputter outputter = new XMLOutputter();
outputter.output(entryElement, writer);
} | java | public static void serializeEntry(final Entry entry, final Writer writer) throws IllegalArgumentException, FeedException, IOException {
// Build a feed containing only the entry
final List<Entry> entries = new ArrayList<Entry>();
entries.add(entry);
final Feed feed1 = new Feed();
feed1.setFeedType("atom_1.0");
feed1.setEntries(entries);
// Get Rome to output feed as a JDOM document
final WireFeedOutput wireFeedOutput = new WireFeedOutput();
final Document feedDoc = wireFeedOutput.outputJDom(feed1);
// Grab entry element from feed and get JDOM to serialize it
final Element entryElement = feedDoc.getRootElement().getChildren().get(0);
final XMLOutputter outputter = new XMLOutputter();
outputter.output(entryElement, writer);
} | [
"public",
"static",
"void",
"serializeEntry",
"(",
"final",
"Entry",
"entry",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IllegalArgumentException",
",",
"FeedException",
",",
"IOException",
"{",
"// Build a feed containing only the entry",
"final",
"List",
"<",
... | Utility method to serialize an entry to writer. | [
"Utility",
"method",
"to",
"serialize",
"an",
"entry",
"to",
"writer",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/Atom10Generator.java#L541-L559 | train |
rometools/rome | rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpURLFeedFetcher.java | HttpURLFeedFetcher.retrieveFeed | @Override
public SyndFeed retrieveFeed(final String userAgent, final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException {
if (feedUrl == null) {
throw new IllegalArgumentException("null is not a valid URL");
}
final URLConnection connection = feedUrl.openConnection();
if (!(connection instanceof HttpURLConnection)) {
throw new IllegalArgumentException(feedUrl.toExternalForm() + " is not a valid HTTP Url");
}
final HttpURLConnection httpConnection = (HttpURLConnection) connection;
if (connectTimeout >= 0) {
httpConnection.setConnectTimeout(connectTimeout);
}
// httpConnection.setInstanceFollowRedirects(true); // this is true by default, but can be
// changed on a claswide basis
final FeedFetcherCache cache = getFeedInfoCache();
if (cache != null) {
SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
setRequestHeaders(connection, syndFeedInfo, userAgent);
httpConnection.connect();
try {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
if (syndFeedInfo == null) {
// this is a feed that hasn't been retrieved
syndFeedInfo = new SyndFeedInfo();
retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
} else {
// check the response code
final int responseCode = httpConnection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
// the response code is not 304 NOT MODIFIED
// This is either because the feed server
// does not support condition gets
// or because the feed hasn't changed
retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
} else {
// the feed does not need retrieving
fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, connection);
}
}
return syndFeedInfo.getSyndFeed();
} finally {
httpConnection.disconnect();
}
} else {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
InputStream inputStream = null;
setRequestHeaders(connection, null, userAgent);
httpConnection.connect();
try {
inputStream = httpConnection.getInputStream();
return getSyndFeedFromStream(inputStream, connection);
} catch (final java.io.IOException e) {
handleErrorCodes(((HttpURLConnection) connection).getResponseCode());
} finally {
IO.close(inputStream);
httpConnection.disconnect();
}
// we will never actually get to this line
return null;
}
} | java | @Override
public SyndFeed retrieveFeed(final String userAgent, final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException {
if (feedUrl == null) {
throw new IllegalArgumentException("null is not a valid URL");
}
final URLConnection connection = feedUrl.openConnection();
if (!(connection instanceof HttpURLConnection)) {
throw new IllegalArgumentException(feedUrl.toExternalForm() + " is not a valid HTTP Url");
}
final HttpURLConnection httpConnection = (HttpURLConnection) connection;
if (connectTimeout >= 0) {
httpConnection.setConnectTimeout(connectTimeout);
}
// httpConnection.setInstanceFollowRedirects(true); // this is true by default, but can be
// changed on a claswide basis
final FeedFetcherCache cache = getFeedInfoCache();
if (cache != null) {
SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
setRequestHeaders(connection, syndFeedInfo, userAgent);
httpConnection.connect();
try {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
if (syndFeedInfo == null) {
// this is a feed that hasn't been retrieved
syndFeedInfo = new SyndFeedInfo();
retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
} else {
// check the response code
final int responseCode = httpConnection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
// the response code is not 304 NOT MODIFIED
// This is either because the feed server
// does not support condition gets
// or because the feed hasn't changed
retrieveAndCacheFeed(feedUrl, syndFeedInfo, httpConnection);
} else {
// the feed does not need retrieving
fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, connection);
}
}
return syndFeedInfo.getSyndFeed();
} finally {
httpConnection.disconnect();
}
} else {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, connection);
InputStream inputStream = null;
setRequestHeaders(connection, null, userAgent);
httpConnection.connect();
try {
inputStream = httpConnection.getInputStream();
return getSyndFeedFromStream(inputStream, connection);
} catch (final java.io.IOException e) {
handleErrorCodes(((HttpURLConnection) connection).getResponseCode());
} finally {
IO.close(inputStream);
httpConnection.disconnect();
}
// we will never actually get to this line
return null;
}
} | [
"@",
"Override",
"public",
"SyndFeed",
"retrieveFeed",
"(",
"final",
"String",
"userAgent",
",",
"final",
"URL",
"feedUrl",
")",
"throws",
"IllegalArgumentException",
",",
"IOException",
",",
"FeedException",
",",
"FetcherException",
"{",
"if",
"(",
"feedUrl",
"==... | Retrieve a feed over HTTP
@param feedUrl A non-null URL of a RSS/Atom feed to retrieve
@return A {@link com.rometools.rome.feed.synd.SyndFeed} object
@throws IllegalArgumentException if the URL is null;
@throws IOException if a TCP error occurs
@throws FeedException if the feed is not valid
@throws FetcherException if a HTTP error occurred | [
"Retrieve",
"a",
"feed",
"over",
"HTTP"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-fetcher/src/main/java/com/rometools/fetcher/impl/HttpURLFeedFetcher.java#L118-L184 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/FactoryFinder.java | FactoryFinder.newInstance | private static Object newInstance(final String className, ClassLoader cl, final boolean doFallback) throws ConfigurationError {
try {
Class<?> providerClass;
if (cl == null) {
// If classloader is null Use the bootstrap ClassLoader.
// Thus Class.forName(String) will use the current
// ClassLoader which will be the bootstrap ClassLoader.
providerClass = Class.forName(className);
} else {
try {
providerClass = cl.loadClass(className);
} catch (final ClassNotFoundException x) {
if (doFallback) {
// Fall back to current classloader
cl = FactoryFinder.class.getClassLoader();
providerClass = cl.loadClass(className);
} else {
throw x;
}
}
}
final Object instance = providerClass.newInstance();
dPrint("created new instance of " + providerClass + " using ClassLoader: " + cl);
return instance;
} catch (final ClassNotFoundException x) {
throw new ConfigurationError("Provider " + className + " not found", x);
} catch (final Exception x) {
throw new ConfigurationError("Provider " + className + " could not be instantiated: " + x, x);
}
} | java | private static Object newInstance(final String className, ClassLoader cl, final boolean doFallback) throws ConfigurationError {
try {
Class<?> providerClass;
if (cl == null) {
// If classloader is null Use the bootstrap ClassLoader.
// Thus Class.forName(String) will use the current
// ClassLoader which will be the bootstrap ClassLoader.
providerClass = Class.forName(className);
} else {
try {
providerClass = cl.loadClass(className);
} catch (final ClassNotFoundException x) {
if (doFallback) {
// Fall back to current classloader
cl = FactoryFinder.class.getClassLoader();
providerClass = cl.loadClass(className);
} else {
throw x;
}
}
}
final Object instance = providerClass.newInstance();
dPrint("created new instance of " + providerClass + " using ClassLoader: " + cl);
return instance;
} catch (final ClassNotFoundException x) {
throw new ConfigurationError("Provider " + className + " not found", x);
} catch (final Exception x) {
throw new ConfigurationError("Provider " + className + " could not be instantiated: " + x, x);
}
} | [
"private",
"static",
"Object",
"newInstance",
"(",
"final",
"String",
"className",
",",
"ClassLoader",
"cl",
",",
"final",
"boolean",
"doFallback",
")",
"throws",
"ConfigurationError",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"providerClass",
";",
"if",
"(",
... | Create an instance of a class using the specified ClassLoader and optionally fall back to the
current ClassLoader if not found.
@param className Name of the concrete class corresponding to the service provider
@param cl ClassLoader to use to load the class, null means to use the bootstrap ClassLoader
@param doFallback true if the current ClassLoader should be tried as a fallback if the class
is not found using cl | [
"Create",
"an",
"instance",
"of",
"a",
"class",
"using",
"the",
"specified",
"ClassLoader",
"and",
"optionally",
"fall",
"back",
"to",
"the",
"current",
"ClassLoader",
"if",
"not",
"found",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/FactoryFinder.java#L58-L89 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/FactoryFinder.java | FactoryFinder.find | static Object find(final String factoryId, final String fallbackClassName) throws ConfigurationError {
// Figure out which ClassLoader to use for loading the provider
// class. If there is a Context ClassLoader then use it.
ClassLoader classLoader = ss.getContextClassLoader();
if (classLoader == null) {
// if we have no Context ClassLoader
// so use the current ClassLoader
classLoader = FactoryFinder.class.getClassLoader();
}
dPrint("find factoryId =" + factoryId);
// Use the system property first
try {
final String systemProp = ss.getSystemProperty(factoryId);
if (systemProp != null) {
dPrint("found system property, value=" + systemProp);
return newInstance(systemProp, classLoader, true);
}
} catch (final SecurityException se) {
// if first option fails due to any reason we should try next option in the
// look up algorithm.
}
// try to read from /propono.properties
try {
final String configFile = "/propono.properties";
String factoryClassName = null;
if (firstTime) {
synchronized (cacheProps) {
if (firstTime) {
try {
final InputStream is = FactoryFinder.class.getResourceAsStream(configFile);
firstTime = false;
if (is != null) {
dPrint("Read properties file: " + configFile);
cacheProps.load(is);
}
} catch (final Exception intentionallyIgnored) {
}
}
}
}
factoryClassName = cacheProps.getProperty(factoryId);
if (factoryClassName != null) {
dPrint("found in $java.home/propono.properties, value=" + factoryClassName);
return newInstance(factoryClassName, classLoader, true);
}
} catch (final Exception ex) {
if (debug) {
ex.printStackTrace();
}
}
// Try Jar Service Provider Mechanism
final Object provider = findJarServiceProvider(factoryId);
if (provider != null) {
return provider;
}
if (fallbackClassName == null) {
throw new ConfigurationError("Provider for " + factoryId + " cannot be found", null);
}
dPrint("loaded from fallback value: " + fallbackClassName);
return newInstance(fallbackClassName, classLoader, true);
} | java | static Object find(final String factoryId, final String fallbackClassName) throws ConfigurationError {
// Figure out which ClassLoader to use for loading the provider
// class. If there is a Context ClassLoader then use it.
ClassLoader classLoader = ss.getContextClassLoader();
if (classLoader == null) {
// if we have no Context ClassLoader
// so use the current ClassLoader
classLoader = FactoryFinder.class.getClassLoader();
}
dPrint("find factoryId =" + factoryId);
// Use the system property first
try {
final String systemProp = ss.getSystemProperty(factoryId);
if (systemProp != null) {
dPrint("found system property, value=" + systemProp);
return newInstance(systemProp, classLoader, true);
}
} catch (final SecurityException se) {
// if first option fails due to any reason we should try next option in the
// look up algorithm.
}
// try to read from /propono.properties
try {
final String configFile = "/propono.properties";
String factoryClassName = null;
if (firstTime) {
synchronized (cacheProps) {
if (firstTime) {
try {
final InputStream is = FactoryFinder.class.getResourceAsStream(configFile);
firstTime = false;
if (is != null) {
dPrint("Read properties file: " + configFile);
cacheProps.load(is);
}
} catch (final Exception intentionallyIgnored) {
}
}
}
}
factoryClassName = cacheProps.getProperty(factoryId);
if (factoryClassName != null) {
dPrint("found in $java.home/propono.properties, value=" + factoryClassName);
return newInstance(factoryClassName, classLoader, true);
}
} catch (final Exception ex) {
if (debug) {
ex.printStackTrace();
}
}
// Try Jar Service Provider Mechanism
final Object provider = findJarServiceProvider(factoryId);
if (provider != null) {
return provider;
}
if (fallbackClassName == null) {
throw new ConfigurationError("Provider for " + factoryId + " cannot be found", null);
}
dPrint("loaded from fallback value: " + fallbackClassName);
return newInstance(fallbackClassName, classLoader, true);
} | [
"static",
"Object",
"find",
"(",
"final",
"String",
"factoryId",
",",
"final",
"String",
"fallbackClassName",
")",
"throws",
"ConfigurationError",
"{",
"// Figure out which ClassLoader to use for loading the provider",
"// class. If there is a Context ClassLoader then use it.",
"Cl... | Finds the implementation Class object in the specified order. Main entry point.
@return Class object of factory, never null
@param factoryId Name of the factory to find, same as a property name
@param fallbackClassName Implementation class name, if nothing else is found. Use null to
mean no fallback.
Package private so this code can be shared. | [
"Finds",
"the",
"implementation",
"Class",
"object",
"in",
"the",
"specified",
"order",
".",
"Main",
"entry",
"point",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/FactoryFinder.java#L102-L171 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Doubles.java | Doubles.parse | public static Double parse(final String s) {
Double parsed = null;
try {
if (s != null) {
parsed = Double.parseDouble(s);
}
} catch (final NumberFormatException e) {
}
return parsed;
} | java | public static Double parse(final String s) {
Double parsed = null;
try {
if (s != null) {
parsed = Double.parseDouble(s);
}
} catch (final NumberFormatException e) {
}
return parsed;
} | [
"public",
"static",
"Double",
"parse",
"(",
"final",
"String",
"s",
")",
"{",
"Double",
"parsed",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"parsed",
"=",
"Double",
".",
"parseDouble",
"(",
"s",
")",
";",
"}",
"}",
"ca... | Converts a String into an Double.
@param s The String to convert, may be null
@return The parsed Double or null when parsing is not possible | [
"Converts",
"a",
"String",
"into",
"an",
"Double",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Doubles.java#L28-L37 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/base/types/PriceTypeEnumeration.java | PriceTypeEnumeration.findByValue | public static PriceTypeEnumeration findByValue(final String value) {
if (value.equalsIgnoreCase("negotiable")) {
return PriceTypeEnumeration.NEGOTIABLE;
} else {
return PriceTypeEnumeration.STARTING;
}
} | java | public static PriceTypeEnumeration findByValue(final String value) {
if (value.equalsIgnoreCase("negotiable")) {
return PriceTypeEnumeration.NEGOTIABLE;
} else {
return PriceTypeEnumeration.STARTING;
}
} | [
"public",
"static",
"PriceTypeEnumeration",
"findByValue",
"(",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"value",
".",
"equalsIgnoreCase",
"(",
"\"negotiable\"",
")",
")",
"{",
"return",
"PriceTypeEnumeration",
".",
"NEGOTIABLE",
";",
"}",
"else",
"{",
... | Returns a PriceTypeEnumeration based on the String value or null.
@param value Value to search for.
@return PriceTypeEnumeration or null. | [
"Returns",
"a",
"PriceTypeEnumeration",
"based",
"on",
"the",
"String",
"value",
"or",
"null",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/base/types/PriceTypeEnumeration.java#L57-L63 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/RSS090Generator.java | RSS090Generator.populateChannel | protected void populateChannel(final Channel channel, final Element eChannel) {
final String title = channel.getTitle();
if (title != null) {
eChannel.addContent(generateSimpleElement("title", title));
}
final String link = channel.getLink();
if (link != null) {
eChannel.addContent(generateSimpleElement("link", link));
}
final String description = channel.getDescription();
if (description != null) {
eChannel.addContent(generateSimpleElement("description", description));
}
} | java | protected void populateChannel(final Channel channel, final Element eChannel) {
final String title = channel.getTitle();
if (title != null) {
eChannel.addContent(generateSimpleElement("title", title));
}
final String link = channel.getLink();
if (link != null) {
eChannel.addContent(generateSimpleElement("link", link));
}
final String description = channel.getDescription();
if (description != null) {
eChannel.addContent(generateSimpleElement("description", description));
}
} | [
"protected",
"void",
"populateChannel",
"(",
"final",
"Channel",
"channel",
",",
"final",
"Element",
"eChannel",
")",
"{",
"final",
"String",
"title",
"=",
"channel",
".",
"getTitle",
"(",
")",
";",
"if",
"(",
"title",
"!=",
"null",
")",
"{",
"eChannel",
... | Populates the given channel with parsed data from the ROME element that holds the channel
data.
@param channel the channel into which parsed data will be added.
@param eChannel the XML element that holds the data for the channel. | [
"Populates",
"the",
"given",
"channel",
"with",
"parsed",
"data",
"from",
"the",
"ROME",
"element",
"that",
"holds",
"the",
"channel",
"data",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/RSS090Generator.java#L111-L124 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS10.java | ConverterForRSS10.createSyndEntry | @Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
final Description desc = item.getDescription();
if (desc != null) {
final SyndContent descContent = new SyndContentImpl();
descContent.setType(desc.getType());
descContent.setValue(desc.getValue());
syndEntry.setDescription(descContent);
}
final Content cont = item.getContent();
if (cont != null) {
final SyndContent contContent = new SyndContentImpl();
contContent.setType(cont.getType());
contContent.setValue(cont.getValue());
final List<SyndContent> contents = new ArrayList<SyndContent>();
contents.add(contContent);
syndEntry.setContents(contents);
}
return syndEntry;
} | java | @Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
final Description desc = item.getDescription();
if (desc != null) {
final SyndContent descContent = new SyndContentImpl();
descContent.setType(desc.getType());
descContent.setValue(desc.getValue());
syndEntry.setDescription(descContent);
}
final Content cont = item.getContent();
if (cont != null) {
final SyndContent contContent = new SyndContentImpl();
contContent.setType(cont.getType());
contContent.setValue(cont.getValue());
final List<SyndContent> contents = new ArrayList<SyndContent>();
contents.add(contContent);
syndEntry.setContents(contents);
}
return syndEntry;
} | [
"@",
"Override",
"protected",
"SyndEntry",
"createSyndEntry",
"(",
"final",
"Item",
"item",
",",
"final",
"boolean",
"preserveWireItem",
")",
"{",
"final",
"SyndEntry",
"syndEntry",
"=",
"super",
".",
"createSyndEntry",
"(",
"item",
",",
"preserveWireItem",
")",
... | rss.description -> synd.description | [
"rss",
".",
"description",
"-",
">",
"synd",
".",
"description"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS10.java#L64-L92 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/AtomServlet.java | AtomServlet.doDelete | @Override
protected void doDelete(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
final AtomRequest areq = new AtomRequestImpl(req);
try {
if (handler.isEntryURI(areq)) {
handler.deleteEntry(areq);
res.setStatus(HttpServletResponse.SC_OK);
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
LOG.debug("An error occured while processing DELETE", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
LOG.debug("An error occured while processing DELETE", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
// Wanted to use sendError() here but Tomcat sends 403 forbidden
// when I do that, so sticking with setStatus() for time being.
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
LOG.debug("Exiting");
} | java | @Override
protected void doDelete(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
LOG.debug("Entering");
final AtomHandler handler = createAtomRequestHandler(req, res);
final String userName = handler.getAuthenticatedUsername();
if (userName != null) {
final AtomRequest areq = new AtomRequestImpl(req);
try {
if (handler.isEntryURI(areq)) {
handler.deleteEntry(areq);
res.setStatus(HttpServletResponse.SC_OK);
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} catch (final AtomException ae) {
res.sendError(ae.getStatus(), ae.getMessage());
LOG.debug("An error occured while processing DELETE", ae);
} catch (final Exception e) {
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
LOG.debug("An error occured while processing DELETE", e);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
// Wanted to use sendError() here but Tomcat sends 403 forbidden
// when I do that, so sticking with setStatus() for time being.
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
LOG.debug("Exiting");
} | [
"@",
"Override",
"protected",
"void",
"doDelete",
"(",
"final",
"HttpServletRequest",
"req",
",",
"final",
"HttpServletResponse",
"res",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"LOG",
".",
"debug",
"(",
"\"Entering\"",
")",
";",
"final",
"Ato... | Handle Atom DELETE by calling appropriate handler. | [
"Handle",
"Atom",
"DELETE",
"by",
"calling",
"appropriate",
"handler",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/AtomServlet.java#L328-L356 | train |
rometools/rome | rome-opml/src/main/java/com/rometools/opml/feed/opml/Outline.java | Outline.getAttributeValue | public String getAttributeValue(final String name) {
final List<Attribute> attributes = Collections.synchronizedList(getAttributes());
for (int i = 0; i < attributes.size(); i++) {
final Attribute a = attributes.get(i);
if (a.getName() != null && a.getName().equals(name)) {
return a.getValue();
}
}
return null;
} | java | public String getAttributeValue(final String name) {
final List<Attribute> attributes = Collections.synchronizedList(getAttributes());
for (int i = 0; i < attributes.size(); i++) {
final Attribute a = attributes.get(i);
if (a.getName() != null && a.getName().equals(name)) {
return a.getValue();
}
}
return null;
} | [
"public",
"String",
"getAttributeValue",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"List",
"<",
"Attribute",
">",
"attributes",
"=",
"Collections",
".",
"synchronizedList",
"(",
"getAttributes",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0"... | Returns the value of an attribute on the outline or null.
@param name name of the attribute. | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"on",
"the",
"outline",
"or",
"null",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-opml/src/main/java/com/rometools/opml/feed/opml/Outline.java#L310-L320 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java | Publisher.sendUpdateNotification | public void sendUpdateNotification(final String hub, final String topic) throws NotificationException {
try {
final StringBuilder sb = new StringBuilder("hub.mode=publish&hub.url=").append(URLEncoder.encode(topic, "UTF-8"));
final URL hubUrl = new URL(hub);
final HttpURLConnection connection = (HttpURLConnection) hubUrl.openConnection();
// connection.setRequestProperty("Host", hubUrl.getHost());
connection.setRequestProperty("User-Agent", "ROME-Certiorem");
connection.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
connection.connect();
final OutputStream os = connection.getOutputStream();
os.write(sb.toString().getBytes("UTF-8"));
os.close();
final int rc = connection.getResponseCode();
connection.disconnect();
if (rc != 204) {
throw new NotificationException("Server returned an unexcepted response code: " + rc + " " + connection.getResponseMessage());
}
} catch (final UnsupportedEncodingException ex) {
LOG.error("Could not encode URL", ex);
throw new NotificationException("Could not encode URL", ex);
} catch (final IOException ex) {
LOG.error("Communication error", ex);
throw new NotificationException("Unable to communicate with " + hub, ex);
}
} | java | public void sendUpdateNotification(final String hub, final String topic) throws NotificationException {
try {
final StringBuilder sb = new StringBuilder("hub.mode=publish&hub.url=").append(URLEncoder.encode(topic, "UTF-8"));
final URL hubUrl = new URL(hub);
final HttpURLConnection connection = (HttpURLConnection) hubUrl.openConnection();
// connection.setRequestProperty("Host", hubUrl.getHost());
connection.setRequestProperty("User-Agent", "ROME-Certiorem");
connection.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
connection.connect();
final OutputStream os = connection.getOutputStream();
os.write(sb.toString().getBytes("UTF-8"));
os.close();
final int rc = connection.getResponseCode();
connection.disconnect();
if (rc != 204) {
throw new NotificationException("Server returned an unexcepted response code: " + rc + " " + connection.getResponseMessage());
}
} catch (final UnsupportedEncodingException ex) {
LOG.error("Could not encode URL", ex);
throw new NotificationException("Could not encode URL", ex);
} catch (final IOException ex) {
LOG.error("Communication error", ex);
throw new NotificationException("Unable to communicate with " + hub, ex);
}
} | [
"public",
"void",
"sendUpdateNotification",
"(",
"final",
"String",
"hub",
",",
"final",
"String",
"topic",
")",
"throws",
"NotificationException",
"{",
"try",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"hub.mode=publish&hub.url=\"",
")... | Sends the HUB url a notification of a change in topic
@param hub URL of the hub to notify.
@param topic The Topic that has changed
@throws NotificationException Any failure | [
"Sends",
"the",
"HUB",
"url",
"a",
"notification",
"of",
"a",
"change",
"in",
"topic"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java#L68-L97 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java | Publisher.sendUpdateNotification | public void sendUpdateNotification(final String topic, final SyndFeed feed) throws NotificationException {
for (final SyndLink link : feed.getLinks()) {
if ("hub".equals(link.getRel())) {
sendUpdateNotification(link.getRel(), topic);
return;
}
}
throw new NotificationException("Hub link not found.");
} | java | public void sendUpdateNotification(final String topic, final SyndFeed feed) throws NotificationException {
for (final SyndLink link : feed.getLinks()) {
if ("hub".equals(link.getRel())) {
sendUpdateNotification(link.getRel(), topic);
return;
}
}
throw new NotificationException("Hub link not found.");
} | [
"public",
"void",
"sendUpdateNotification",
"(",
"final",
"String",
"topic",
",",
"final",
"SyndFeed",
"feed",
")",
"throws",
"NotificationException",
"{",
"for",
"(",
"final",
"SyndLink",
"link",
":",
"feed",
".",
"getLinks",
"(",
")",
")",
"{",
"if",
"(",
... | Sends a notification for a feed located at "topic". The feed MUST contain rel="hub".
@param topic URL for the feed
@param feed The feed itself
@throws NotificationException Any failure | [
"Sends",
"a",
"notification",
"for",
"a",
"feed",
"located",
"at",
"topic",
".",
"The",
"feed",
"MUST",
"contain",
"rel",
"=",
"hub",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java#L106-L115 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java | Publisher.sendUpdateNotification | public void sendUpdateNotification(final SyndFeed feed) throws NotificationException {
SyndLink hub = null;
SyndLink self = null;
for (final SyndLink link : feed.getLinks()) {
if ("hub".equals(link.getRel())) {
hub = link;
}
if ("self".equals(link.getRel())) {
self = link;
}
if (hub != null && self != null) {
break;
}
}
if (hub == null) {
throw new NotificationException("A link rel='hub' was not found in the feed.");
}
if (self == null) {
throw new NotificationException("A link rel='self' was not found in the feed.");
}
sendUpdateNotification(hub.getRel(), self.getHref());
} | java | public void sendUpdateNotification(final SyndFeed feed) throws NotificationException {
SyndLink hub = null;
SyndLink self = null;
for (final SyndLink link : feed.getLinks()) {
if ("hub".equals(link.getRel())) {
hub = link;
}
if ("self".equals(link.getRel())) {
self = link;
}
if (hub != null && self != null) {
break;
}
}
if (hub == null) {
throw new NotificationException("A link rel='hub' was not found in the feed.");
}
if (self == null) {
throw new NotificationException("A link rel='self' was not found in the feed.");
}
sendUpdateNotification(hub.getRel(), self.getHref());
} | [
"public",
"void",
"sendUpdateNotification",
"(",
"final",
"SyndFeed",
"feed",
")",
"throws",
"NotificationException",
"{",
"SyndLink",
"hub",
"=",
"null",
";",
"SyndLink",
"self",
"=",
"null",
";",
"for",
"(",
"final",
"SyndLink",
"link",
":",
"feed",
".",
"... | Sends a notification for a feed. The feed MUST contain rel="hub" and rel="self" links.
@param feed The feed to notify
@throws NotificationException Any failure | [
"Sends",
"a",
"notification",
"for",
"a",
"feed",
".",
"The",
"feed",
"MUST",
"contain",
"rel",
"=",
"hub",
"and",
"rel",
"=",
"self",
"links",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java#L123-L150 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java | Publisher.sendUpdateNotificationAsyncronously | public void sendUpdateNotificationAsyncronously(final String hub, final String topic, final AsyncNotificationCallback callback) {
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendUpdateNotification(hub, topic);
callback.onSuccess();
} catch (final Throwable t) {
callback.onFailure(t);
}
}
};
if (executor != null) {
executor.execute(r);
} else {
new Thread(r).start();
}
} | java | public void sendUpdateNotificationAsyncronously(final String hub, final String topic, final AsyncNotificationCallback callback) {
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendUpdateNotification(hub, topic);
callback.onSuccess();
} catch (final Throwable t) {
callback.onFailure(t);
}
}
};
if (executor != null) {
executor.execute(r);
} else {
new Thread(r).start();
}
} | [
"public",
"void",
"sendUpdateNotificationAsyncronously",
"(",
"final",
"String",
"hub",
",",
"final",
"String",
"topic",
",",
"final",
"AsyncNotificationCallback",
"callback",
")",
"{",
"final",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Overr... | Sends the HUB url a notification of a change in topic asynchronously
@param hub URL of the hub to notify.
@param topic The Topic that has changed
@param callback A callback invoked when the notification completes.
@throws NotificationException Any failure | [
"Sends",
"the",
"HUB",
"url",
"a",
"notification",
"of",
"a",
"change",
"in",
"topic",
"asynchronously"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java#L160-L178 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.getCategories | @Override
public Categories getCategories(final AtomRequest areq) throws AtomException {
LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
return col.getCategories(true).get(0);
} | java | @Override
public Categories getCategories(final AtomRequest areq) throws AtomException {
LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
return col.getCategories(true).get(0);
} | [
"@",
"Override",
"public",
"Categories",
"getCategories",
"(",
"final",
"AtomRequest",
"areq",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"getCollection\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"spli... | Returns null because we use in-line categories.
@throws com.rometools.rome.propono.atom.server.AtomException Unexpected exception.
@return Categories object | [
"Returns",
"null",
"because",
"we",
"use",
"in",
"-",
"line",
"categories",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L138-L146 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.getCollection | @Override
public Feed getCollection(final AtomRequest areq) throws AtomException {
LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
return col.getFeedDocument();
} | java | @Override
public Feed getCollection(final AtomRequest areq) throws AtomException {
LOG.debug("getCollection");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
return col.getFeedDocument();
} | [
"@",
"Override",
"public",
"Feed",
"getCollection",
"(",
"final",
"AtomRequest",
"areq",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"getCollection\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"split",
... | Get collection specified by pathinfo.
@param areq Details of HTTP request
@return ROME feed representing collection.
@throws com.rometools.rome.propono.atom.server.AtomException Invalid collection or other
exception. | [
"Get",
"collection",
"specified",
"by",
"pathinfo",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L156-L164 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.postEntry | @Override
public Entry postEntry(final AtomRequest areq, final Entry entry) throws AtomException {
LOG.debug("postEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
return col.addEntry(entry);
} catch (final Exception fe) {
fe.printStackTrace();
throw new AtomException(fe);
}
} | java | @Override
public Entry postEntry(final AtomRequest areq, final Entry entry) throws AtomException {
LOG.debug("postEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
return col.addEntry(entry);
} catch (final Exception fe) {
fe.printStackTrace();
throw new AtomException(fe);
}
} | [
"@",
"Override",
"public",
"Entry",
"postEntry",
"(",
"final",
"AtomRequest",
"areq",
",",
"final",
"Entry",
"entry",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"postEntry\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"S... | Create a new entry specified by pathInfo and posted entry. We save the submitted Atom entry
verbatim, but we do set the id and reset the update time.
@param entry Entry to be added to collection.
@param areq Details of HTTP request
@throws com.rometools.rome.propono.atom.server.AtomException On invalid collection or other
error.
@return Entry as represented on server. | [
"Create",
"a",
"new",
"entry",
"specified",
"by",
"pathInfo",
"and",
"posted",
"entry",
".",
"We",
"save",
"the",
"submitted",
"Atom",
"entry",
"verbatim",
"but",
"we",
"do",
"set",
"the",
"id",
"and",
"reset",
"the",
"update",
"time",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L176-L191 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.putEntry | @Override
public void putEntry(final AtomRequest areq, final Entry entry) throws AtomException {
LOG.debug("putEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[2];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.updateEntry(entry, fileName);
} catch (final Exception fe) {
throw new AtomException(fe);
}
} | java | @Override
public void putEntry(final AtomRequest areq, final Entry entry) throws AtomException {
LOG.debug("putEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[2];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.updateEntry(entry, fileName);
} catch (final Exception fe) {
throw new AtomException(fe);
}
} | [
"@",
"Override",
"public",
"void",
"putEntry",
"(",
"final",
"AtomRequest",
"areq",
",",
"final",
"Entry",
"entry",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"putEntry\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"Stri... | Update entry specified by pathInfo and posted entry.
@param entry
@param areq Details of HTTP request
@throws com.rometools.rome.propono.atom.server.AtomException | [
"Update",
"entry",
"specified",
"by",
"pathInfo",
"and",
"posted",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L227-L241 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.deleteEntry | @Override
public void deleteEntry(final AtomRequest areq) throws AtomException {
LOG.debug("deleteEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[2];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.deleteEntry(fileName);
} catch (final Exception e) {
final String msg = "ERROR in atom.deleteResource";
LOG.error(msg, e);
throw new AtomException(msg);
}
} | java | @Override
public void deleteEntry(final AtomRequest areq) throws AtomException {
LOG.debug("deleteEntry");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[2];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.deleteEntry(fileName);
} catch (final Exception e) {
final String msg = "ERROR in atom.deleteResource";
LOG.error(msg, e);
throw new AtomException(msg);
}
} | [
"@",
"Override",
"public",
"void",
"deleteEntry",
"(",
"final",
"AtomRequest",
"areq",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"deleteEntry\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"split",
"(",... | Delete entry specified by pathInfo.
@param areq Details of HTTP request | [
"Delete",
"entry",
"specified",
"by",
"pathInfo",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L248-L264 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.postMedia | @Override
public Entry postMedia(final AtomRequest areq, final Entry entry) throws AtomException {
// get incoming slug from HTTP header
final String slug = areq.getHeader("Slug");
if (LOG.isDebugEnabled()) {
LOG.debug("postMedia - title: " + entry.getTitle() + " slug:" + slug);
}
try {
final File tempFile = null;
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.addMediaEntry(entry, slug, areq.getInputStream());
} catch (final Exception e) {
e.printStackTrace();
final String msg = "ERROR reading posted file";
LOG.error(msg, e);
throw new AtomException(msg, e);
} finally {
if (tempFile != null) {
tempFile.delete();
}
}
} catch (final Exception re) {
throw new AtomException("ERROR: posting media");
}
return entry;
} | java | @Override
public Entry postMedia(final AtomRequest areq, final Entry entry) throws AtomException {
// get incoming slug from HTTP header
final String slug = areq.getHeader("Slug");
if (LOG.isDebugEnabled()) {
LOG.debug("postMedia - title: " + entry.getTitle() + " slug:" + slug);
}
try {
final File tempFile = null;
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.addMediaEntry(entry, slug, areq.getInputStream());
} catch (final Exception e) {
e.printStackTrace();
final String msg = "ERROR reading posted file";
LOG.error(msg, e);
throw new AtomException(msg, e);
} finally {
if (tempFile != null) {
tempFile.delete();
}
}
} catch (final Exception re) {
throw new AtomException("ERROR: posting media");
}
return entry;
} | [
"@",
"Override",
"public",
"Entry",
"postMedia",
"(",
"final",
"AtomRequest",
"areq",
",",
"final",
"Entry",
"entry",
")",
"throws",
"AtomException",
"{",
"// get incoming slug from HTTP header",
"final",
"String",
"slug",
"=",
"areq",
".",
"getHeader",
"(",
"\"Sl... | Store media data in collection specified by pathInfo, create an Atom media-link entry to
store metadata for the new media file and return that entry to the caller.
@param areq Details of HTTP request
@param entry New entry initialzied with only title and content type
@return Location URL of new media entry | [
"Store",
"media",
"data",
"in",
"collection",
"specified",
"by",
"pathInfo",
"create",
"an",
"Atom",
"media",
"-",
"link",
"entry",
"to",
"store",
"metadata",
"for",
"the",
"new",
"media",
"file",
"and",
"return",
"that",
"entry",
"to",
"the",
"caller",
".... | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L274-L308 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.putMedia | @Override
public void putMedia(final AtomRequest areq) throws AtomException {
LOG.debug("putMedia");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[3];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.updateMediaEntry(fileName, areq.getContentType(), areq.getInputStream());
} catch (final Exception re) {
throw new AtomException("ERROR: posting media");
}
} | java | @Override
public void putMedia(final AtomRequest areq) throws AtomException {
LOG.debug("putMedia");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
final String handle = pathInfo[0];
final String collection = pathInfo[1];
final String fileName = pathInfo[3];
final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
try {
col.updateMediaEntry(fileName, areq.getContentType(), areq.getInputStream());
} catch (final Exception re) {
throw new AtomException("ERROR: posting media");
}
} | [
"@",
"Override",
"public",
"void",
"putMedia",
"(",
"final",
"AtomRequest",
"areq",
")",
"throws",
"AtomException",
"{",
"LOG",
".",
"debug",
"(",
"\"putMedia\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"split",
"(",
"ar... | Update the media file part of a media-link entry.
@param areq Details of HTTP request Assuming pathInfo of form /user-name/resource/name | [
"Update",
"the",
"media",
"file",
"part",
"of",
"a",
"media",
"-",
"link",
"entry",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L315-L330 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.isAtomServiceURI | @Override
public boolean isAtomServiceURI(final AtomRequest areq) {
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 0) {
return true;
}
return false;
} | java | @Override
public boolean isAtomServiceURI(final AtomRequest areq) {
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 0) {
return true;
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"isAtomServiceURI",
"(",
"final",
"AtomRequest",
"areq",
")",
"{",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"split",
"(",
"areq",
".",
"getPathInfo",
"(",
")",
",",
"\"/\"",
")",
";",
"if",
"... | Return true if specified pathinfo represents URI of service doc. | [
"Return",
"true",
"if",
"specified",
"pathinfo",
"represents",
"URI",
"of",
"service",
"doc",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L351-L358 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.isCategoriesURI | @Override
public boolean isCategoriesURI(final AtomRequest areq) {
LOG.debug("isCategoriesDocumentURI");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 3 && "categories".equals(pathInfo[2])) {
return true;
}
return false;
} | java | @Override
public boolean isCategoriesURI(final AtomRequest areq) {
LOG.debug("isCategoriesDocumentURI");
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 3 && "categories".equals(pathInfo[2])) {
return true;
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"isCategoriesURI",
"(",
"final",
"AtomRequest",
"areq",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"isCategoriesDocumentURI\"",
")",
";",
"final",
"String",
"[",
"]",
"pathInfo",
"=",
"StringUtils",
".",
"split",
"(",
"areq",
... | Return true if specified pathinfo represents URI of category doc. | [
"Return",
"true",
"if",
"specified",
"pathinfo",
"represents",
"URI",
"of",
"category",
"doc",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L363-L371 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.isCollectionURI | @Override
public boolean isCollectionURI(final AtomRequest areq) {
LOG.debug("isCollectionURI");
// workspace/collection-plural
// if length is 2 and points to a valid collection then YES
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 2) {
final String handle = pathInfo[0];
final String collection = pathInfo[1];
if (service.findCollectionByHandle(handle, collection) != null) {
return true;
}
}
return false;
} | java | @Override
public boolean isCollectionURI(final AtomRequest areq) {
LOG.debug("isCollectionURI");
// workspace/collection-plural
// if length is 2 and points to a valid collection then YES
final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
if (pathInfo.length == 2) {
final String handle = pathInfo[0];
final String collection = pathInfo[1];
if (service.findCollectionByHandle(handle, collection) != null) {
return true;
}
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"isCollectionURI",
"(",
"final",
"AtomRequest",
"areq",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"isCollectionURI\"",
")",
";",
"// workspace/collection-plural",
"// if length is 2 and points to a valid collection then YES",
"final",
"Stri... | Return true if specified pathinfo represents URI of a collection. | [
"Return",
"true",
"if",
"specified",
"pathinfo",
"represents",
"URI",
"of",
"a",
"collection",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L376-L391 | train |
rometools/rome | rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java | FileBasedAtomHandler.authenticateBASIC | public String authenticateBASIC(final HttpServletRequest request) {
LOG.debug("authenticateBASIC");
boolean valid = false;
String userID = null;
String password = null;
try {
final String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
final StringTokenizer st = new StringTokenizer(authHeader);
if (st.hasMoreTokens()) {
final String basic = st.nextToken();
if (basic.equalsIgnoreCase("Basic")) {
final String credentials = st.nextToken();
final String userPass = new String(Base64.decodeBase64(credentials.getBytes()));
final int p = userPass.indexOf(":");
if (p != -1) {
userID = userPass.substring(0, p);
password = userPass.substring(p + 1);
// Validate the User.
valid = validateUser(userID, password);
}
}
}
}
} catch (final Exception e) {
LOG.debug("An error occured while processing Basic authentication", e);
}
if (valid) {
// For now assume userID as userName
return userID;
}
return null;
} | java | public String authenticateBASIC(final HttpServletRequest request) {
LOG.debug("authenticateBASIC");
boolean valid = false;
String userID = null;
String password = null;
try {
final String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
final StringTokenizer st = new StringTokenizer(authHeader);
if (st.hasMoreTokens()) {
final String basic = st.nextToken();
if (basic.equalsIgnoreCase("Basic")) {
final String credentials = st.nextToken();
final String userPass = new String(Base64.decodeBase64(credentials.getBytes()));
final int p = userPass.indexOf(":");
if (p != -1) {
userID = userPass.substring(0, p);
password = userPass.substring(p + 1);
// Validate the User.
valid = validateUser(userID, password);
}
}
}
}
} catch (final Exception e) {
LOG.debug("An error occured while processing Basic authentication", e);
}
if (valid) {
// For now assume userID as userName
return userID;
}
return null;
} | [
"public",
"String",
"authenticateBASIC",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"authenticateBASIC\"",
")",
";",
"boolean",
"valid",
"=",
"false",
";",
"String",
"userID",
"=",
"null",
";",
"String",
"password",
"=... | BASIC authentication. | [
"BASIC",
"authentication",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-propono/src/main/java/com/rometools/propono/atom/server/impl/FileBasedAtomHandler.java#L438-L471 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/feed/atom/Entry.java | Entry.isMediaEntry | public boolean isMediaEntry() {
boolean mediaEntry = false;
final List<Link> links = getOtherLinks();
for (final Link link : links) {
if ("edit-media".equals(link.getRel())) {
mediaEntry = true;
break;
}
}
return mediaEntry;
} | java | public boolean isMediaEntry() {
boolean mediaEntry = false;
final List<Link> links = getOtherLinks();
for (final Link link : links) {
if ("edit-media".equals(link.getRel())) {
mediaEntry = true;
break;
}
}
return mediaEntry;
} | [
"public",
"boolean",
"isMediaEntry",
"(",
")",
"{",
"boolean",
"mediaEntry",
"=",
"false",
";",
"final",
"List",
"<",
"Link",
">",
"links",
"=",
"getOtherLinks",
"(",
")",
";",
"for",
"(",
"final",
"Link",
"link",
":",
"links",
")",
"{",
"if",
"(",
"... | Returns true if entry is a media entry, i.e. has rel="edit-media".
@return true if entry is a media entry | [
"Returns",
"true",
"if",
"entry",
"is",
"a",
"media",
"entry",
"i",
".",
"e",
".",
"has",
"rel",
"=",
"edit",
"-",
"media",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/feed/atom/Entry.java#L261-L271 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java | ThreadPoolNotifier.enqueueNotification | @Override
protected void enqueueNotification(final Notification not) {
final Runnable r = new Runnable() {
@Override
public void run() {
not.lastRun = System.currentTimeMillis();
final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload);
if (!summary.isLastPublishSuccessful()) {
not.retryCount++;
if (not.retryCount <= 5) {
retry(not);
}
}
not.callback.onSummaryInfo(summary);
}
};
exeuctor.execute(r);
} | java | @Override
protected void enqueueNotification(final Notification not) {
final Runnable r = new Runnable() {
@Override
public void run() {
not.lastRun = System.currentTimeMillis();
final SubscriptionSummary summary = postNotification(not.subscriber, not.mimeType, not.payload);
if (!summary.isLastPublishSuccessful()) {
not.retryCount++;
if (not.retryCount <= 5) {
retry(not);
}
}
not.callback.onSummaryInfo(summary);
}
};
exeuctor.execute(r);
} | [
"@",
"Override",
"protected",
"void",
"enqueueNotification",
"(",
"final",
"Notification",
"not",
")",
"{",
"final",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"not",
".",
"lastRun",
"... | Enqueues a notification to run. If the notification fails, it will be retried every two
minutes until 5 attempts are completed. Notifications to the same callback should be
delivered successfully in order.
@param not | [
"Enqueues",
"a",
"notification",
"to",
"run",
".",
"If",
"the",
"notification",
"fails",
"it",
"will",
"be",
"retried",
"every",
"two",
"minutes",
"until",
"5",
"attempts",
"are",
"completed",
".",
"Notifications",
"to",
"the",
"same",
"callback",
"should",
... | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java#L62-L84 | train |
rometools/rome | rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java | ThreadPoolNotifier.retry | protected void retry(final Notification not) {
if (!pendings.contains(not.subscriber.getCallback())) {
// We don't have a current retry for this callback pending, so we
// will schedule the retry
pendings.add(not.subscriber.getCallback());
timer.schedule(new TimerTask() {
@Override
public void run() {
pendings.remove(not.subscriber.getCallback());
enqueueNotification(not);
}
}, TWO_MINUTES);
} else {
// There is a retry in front of this one, so we will just schedule
// it to retry again in a bit
timer.schedule(new TimerTask() {
@Override
public void run() {
retry(not);
}
}, TWO_MINUTES);
}
} | java | protected void retry(final Notification not) {
if (!pendings.contains(not.subscriber.getCallback())) {
// We don't have a current retry for this callback pending, so we
// will schedule the retry
pendings.add(not.subscriber.getCallback());
timer.schedule(new TimerTask() {
@Override
public void run() {
pendings.remove(not.subscriber.getCallback());
enqueueNotification(not);
}
}, TWO_MINUTES);
} else {
// There is a retry in front of this one, so we will just schedule
// it to retry again in a bit
timer.schedule(new TimerTask() {
@Override
public void run() {
retry(not);
}
}, TWO_MINUTES);
}
} | [
"protected",
"void",
"retry",
"(",
"final",
"Notification",
"not",
")",
"{",
"if",
"(",
"!",
"pendings",
".",
"contains",
"(",
"not",
".",
"subscriber",
".",
"getCallback",
"(",
")",
")",
")",
"{",
"// We don't have a current retry for this callback pending, so we... | Schedules a notification to retry in two minutes.
@param not Notification to retry | [
"Schedules",
"a",
"notification",
"to",
"retry",
"in",
"two",
"minutes",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/hub/notify/standard/ThreadPoolNotifier.java#L91-L113 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java | RSS091UserlandParser.getItems | @Override
protected List<Element> getItems(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChildren("item", getRSSNamespace());
} else {
return Collections.emptyList();
}
} | java | @Override
protected List<Element> getItems(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChildren("item", getRSSNamespace());
} else {
return Collections.emptyList();
}
} | [
"@",
"Override",
"protected",
"List",
"<",
"Element",
">",
"getItems",
"(",
"final",
"Element",
"rssRoot",
")",
"{",
"final",
"Element",
"eChannel",
"=",
"rssRoot",
".",
"getChild",
"(",
"\"channel\"",
",",
"getRSSNamespace",
"(",
")",
")",
";",
"if",
"(",... | It looks for the 'item' elements under the 'channel' elemment. | [
"It",
"looks",
"for",
"the",
"item",
"elements",
"under",
"the",
"channel",
"elemment",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java#L202-L213 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java | RSS091UserlandParser.getImage | @Override
protected Element getImage(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChild("image", getRSSNamespace());
} else {
return null;
}
} | java | @Override
protected Element getImage(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChild("image", getRSSNamespace());
} else {
return null;
}
} | [
"@",
"Override",
"protected",
"Element",
"getImage",
"(",
"final",
"Element",
"rssRoot",
")",
"{",
"final",
"Element",
"eChannel",
"=",
"rssRoot",
".",
"getChild",
"(",
"\"channel\"",
",",
"getRSSNamespace",
"(",
")",
")",
";",
"if",
"(",
"eChannel",
"!=",
... | It looks for the 'image' elements under the 'channel' elemment. | [
"It",
"looks",
"for",
"the",
"image",
"elements",
"under",
"the",
"channel",
"elemment",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java#L218-L229 | train |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java | RSS091UserlandParser.getTextInput | @Override
protected Element getTextInput(final Element rssRoot) {
final String elementName = getTextInputLabel();
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChild(elementName, getRSSNamespace());
} else {
return null;
}
} | java | @Override
protected Element getTextInput(final Element rssRoot) {
final String elementName = getTextInputLabel();
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
if (eChannel != null) {
return eChannel.getChild(elementName, getRSSNamespace());
} else {
return null;
}
} | [
"@",
"Override",
"protected",
"Element",
"getTextInput",
"(",
"final",
"Element",
"rssRoot",
")",
"{",
"final",
"String",
"elementName",
"=",
"getTextInputLabel",
"(",
")",
";",
"final",
"Element",
"eChannel",
"=",
"rssRoot",
".",
"getChild",
"(",
"\"channel\"",... | It looks for the 'textinput' elements under the 'channel' elemment. | [
"It",
"looks",
"for",
"the",
"textinput",
"elements",
"under",
"the",
"channel",
"elemment",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/RSS091UserlandParser.java#L241-L253 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java | FeedInformationImpl.getCategories | @Override
public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories;
} | java | @Override
public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories;
} | [
"@",
"Override",
"public",
"List",
"<",
"Category",
">",
"getCategories",
"(",
")",
"{",
"return",
"categories",
"==",
"null",
"?",
"(",
"categories",
"=",
"new",
"ArrayList",
"<",
"Category",
">",
"(",
")",
")",
":",
"categories",
";",
"}"
] | The parent categories for this feed
@return The parent categories for this feed | [
"The",
"parent",
"categories",
"for",
"this",
"feed"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java#L54-L57 | train |
rometools/rome | rome-utils/src/main/java/com/rometools/utils/Longs.java | Longs.parseDecimal | public static Long parseDecimal(final String s) {
Long parsed = null;
try {
if (s != null) {
parsed = (long) Double.parseDouble(s);
}
} catch (final NumberFormatException e) {
}
return parsed;
} | java | public static Long parseDecimal(final String s) {
Long parsed = null;
try {
if (s != null) {
parsed = (long) Double.parseDouble(s);
}
} catch (final NumberFormatException e) {
}
return parsed;
} | [
"public",
"static",
"Long",
"parseDecimal",
"(",
"final",
"String",
"s",
")",
"{",
"Long",
"parsed",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"parsed",
"=",
"(",
"long",
")",
"Double",
".",
"parseDouble",
"(",
"s",
")",... | Converts a String into a Long by first parsing it as Double and then casting it to Long.
@param s The String to convert, may be null or in decimal format
@return The parsed Long or null when parsing is not possible | [
"Converts",
"a",
"String",
"into",
"a",
"Long",
"by",
"first",
"parsing",
"it",
"as",
"Double",
"and",
"then",
"casting",
"it",
"to",
"Long",
"."
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-utils/src/main/java/com/rometools/utils/Longs.java#L28-L37 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java | PositionList.add | public void add(final double latitude, final double longitude) {
ensureCapacity(size + 1);
this.longitude[size] = longitude;
this.latitude[size] = latitude;
++size;
} | java | public void add(final double latitude, final double longitude) {
ensureCapacity(size + 1);
this.longitude[size] = longitude;
this.latitude[size] = latitude;
++size;
} | [
"public",
"void",
"add",
"(",
"final",
"double",
"latitude",
",",
"final",
"double",
"longitude",
")",
"{",
"ensureCapacity",
"(",
"size",
"+",
"1",
")",
";",
"this",
".",
"longitude",
"[",
"size",
"]",
"=",
"longitude",
";",
"this",
".",
"latitude",
"... | Add a position at the end of the list | [
"Add",
"a",
"position",
"at",
"the",
"end",
"of",
"the",
"list"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java#L116-L121 | train |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java | PositionList.insert | public void insert(final int pos, final double latitude, final double longitude) {
ensureCapacity(size + 1);
System.arraycopy(this.longitude, pos, this.longitude, pos + 1, size - pos);
System.arraycopy(this.latitude, pos, this.latitude, pos + 1, size - pos);
this.longitude[pos] = longitude;
this.latitude[pos] = latitude;
++size;
} | java | public void insert(final int pos, final double latitude, final double longitude) {
ensureCapacity(size + 1);
System.arraycopy(this.longitude, pos, this.longitude, pos + 1, size - pos);
System.arraycopy(this.latitude, pos, this.latitude, pos + 1, size - pos);
this.longitude[pos] = longitude;
this.latitude[pos] = latitude;
++size;
} | [
"public",
"void",
"insert",
"(",
"final",
"int",
"pos",
",",
"final",
"double",
"latitude",
",",
"final",
"double",
"longitude",
")",
"{",
"ensureCapacity",
"(",
"size",
"+",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"longitude",
",",
... | Add a position at a given index in the list. The rest of the list is shifted one place to the
"right"
@param pos position index | [
"Add",
"a",
"position",
"at",
"a",
"given",
"index",
"in",
"the",
"list",
".",
"The",
"rest",
"of",
"the",
"list",
"is",
"shifted",
"one",
"place",
"to",
"the",
"right"
] | 5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010 | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/georss/geometries/PositionList.java#L129-L136 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.