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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
svenkubiak/embedded-mongodb | src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java | EmbeddedMongoDB.start | public EmbeddedMongoDB start() {
if (!this.active) {
try {
this.mongodProcess = MongodStarter.getDefaultInstance().prepare(new MongodConfigBuilder()
.version(this.version)
.net(new Net(this.host, this.port, false))
.build()).start();
this.active = true;
LOG.info("Successfully started EmbeddedMongoDB @ {}:{}", this.host, this.port);
} catch (final IOException e) {
LOG.error("Failed to start EmbeddedMongoDB @ {}:{}", this.host, this.port, e);
}
}
return this;
} | java | public EmbeddedMongoDB start() {
if (!this.active) {
try {
this.mongodProcess = MongodStarter.getDefaultInstance().prepare(new MongodConfigBuilder()
.version(this.version)
.net(new Net(this.host, this.port, false))
.build()).start();
this.active = true;
LOG.info("Successfully started EmbeddedMongoDB @ {}:{}", this.host, this.port);
} catch (final IOException e) {
LOG.error("Failed to start EmbeddedMongoDB @ {}:{}", this.host, this.port, e);
}
}
return this;
} | [
"public",
"EmbeddedMongoDB",
"start",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"try",
"{",
"this",
".",
"mongodProcess",
"=",
"MongodStarter",
".",
"getDefaultInstance",
"(",
")",
".",
"prepare",
"(",
"new",
"MongodConfigBuilder",
"(... | Starts the EmbeddedMongoDB instance
@return EmbeddedMongoDB instance | [
"Starts",
"the",
"EmbeddedMongoDB",
"instance"
] | c4394065bdce5917491a6537efdc808675047629 | https://github.com/svenkubiak/embedded-mongodb/blob/c4394065bdce5917491a6537efdc808675047629/src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java#L84-L100 | train |
svenkubiak/embedded-mongodb | src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java | EmbeddedMongoDB.stop | public void stop() {
if (this.active) {
this.mongodProcess.stop();
this.active = false;
LOG.info("Successfully stopped EmbeddedMongoDB @ {}:{}", this.host, this.port);
}
} | java | public void stop() {
if (this.active) {
this.mongodProcess.stop();
this.active = false;
LOG.info("Successfully stopped EmbeddedMongoDB @ {}:{}", this.host, this.port);
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"this",
".",
"active",
")",
"{",
"this",
".",
"mongodProcess",
".",
"stop",
"(",
")",
";",
"this",
".",
"active",
"=",
"false",
";",
"LOG",
".",
"info",
"(",
"\"Successfully stopped EmbeddedMongoDB @ {}... | Stops the EmbeddedMongoDB instance | [
"Stops",
"the",
"EmbeddedMongoDB",
"instance"
] | c4394065bdce5917491a6537efdc808675047629 | https://github.com/svenkubiak/embedded-mongodb/blob/c4394065bdce5917491a6537efdc808675047629/src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java#L105-L112 | train |
TNG/property-loader | src/main/java/com/tngtech/propertyloader/Obfuscator.java | Obfuscator.encrypt | public String encrypt(String toEncrypt) {
byte[] encryptedBytes = encryptInternal(dataEncryptionSecretKeySpec, toEncrypt);
return new String(base64Encoder.encode(encryptedBytes));
} | java | public String encrypt(String toEncrypt) {
byte[] encryptedBytes = encryptInternal(dataEncryptionSecretKeySpec, toEncrypt);
return new String(base64Encoder.encode(encryptedBytes));
} | [
"public",
"String",
"encrypt",
"(",
"String",
"toEncrypt",
")",
"{",
"byte",
"[",
"]",
"encryptedBytes",
"=",
"encryptInternal",
"(",
"dataEncryptionSecretKeySpec",
",",
"toEncrypt",
")",
";",
"return",
"new",
"String",
"(",
"base64Encoder",
".",
"encode",
"(",
... | Encrypt and base64-encode a String.
@param toEncrypt - the String to encrypt.
@return the Blowfish-encrypted and base64-encoded String. | [
"Encrypt",
"and",
"base64",
"-",
"encode",
"a",
"String",
"."
] | 0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f | https://github.com/TNG/property-loader/blob/0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f/src/main/java/com/tngtech/propertyloader/Obfuscator.java#L41-L44 | train |
TNG/property-loader | src/main/java/com/tngtech/propertyloader/Obfuscator.java | Obfuscator.encryptInternal | private byte[] encryptInternal(SecretKeySpec key, String toEncrypt) {
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(toEncrypt.getBytes(ENCODING));
} catch (GeneralSecurityException e) {
throw new RuntimeException("Exception during decryptInternal: " + e, e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Exception during encryptInternal: " + e, e);
}
} | java | private byte[] encryptInternal(SecretKeySpec key, String toEncrypt) {
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(toEncrypt.getBytes(ENCODING));
} catch (GeneralSecurityException e) {
throw new RuntimeException("Exception during decryptInternal: " + e, e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Exception during encryptInternal: " + e, e);
}
} | [
"private",
"byte",
"[",
"]",
"encryptInternal",
"(",
"SecretKeySpec",
"key",
",",
"String",
"toEncrypt",
")",
"{",
"try",
"{",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"ENCRYPTION_ALGORITHM",
"+",
"ENCRYPTION_ALGORITHM_MODIFIER",
")",
";",
"ci... | Internal Encryption method.
@param key - the SecretKeySpec used to encrypt
@param toEncrypt - the String to encrypt
@return the encrypted String (as byte[]) | [
"Internal",
"Encryption",
"method",
"."
] | 0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f | https://github.com/TNG/property-loader/blob/0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f/src/main/java/com/tngtech/propertyloader/Obfuscator.java#L53-L63 | train |
TNG/property-loader | src/main/java/com/tngtech/propertyloader/Obfuscator.java | Obfuscator.decrypt | public String decrypt(String toDecrypt) {
byte[] encryptedBytes = base64Decoder.decode(toDecrypt);
return decryptInternal(dataEncryptionSecretKeySpec, encryptedBytes);
} | java | public String decrypt(String toDecrypt) {
byte[] encryptedBytes = base64Decoder.decode(toDecrypt);
return decryptInternal(dataEncryptionSecretKeySpec, encryptedBytes);
} | [
"public",
"String",
"decrypt",
"(",
"String",
"toDecrypt",
")",
"{",
"byte",
"[",
"]",
"encryptedBytes",
"=",
"base64Decoder",
".",
"decode",
"(",
"toDecrypt",
")",
";",
"return",
"decryptInternal",
"(",
"dataEncryptionSecretKeySpec",
",",
"encryptedBytes",
")",
... | Decrypt an encrypted and base64-encoded String
@param toDecrypt - the encrypted and base64-encoded String
@return the plaintext String | [
"Decrypt",
"an",
"encrypted",
"and",
"base64",
"-",
"encoded",
"String"
] | 0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f | https://github.com/TNG/property-loader/blob/0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f/src/main/java/com/tngtech/propertyloader/Obfuscator.java#L71-L74 | train |
TNG/property-loader | src/main/java/com/tngtech/propertyloader/Obfuscator.java | Obfuscator.decryptInternal | private String decryptInternal(SecretKeySpec key, byte[] encryptedBytes) {
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
return new String(decryptedBytes, ENCODING);
} catch (GeneralSecurityException e) {
throw new RuntimeException("Exception during decryptInternal: " + e, e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Exception during encryptInternal: " + e, e);
}
} | java | private String decryptInternal(SecretKeySpec key, byte[] encryptedBytes) {
try {
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
return new String(decryptedBytes, ENCODING);
} catch (GeneralSecurityException e) {
throw new RuntimeException("Exception during decryptInternal: " + e, e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Exception during encryptInternal: " + e, e);
}
} | [
"private",
"String",
"decryptInternal",
"(",
"SecretKeySpec",
"key",
",",
"byte",
"[",
"]",
"encryptedBytes",
")",
"{",
"try",
"{",
"Cipher",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"ENCRYPTION_ALGORITHM",
"+",
"ENCRYPTION_ALGORITHM_MODIFIER",
")",
";",
... | Internal decryption method.
@param key - the SecretKeySpec used to decrypt
@param encryptedBytes - the byte[] to decrypt
@return the decrypted plaintext String. | [
"Internal",
"decryption",
"method",
"."
] | 0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f | https://github.com/TNG/property-loader/blob/0fbc8a091795aaf2bdaf7c0d494a32772bff0e1f/src/main/java/com/tngtech/propertyloader/Obfuscator.java#L83-L94 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-reindexing/src/main/java/org/fcrepo/camel/reindexing/RestProcessor.java | RestProcessor.process | public void process(final Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final String contentType = in.getHeader(CONTENT_TYPE, "", String.class);
final String body = in.getBody(String.class);
final Set<String> endpoints = new HashSet<>();
for (final String s : in.getHeader(REINDEXING_RECIPIENTS, "", String.class).split(",")) {
endpoints.add(s.trim());
}
if (contentType.equals("application/json") && body != null && !body.trim().isEmpty()) {
try {
final JsonNode root = MAPPER.readTree(body);
final Iterator<JsonNode> ite = root.elements();
while (ite.hasNext()) {
final JsonNode n = ite.next();
endpoints.add(n.asText());
}
} catch (JsonProcessingException e) {
LOGGER.debug("Invalid JSON", e);
in.setHeader(HTTP_RESPONSE_CODE, BAD_REQUEST);
in.setBody("Invalid JSON");
}
}
in.setHeader(REINDEXING_RECIPIENTS, join(",", endpoints));
} | java | public void process(final Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final String contentType = in.getHeader(CONTENT_TYPE, "", String.class);
final String body = in.getBody(String.class);
final Set<String> endpoints = new HashSet<>();
for (final String s : in.getHeader(REINDEXING_RECIPIENTS, "", String.class).split(",")) {
endpoints.add(s.trim());
}
if (contentType.equals("application/json") && body != null && !body.trim().isEmpty()) {
try {
final JsonNode root = MAPPER.readTree(body);
final Iterator<JsonNode> ite = root.elements();
while (ite.hasNext()) {
final JsonNode n = ite.next();
endpoints.add(n.asText());
}
} catch (JsonProcessingException e) {
LOGGER.debug("Invalid JSON", e);
in.setHeader(HTTP_RESPONSE_CODE, BAD_REQUEST);
in.setBody("Invalid JSON");
}
}
in.setHeader(REINDEXING_RECIPIENTS, join(",", endpoints));
} | [
"public",
"void",
"process",
"(",
"final",
"Exchange",
"exchange",
")",
"throws",
"Exception",
"{",
"final",
"Message",
"in",
"=",
"exchange",
".",
"getIn",
"(",
")",
";",
"final",
"String",
"contentType",
"=",
"in",
".",
"getHeader",
"(",
"CONTENT_TYPE",
... | Convert the incoming REST request into the correct
Fcrepo header fields.
@param exchange the current message exchange | [
"Convert",
"the",
"incoming",
"REST",
"request",
"into",
"the",
"correct",
"Fcrepo",
"header",
"fields",
"."
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-reindexing/src/main/java/org/fcrepo/camel/reindexing/RestProcessor.java#L62-L88 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java | AuditSparqlProcessor.process | public void process(final Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final String eventURIBase = in.getHeader(AuditHeaders.EVENT_BASE_URI, String.class);
final String eventID = in.getHeader(FCREPO_EVENT_ID, String.class);
final Resource eventURI = createResource(eventURIBase + "/" + eventID);
// generate SPARQL Update
final StringBuilder query = new StringBuilder("update=");
query.append(ProcessorUtils.insertData(serializedGraphForMessage(in, eventURI), ""));
// update exchange
in.setBody(query.toString());
in.setHeader(AuditHeaders.EVENT_URI, eventURI.toString());
in.setHeader(Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded");
in.setHeader(Exchange.HTTP_METHOD, "POST");
} | java | public void process(final Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final String eventURIBase = in.getHeader(AuditHeaders.EVENT_BASE_URI, String.class);
final String eventID = in.getHeader(FCREPO_EVENT_ID, String.class);
final Resource eventURI = createResource(eventURIBase + "/" + eventID);
// generate SPARQL Update
final StringBuilder query = new StringBuilder("update=");
query.append(ProcessorUtils.insertData(serializedGraphForMessage(in, eventURI), ""));
// update exchange
in.setBody(query.toString());
in.setHeader(AuditHeaders.EVENT_URI, eventURI.toString());
in.setHeader(Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded");
in.setHeader(Exchange.HTTP_METHOD, "POST");
} | [
"public",
"void",
"process",
"(",
"final",
"Exchange",
"exchange",
")",
"throws",
"Exception",
"{",
"final",
"Message",
"in",
"=",
"exchange",
".",
"getIn",
"(",
")",
";",
"final",
"String",
"eventURIBase",
"=",
"in",
".",
"getHeader",
"(",
"AuditHeaders",
... | Define how a message should be processed.
@param exchange the current camel message exchange | [
"Define",
"how",
"a",
"message",
"should",
"be",
"processed",
"."
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java#L86-L101 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java | AuditSparqlProcessor.serializedGraphForMessage | private static String serializedGraphForMessage(final Message message, final Resource subject) throws IOException {
// serialize triples
final ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
final Model model = createDefaultModel();
// get info from jms message headers
@SuppressWarnings("unchecked")
final List<String> eventType = message.getHeader(FCREPO_EVENT_TYPE, emptyList(), List.class);
final String dateTime = message.getHeader(FCREPO_DATE_TIME, EMPTY_STRING, String.class);
@SuppressWarnings("unchecked")
final List<String> agents = message.getHeader(FCREPO_AGENT, emptyList(), List.class);
@SuppressWarnings("unchecked")
final List<String> resourceTypes = message.getHeader(FCREPO_RESOURCE_TYPE, emptyList(), List.class);
final String identifier = message.getHeader(FCREPO_URI, EMPTY_STRING, String.class);
final Optional<String> premisType = getAuditEventType(eventType, resourceTypes);
model.add( model.createStatement(subject, type, INTERNAL_EVENT) );
model.add( model.createStatement(subject, type, PREMIS_EVENT) );
model.add( model.createStatement(subject, type, PROV_EVENT) );
// basic event info
model.add( model.createStatement(subject, PREMIS_TIME, createTypedLiteral(dateTime, XSDdateTime)) );
model.add( model.createStatement(subject, PREMIS_OBJ, createResource(identifier)) );
agents.forEach(agent -> {
model.add( model.createStatement(subject, PREMIS_AGENT, createTypedLiteral(agent, XSDstring)) );
});
premisType.ifPresent(rdfType -> {
model.add(model.createStatement(subject, PREMIS_TYPE, createResource(rdfType)));
});
write(serializedGraph, model, NTRIPLES);
return serializedGraph.toString("UTF-8");
} | java | private static String serializedGraphForMessage(final Message message, final Resource subject) throws IOException {
// serialize triples
final ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
final Model model = createDefaultModel();
// get info from jms message headers
@SuppressWarnings("unchecked")
final List<String> eventType = message.getHeader(FCREPO_EVENT_TYPE, emptyList(), List.class);
final String dateTime = message.getHeader(FCREPO_DATE_TIME, EMPTY_STRING, String.class);
@SuppressWarnings("unchecked")
final List<String> agents = message.getHeader(FCREPO_AGENT, emptyList(), List.class);
@SuppressWarnings("unchecked")
final List<String> resourceTypes = message.getHeader(FCREPO_RESOURCE_TYPE, emptyList(), List.class);
final String identifier = message.getHeader(FCREPO_URI, EMPTY_STRING, String.class);
final Optional<String> premisType = getAuditEventType(eventType, resourceTypes);
model.add( model.createStatement(subject, type, INTERNAL_EVENT) );
model.add( model.createStatement(subject, type, PREMIS_EVENT) );
model.add( model.createStatement(subject, type, PROV_EVENT) );
// basic event info
model.add( model.createStatement(subject, PREMIS_TIME, createTypedLiteral(dateTime, XSDdateTime)) );
model.add( model.createStatement(subject, PREMIS_OBJ, createResource(identifier)) );
agents.forEach(agent -> {
model.add( model.createStatement(subject, PREMIS_AGENT, createTypedLiteral(agent, XSDstring)) );
});
premisType.ifPresent(rdfType -> {
model.add(model.createStatement(subject, PREMIS_TYPE, createResource(rdfType)));
});
write(serializedGraph, model, NTRIPLES);
return serializedGraph.toString("UTF-8");
} | [
"private",
"static",
"String",
"serializedGraphForMessage",
"(",
"final",
"Message",
"message",
",",
"final",
"Resource",
"subject",
")",
"throws",
"IOException",
"{",
"// serialize triples",
"final",
"ByteArrayOutputStream",
"serializedGraph",
"=",
"new",
"ByteArrayOutpu... | Convert a Camel message to audit event description.
@param message Camel message produced by an audit event
@param subject RDF subject of the audit description | [
"Convert",
"a",
"Camel",
"message",
"to",
"audit",
"event",
"description",
"."
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java#L120-L155 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java | AuditSparqlProcessor.getAuditEventType | private static Optional<String> getAuditEventType(final List<String> eventType, final List<String> resourceType) {
// mapping event type/properties to audit event type
if (eventType.contains(EVENT_NAMESPACE + "ResourceCreation") || eventType.contains(AS_NAMESPACE + "Create")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_ADD);
} else {
return of(OBJECT_ADD);
}
} else if (eventType.contains(EVENT_NAMESPACE + "ResourceDeletion") ||
eventType.contains(AS_NAMESPACE + "Delete")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_REM);
} else {
return of(OBJECT_REM);
}
} else if (eventType.contains(EVENT_NAMESPACE + "ResourceModification") ||
eventType.contains(AS_NAMESPACE + "Update")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_MOD);
} else {
return of(METADATA_MOD);
}
}
return empty();
} | java | private static Optional<String> getAuditEventType(final List<String> eventType, final List<String> resourceType) {
// mapping event type/properties to audit event type
if (eventType.contains(EVENT_NAMESPACE + "ResourceCreation") || eventType.contains(AS_NAMESPACE + "Create")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_ADD);
} else {
return of(OBJECT_ADD);
}
} else if (eventType.contains(EVENT_NAMESPACE + "ResourceDeletion") ||
eventType.contains(AS_NAMESPACE + "Delete")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_REM);
} else {
return of(OBJECT_REM);
}
} else if (eventType.contains(EVENT_NAMESPACE + "ResourceModification") ||
eventType.contains(AS_NAMESPACE + "Update")) {
if (resourceType.contains(REPOSITORY + "Binary")) {
return of(CONTENT_MOD);
} else {
return of(METADATA_MOD);
}
}
return empty();
} | [
"private",
"static",
"Optional",
"<",
"String",
">",
"getAuditEventType",
"(",
"final",
"List",
"<",
"String",
">",
"eventType",
",",
"final",
"List",
"<",
"String",
">",
"resourceType",
")",
"{",
"// mapping event type/properties to audit event type",
"if",
"(",
... | Returns the Audit event type based on fedora event type and properties.
@param eventType from Fedora
@param properties associated with the Fedora event
@return Audit event | [
"Returns",
"the",
"Audit",
"event",
"type",
"based",
"on",
"fedora",
"event",
"type",
"and",
"properties",
"."
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-audit-triplestore/src/main/java/org/fcrepo/camel/audit/triplestore/AuditSparqlProcessor.java#L164-L188 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java | LDPathWrapper.programQuery | public List<Map<String, Collection<?>>> programQuery(final String uri, final InputStream program)
throws LDPathParseException {
return singletonList(ldpath.programQuery(new URIImpl(uri), new InputStreamReader(program)));
} | java | public List<Map<String, Collection<?>>> programQuery(final String uri, final InputStream program)
throws LDPathParseException {
return singletonList(ldpath.programQuery(new URIImpl(uri), new InputStreamReader(program)));
} | [
"public",
"List",
"<",
"Map",
"<",
"String",
",",
"Collection",
"<",
"?",
">",
">",
">",
"programQuery",
"(",
"final",
"String",
"uri",
",",
"final",
"InputStream",
"program",
")",
"throws",
"LDPathParseException",
"{",
"return",
"singletonList",
"(",
"ldpat... | Execute an LDPath query
@param uri the URI to query
@param program the LDPath program
@return a result object wrapped in a List
@throws LDPathParseException if the LDPath program was malformed | [
"Execute",
"an",
"LDPath",
"query"
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java#L102-L105 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java | ClientFactory.createClient | public static ClientConfiguration createClient(final AuthScope authScope, final Credentials credentials,
final List<Endpoint> endpoints, final List<DataProvider> providers) {
final ClientConfiguration client = new ClientConfiguration();
if (credentials != null && authScope != null) {
final CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(authScope, credentials);
client.setHttpClient(HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.useSystemProperties().build());
}
// manually add default Providers and Endpoints
client.addProvider(new LinkedDataProvider());
client.addProvider(new CacheProvider());
client.addProvider(new RegexUriProvider());
client.addProvider(new SPARQLProvider());
client.addEndpoint(new LinkedDataEndpoint());
// add any injected endpoints/providers
endpoints.forEach(client::addEndpoint);
providers.forEach(client::addProvider);
return client;
} | java | public static ClientConfiguration createClient(final AuthScope authScope, final Credentials credentials,
final List<Endpoint> endpoints, final List<DataProvider> providers) {
final ClientConfiguration client = new ClientConfiguration();
if (credentials != null && authScope != null) {
final CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(authScope, credentials);
client.setHttpClient(HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.useSystemProperties().build());
}
// manually add default Providers and Endpoints
client.addProvider(new LinkedDataProvider());
client.addProvider(new CacheProvider());
client.addProvider(new RegexUriProvider());
client.addProvider(new SPARQLProvider());
client.addEndpoint(new LinkedDataEndpoint());
// add any injected endpoints/providers
endpoints.forEach(client::addEndpoint);
providers.forEach(client::addProvider);
return client;
} | [
"public",
"static",
"ClientConfiguration",
"createClient",
"(",
"final",
"AuthScope",
"authScope",
",",
"final",
"Credentials",
"credentials",
",",
"final",
"List",
"<",
"Endpoint",
">",
"endpoints",
",",
"final",
"List",
"<",
"DataProvider",
">",
"providers",
")"... | Create a linked data client suitable for use with a Fedora Repository.
@param authScope the authentication scope
@param credentials the credentials
@param endpoints additional endpoints to enable on the client
@param providers additional providers to enable on the client
@return a configuration for use with an LDClient | [
"Create",
"a",
"linked",
"data",
"client",
"suitable",
"for",
"use",
"with",
"a",
"Fedora",
"Repository",
"."
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java#L104-L129 | train |
fcrepo4-exts/fcrepo-camel-toolbox | fcrepo-serialization/src/main/java/org/fcrepo/camel/serialization/SerializationRouter.java | SerializationRouter.configure | public void configure() throws Exception {
final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
.add("fedora", REPOSITORY);
/**
* A generic error handler (specific to this RouteBuilder)
*/
onException(Exception.class)
.maximumRedeliveries("{{error.maxRedeliveries}}")
.log("Index Routing Error: ${routeId}");
/**
* Handle Serialization Events
*/
from("{{input.stream}}")
.routeId("FcrepoSerialization")
.process(new EventProcessor())
.process(exchange -> {
final String uri = exchange.getIn().getHeader(FCREPO_URI, "", String.class);
exchange.getIn().setHeader(SERIALIZATION_PATH, create(uri).getPath());
})
.filter(not(in(uriFilter)))
.choice()
.when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION),
header(FCREPO_EVENT_TYPE).contains(DELETE)))
.to("direct:delete")
.otherwise()
.multicast().to("direct:metadata", "direct:binary");
from("{{serialization.stream}}")
.routeId("FcrepoReSerialization")
.filter(not(in(uriFilter)))
.process(exchange -> {
final String uri = exchange.getIn().getHeader(FCREPO_URI, "", String.class);
exchange.getIn().setHeader(SERIALIZATION_PATH, create(uri).getPath());
})
.multicast().to("direct:metadata", "direct:binary");
from("direct:metadata")
.routeId("FcrepoSerializationMetadataUpdater")
.to("fcrepo:localhost?accept={{serialization.mimeType}}")
.log(INFO, LOGGER, "Serializing object ${headers[CamelFcrepoUri]}")
.setHeader(FILE_NAME).simple("${headers[CamelSerializationPath]}.{{serialization.extension}}")
.log(DEBUG, LOGGER, "filename is ${headers[CamelFileName]}")
.to("file://{{serialization.descriptions}}");
from("direct:binary")
.routeId("FcrepoSerializationBinaryUpdater")
.filter().simple("{{serialization.includeBinaries}} == 'true'")
.to("fcrepo:localhost?preferInclude=PreferMinimalContainer" +
"&accept=application/rdf+xml")
.filter().xpath(isBinaryResourceXPath, ns)
.log(INFO, LOGGER, "Writing binary ${headers[CamelSerializationPath]}")
.to("fcrepo:localhost?metadata=false")
.setHeader(FILE_NAME).header(SERIALIZATION_PATH)
.log(DEBUG, LOGGER, "header filename is: ${headers[CamelFileName]}")
.to("file://{{serialization.binaries}}");
from("direct:delete")
.routeId("FcrepoSerializationDeleter")
.setHeader(EXEC_COMMAND_ARGS).simple(
"-rf {{serialization.descriptions}}${headers[CamelSerializationPath]}.{{serialization.extension}} " +
"{{serialization.descriptions}}${headers[CamelSerializationPath]} " +
"{{serialization.binaries}}${headers[CamelSerializationPath]}")
.to("exec:rm");
} | java | public void configure() throws Exception {
final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
.add("fedora", REPOSITORY);
/**
* A generic error handler (specific to this RouteBuilder)
*/
onException(Exception.class)
.maximumRedeliveries("{{error.maxRedeliveries}}")
.log("Index Routing Error: ${routeId}");
/**
* Handle Serialization Events
*/
from("{{input.stream}}")
.routeId("FcrepoSerialization")
.process(new EventProcessor())
.process(exchange -> {
final String uri = exchange.getIn().getHeader(FCREPO_URI, "", String.class);
exchange.getIn().setHeader(SERIALIZATION_PATH, create(uri).getPath());
})
.filter(not(in(uriFilter)))
.choice()
.when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION),
header(FCREPO_EVENT_TYPE).contains(DELETE)))
.to("direct:delete")
.otherwise()
.multicast().to("direct:metadata", "direct:binary");
from("{{serialization.stream}}")
.routeId("FcrepoReSerialization")
.filter(not(in(uriFilter)))
.process(exchange -> {
final String uri = exchange.getIn().getHeader(FCREPO_URI, "", String.class);
exchange.getIn().setHeader(SERIALIZATION_PATH, create(uri).getPath());
})
.multicast().to("direct:metadata", "direct:binary");
from("direct:metadata")
.routeId("FcrepoSerializationMetadataUpdater")
.to("fcrepo:localhost?accept={{serialization.mimeType}}")
.log(INFO, LOGGER, "Serializing object ${headers[CamelFcrepoUri]}")
.setHeader(FILE_NAME).simple("${headers[CamelSerializationPath]}.{{serialization.extension}}")
.log(DEBUG, LOGGER, "filename is ${headers[CamelFileName]}")
.to("file://{{serialization.descriptions}}");
from("direct:binary")
.routeId("FcrepoSerializationBinaryUpdater")
.filter().simple("{{serialization.includeBinaries}} == 'true'")
.to("fcrepo:localhost?preferInclude=PreferMinimalContainer" +
"&accept=application/rdf+xml")
.filter().xpath(isBinaryResourceXPath, ns)
.log(INFO, LOGGER, "Writing binary ${headers[CamelSerializationPath]}")
.to("fcrepo:localhost?metadata=false")
.setHeader(FILE_NAME).header(SERIALIZATION_PATH)
.log(DEBUG, LOGGER, "header filename is: ${headers[CamelFileName]}")
.to("file://{{serialization.binaries}}");
from("direct:delete")
.routeId("FcrepoSerializationDeleter")
.setHeader(EXEC_COMMAND_ARGS).simple(
"-rf {{serialization.descriptions}}${headers[CamelSerializationPath]}.{{serialization.extension}} " +
"{{serialization.descriptions}}${headers[CamelSerializationPath]} " +
"{{serialization.binaries}}${headers[CamelSerializationPath]}")
.to("exec:rm");
} | [
"public",
"void",
"configure",
"(",
")",
"throws",
"Exception",
"{",
"final",
"Namespaces",
"ns",
"=",
"new",
"Namespaces",
"(",
"\"rdf\"",
",",
"\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
")",
".",
"add",
"(",
"\"fedora\"",
",",
"REPOSITORY",
")",
";",
"... | Configure the message route workflow | [
"Configure",
"the",
"message",
"route",
"workflow"
] | 9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f | https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/blob/9e0cf220937b2d5c050e0e071f0cdc4c7a084c0f/fcrepo-serialization/src/main/java/org/fcrepo/camel/serialization/SerializationRouter.java#L74-L140 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java | JsonPropertyMeta.name | public JsonPropertyBuilder<T, P> name(String name) {
return new JsonPropertyBuilder<T, P>(coderClass, name, null, null);
} | java | public JsonPropertyBuilder<T, P> name(String name) {
return new JsonPropertyBuilder<T, P>(coderClass, name, null, null);
} | [
"public",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"name",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"(",
"coderClass",
",",
"name",
",",
"null",
",",
"null",
")",
";",
"}"
] | Gets a new instance of property builder for the given key name.
@param name
@return a new property builder instance
@author vvakame | [
"Gets",
"a",
"new",
"instance",
"of",
"property",
"builder",
"for",
"the",
"given",
"key",
"name",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java#L43-L45 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java | JsonPropertyMeta.coder | public JsonPropertyBuilder<T, P> coder(JsonModelCoder<P> coder) {
return new JsonPropertyBuilder<T, P>(coderClass, name, coder, null);
} | java | public JsonPropertyBuilder<T, P> coder(JsonModelCoder<P> coder) {
return new JsonPropertyBuilder<T, P>(coderClass, name, coder, null);
} | [
"public",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"coder",
"(",
"JsonModelCoder",
"<",
"P",
">",
"coder",
")",
"{",
"return",
"new",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"(",
"coderClass",
",",
"name",
",",
"coder",
",",
"null",
")",... | Gets a new instance of property builder for the given value coder.
@param coder
@return a new property builder instance
@author vvakame | [
"Gets",
"a",
"new",
"instance",
"of",
"property",
"builder",
"for",
"the",
"given",
"value",
"coder",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java#L53-L55 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java | JsonPropertyMeta.router | public JsonPropertyBuilder<T, P> router(JsonCoderRouter<P> router) {
return new JsonPropertyBuilder<T, P>(coderClass, name, null, router);
} | java | public JsonPropertyBuilder<T, P> router(JsonCoderRouter<P> router) {
return new JsonPropertyBuilder<T, P>(coderClass, name, null, router);
} | [
"public",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"router",
"(",
"JsonCoderRouter",
"<",
"P",
">",
"router",
")",
"{",
"return",
"new",
"JsonPropertyBuilder",
"<",
"T",
",",
"P",
">",
"(",
"coderClass",
",",
"name",
",",
"null",
",",
"router",
... | Gets a new instance of property builder for the given coder router.
@param router
@return a new property builder instance
@author vvakame | [
"Gets",
"a",
"new",
"instance",
"of",
"property",
"builder",
"for",
"the",
"given",
"coder",
"router",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonPropertyMeta.java#L63-L65 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonHash.java | JsonHash.put | @Deprecated
public Object put(String key, Object value, State state) {
return put(key, value, Type.from(state));
} | java | @Deprecated
public Object put(String key, Object value, State state) {
return put(key, value, Type.from(state));
} | [
"@",
"Deprecated",
"public",
"Object",
"put",
"(",
"String",
"key",
",",
"Object",
"value",
",",
"State",
"state",
")",
"{",
"return",
"put",
"(",
"key",
",",
"value",
",",
"Type",
".",
"from",
"(",
"state",
")",
")",
";",
"}"
] | put with State.
@param key
@param value
@param state
@return The instance of the value for the given key
@deprecated {@link State} is confuse the users. replace to {@link Type} in about {@link JsonHash}. since 1.4.12. | [
"put",
"with",
"State",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonHash.java#L375-L378 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/JsonModelGenerator.java | JsonModelGenerator.write | public void write() throws IOException {
{
Filer filer = processingEnv.getFiler();
String generateClassName =
jsonModel.getPackageName() + "." + jsonModel.getTarget() + postfix;
JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
Template.writeGen(fileObject, jsonModel);
}
if (jsonModel.isBuilder()) {
Filer filer = processingEnv.getFiler();
String generateClassName =
jsonModel.getPackageName() + "." + jsonModel.getTarget() + "JsonMeta";
JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
Template.writeJsonMeta(fileObject, jsonModel);
}
} | java | public void write() throws IOException {
{
Filer filer = processingEnv.getFiler();
String generateClassName =
jsonModel.getPackageName() + "." + jsonModel.getTarget() + postfix;
JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
Template.writeGen(fileObject, jsonModel);
}
if (jsonModel.isBuilder()) {
Filer filer = processingEnv.getFiler();
String generateClassName =
jsonModel.getPackageName() + "." + jsonModel.getTarget() + "JsonMeta";
JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
Template.writeJsonMeta(fileObject, jsonModel);
}
} | [
"public",
"void",
"write",
"(",
")",
"throws",
"IOException",
"{",
"{",
"Filer",
"filer",
"=",
"processingEnv",
".",
"getFiler",
"(",
")",
";",
"String",
"generateClassName",
"=",
"jsonModel",
".",
"getPackageName",
"(",
")",
"+",
"\".\"",
"+",
"jsonModel",
... | Generates the source code.
@throws IOException
@author vvakame | [
"Generates",
"the",
"source",
"code",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/JsonModelGenerator.java#L124-L139 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/JsonModelGenerator.java | JsonModelGenerator.getElementKeyString | String getElementKeyString(Element element) {
JsonKey key = element.getAnnotation(JsonKey.class);
JsonModel model = element.getEnclosingElement().getAnnotation(JsonModel.class);
if (!"".equals(key.value())) {
return key.value();
} else if ("".equals(key.value()) && key.decamelize()) {
return decamelize(element.toString());
} else if ("".equals(key.value()) && model.decamelize()) {
return decamelize(element.toString());
} else {
return element.toString();
}
} | java | String getElementKeyString(Element element) {
JsonKey key = element.getAnnotation(JsonKey.class);
JsonModel model = element.getEnclosingElement().getAnnotation(JsonModel.class);
if (!"".equals(key.value())) {
return key.value();
} else if ("".equals(key.value()) && key.decamelize()) {
return decamelize(element.toString());
} else if ("".equals(key.value()) && model.decamelize()) {
return decamelize(element.toString());
} else {
return element.toString();
}
} | [
"String",
"getElementKeyString",
"(",
"Element",
"element",
")",
"{",
"JsonKey",
"key",
"=",
"element",
".",
"getAnnotation",
"(",
"JsonKey",
".",
"class",
")",
";",
"JsonModel",
"model",
"=",
"element",
".",
"getEnclosingElement",
"(",
")",
".",
"getAnnotatio... | Get JSON key string.
@param element
@return JSON key string
@author vvakame | [
"Get",
"JSON",
"key",
"string",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/JsonModelGenerator.java#L222-L234 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/Stack.java | Stack.pop | public T pop() {
final int max = stack.size() - 1;
if (max < 0) {
throw new NoSuchElementException();
}
return stack.remove(max);
} | java | public T pop() {
final int max = stack.size() - 1;
if (max < 0) {
throw new NoSuchElementException();
}
return stack.remove(max);
} | [
"public",
"T",
"pop",
"(",
")",
"{",
"final",
"int",
"max",
"=",
"stack",
".",
"size",
"(",
")",
"-",
"1",
";",
"if",
"(",
"max",
"<",
"0",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"return",
"stack",
".",
"remove",
... | Pops the value from the top of stack and returns it.
@return The value has been popped.
@author vvakame | [
"Pops",
"the",
"value",
"from",
"the",
"top",
"of",
"stack",
"and",
"returns",
"it",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/Stack.java#L51-L57 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/Stack.java | Stack.peek | public T peek() {
final int top = stack.size() - 1;
if (top < 0) {
throw new NoSuchElementException();
}
return stack.get(top);
} | java | public T peek() {
final int top = stack.size() - 1;
if (top < 0) {
throw new NoSuchElementException();
}
return stack.get(top);
} | [
"public",
"T",
"peek",
"(",
")",
"{",
"final",
"int",
"top",
"=",
"stack",
".",
"size",
"(",
")",
"-",
"1",
";",
"if",
"(",
"top",
"<",
"0",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"return",
"stack",
".",
"get",
... | Returns the value currently on the top of the stack.
@return The value on the top.
@author vvakame | [
"Returns",
"the",
"value",
"currently",
"on",
"the",
"top",
"of",
"the",
"stack",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/Stack.java#L64-L70 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserInteger | public static Integer parserInteger(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (int) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | java | public static Integer parserInteger(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (int) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Integer",
"parserInteger",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
... | Parses the current token as an integer.
@param parser
@return {@link Integer}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"an",
"integer",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L43-L55 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserLong | public static Long parserLong(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | java | public static Long parserLong(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Long",
"parserLong",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
"VALU... | Parses the current token as a long.
@param parser
@return {@link Long}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"long",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L65-L76 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserByte | public static Byte parserByte(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (byte) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | java | public static Byte parserByte(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (byte) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Byte",
"parserByte",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
"VALU... | Parses the current token as a byte.
@param parser
@return {@link Byte}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"byte",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L86-L97 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserShort | public static Short parserShort(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (short) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | java | public static Short parserShort(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_LONG) {
return (short) parser.getValueLong();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Short",
"parserShort",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
"VA... | Parses the current token as a short.
@param parser
@return {@link Short}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"short",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L107-L118 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserBoolean | public static Boolean parserBoolean(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_BOOLEAN) {
return parser.getValueBoolean();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_BOOLEAN, but get="
+ eventType.toString());
}
} | java | public static Boolean parserBoolean(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_BOOLEAN) {
return parser.getValueBoolean();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_BOOLEAN, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Boolean",
"parserBoolean",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
... | Parses the current token as a boolean.
@param parser
@return {@link Boolean}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"boolean",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L128-L140 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserCharacter | public static Character parserCharacter(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_STRING) {
String str = parser.getValueString();
if (str.length() != 1) {
throw new IllegalStateException(
"unexpected value. expecte string size is 1. but get=" + str);
}
return str.charAt(0);
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
} | java | public static Character parserCharacter(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_STRING) {
String str = parser.getValueString();
if (str.length() != 1) {
throw new IllegalStateException(
"unexpected value. expecte string size is 1. but get=" + str);
}
return str.charAt(0);
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Character",
"parserCharacter",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".... | Parses the current token as a character.
@param parser
@return {@link Character}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"character",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L150-L167 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserDouble | public static Double parserDouble(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_DOUBLE) {
return parser.getValueDouble();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
} | java | public static Double parserDouble(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_DOUBLE) {
return parser.getValueDouble();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Double",
"parserDouble",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
"... | Parses the current token as a double-precision floating point value.
@param parser
@return {@link Double}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"double",
"-",
"precision",
"floating",
"point",
"value",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L177-L189 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserFloat | public static Float parserFloat(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_DOUBLE) {
return (float) parser.getValueDouble();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
} | java | public static Float parserFloat(JsonPullParser parser) throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
} else if (eventType == State.VALUE_DOUBLE) {
return (float) parser.getValueDouble();
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
} | [
"public",
"static",
"Float",
"parserFloat",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
"==",
"State",
".",
"VA... | Parses the current token as a single-precision floating point value.
@param parser
@return {@link Float}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"single",
"-",
"precision",
"floating",
"point",
"value",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L199-L210 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserIntegerList | public static List<Integer> parserIntegerList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Integer> list = new ArrayList<Integer>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_LONG) {
list.add((int) parser.getValueLong());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static List<Integer> parserIntegerList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Integer> list = new ArrayList<Integer>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_LONG) {
list.add((int) parser.getValueLong());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_LONG, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"List",
"<",
"Integer",
">",
"parserIntegerList",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",... | Parses the current token as a list of integers.
@param parser
@return List of {@link Integer}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"integers",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L220-L244 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserBooleanList | public static List<Boolean> parserBooleanList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Boolean> list = new ArrayList<Boolean>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_BOOLEAN) {
list.add(parser.getValueBoolean());
} else {
throw new IllegalStateException(
"unexpected state. expected=VALUE_BOOLEAN, but get=" + eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static List<Boolean> parserBooleanList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Boolean> list = new ArrayList<Boolean>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_BOOLEAN) {
list.add(parser.getValueBoolean());
} else {
throw new IllegalStateException(
"unexpected state. expected=VALUE_BOOLEAN, but get=" + eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"List",
"<",
"Boolean",
">",
"parserBooleanList",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",... | Parses the current token as a list of booleans.
@param parser
@return List of {@link Boolean}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"booleans",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L356-L380 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserCharacterList | public static List<Character> parserCharacterList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Character> list = new ArrayList<Character>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
String str = parser.getValueString();
if (str.length() != 1) {
throw new IllegalStateException(
"unexpected value. expecte string size is 1. but get=" + str);
}
list.add(str.charAt(0));
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static List<Character> parserCharacterList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Character> list = new ArrayList<Character>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
String str = parser.getValueString();
if (str.length() != 1) {
throw new IllegalStateException(
"unexpected value. expecte string size is 1. but get=" + str);
}
list.add(str.charAt(0));
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"List",
"<",
"Character",
">",
"parserCharacterList",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventTy... | Parses the current token as a list of characters.
@param parser
@return List of {@link Character}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"characters",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L390-L419 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserDoubleList | public static List<Double> parserDoubleList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Double> list = new ArrayList<Double>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_DOUBLE) {
list.add(parser.getValueDouble());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static List<Double> parserDoubleList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<Double> list = new ArrayList<Double>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_DOUBLE) {
list.add(parser.getValueDouble());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_DOUBLE, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"List",
"<",
"Double",
">",
"parserDoubleList",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
... | Parses the current token as a list of double-precision floating point numbers.
@param parser
@return List of {@link Double}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"double",
"-",
"precision",
"floating",
"point",
"numbers",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L429-L453 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserStringList | public static List<String> parserStringList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<String> list = new ArrayList<String>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
list.add(parser.getValueString());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static List<String> parserStringList(JsonPullParser parser) throws IOException,
JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<String> list = new ArrayList<String>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
list.add(parser.getValueString());
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"parserStringList",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"eventType",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"eventType",
... | Parses the current token as a list of strings.
@param parser
@return List of {@link String}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"strings",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L497-L521 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java | JsonParseUtil.parserEnumList | public static <T extends Enum<T>>List<T> parserEnumList(JsonPullParser parser, Class<T> clazz)
throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<T> list = new ArrayList<T>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
T obj = Enum.valueOf(clazz, parser.getValueString());
list.add(obj);
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | java | public static <T extends Enum<T>>List<T> parserEnumList(JsonPullParser parser, Class<T> clazz)
throws IOException, JsonFormatException {
State eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
return null;
}
if (eventType != State.START_ARRAY) {
throw new IllegalStateException("not started brace!");
}
List<T> list = new ArrayList<T>();
while (parser.lookAhead() != State.END_ARRAY) {
eventType = parser.getEventType();
if (eventType == State.VALUE_NULL) {
list.add(null);
} else if (eventType == State.VALUE_STRING) {
T obj = Enum.valueOf(clazz, parser.getValueString());
list.add(obj);
} else {
throw new IllegalStateException("unexpected state. expected=VALUE_STRING, but get="
+ eventType.toString());
}
}
parser.getEventType();
return list;
} | [
"public",
"static",
"<",
"T",
"extends",
"Enum",
"<",
"T",
">",
">",
"List",
"<",
"T",
">",
"parserEnumList",
"(",
"JsonPullParser",
"parser",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"... | Parses the current token as a list of Enums.
@param <T>
@param parser
@param clazz
@return List of {@link Enum}s
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"current",
"token",
"as",
"a",
"list",
"of",
"Enums",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonParseUtil.java#L568-L593 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonModelBuilder.java | JsonModelBuilder.rm | public JsonModelBuilder<T> rm(String... names) {
for (String name : names) {
rmSub(name);
}
return this;
} | java | public JsonModelBuilder<T> rm(String... names) {
for (String name : names) {
rmSub(name);
}
return this;
} | [
"public",
"JsonModelBuilder",
"<",
"T",
">",
"rm",
"(",
"String",
"...",
"names",
")",
"{",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"rmSub",
"(",
"name",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Detaches property builder for the given names.
@param names
@return this
@author vvakame | [
"Detaches",
"property",
"builder",
"for",
"the",
"given",
"names",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/builder/JsonModelBuilder.java#L529-L534 | train |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonArray.java | JsonArray.fromParser | public static JsonArray fromParser(JsonPullParser parser) throws IOException,
JsonFormatException {
State state = parser.getEventType();
if (state == State.VALUE_NULL) {
return null;
} else if (state != State.START_ARRAY) {
throw new JsonFormatException("unexpected token. token=" + state, parser);
}
JsonArray jsonArray = new JsonArray();
while ((state = parser.lookAhead()) != State.END_ARRAY) {
jsonArray.add(getValue(parser), state);
}
parser.getEventType();
return jsonArray;
} | java | public static JsonArray fromParser(JsonPullParser parser) throws IOException,
JsonFormatException {
State state = parser.getEventType();
if (state == State.VALUE_NULL) {
return null;
} else if (state != State.START_ARRAY) {
throw new JsonFormatException("unexpected token. token=" + state, parser);
}
JsonArray jsonArray = new JsonArray();
while ((state = parser.lookAhead()) != State.END_ARRAY) {
jsonArray.add(getValue(parser), state);
}
parser.getEventType();
return jsonArray;
} | [
"public",
"static",
"JsonArray",
"fromParser",
"(",
"JsonPullParser",
"parser",
")",
"throws",
"IOException",
",",
"JsonFormatException",
"{",
"State",
"state",
"=",
"parser",
".",
"getEventType",
"(",
")",
";",
"if",
"(",
"state",
"==",
"State",
".",
"VALUE_N... | Parses the given JSON data as an array.
@param parser {@link JsonPullParser} with some JSON-formatted data
@return {@link JsonArray}
@throws IOException
@throws JsonFormatException
@author vvakame | [
"Parses",
"the",
"given",
"JSON",
"data",
"as",
"an",
"array",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonArray.java#L63-L80 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/Log.java | Log.e | public static void e(String msg, Element element) {
messager.printMessage(Diagnostic.Kind.ERROR, msg, element);
} | java | public static void e(String msg, Element element) {
messager.printMessage(Diagnostic.Kind.ERROR, msg, element);
} | [
"public",
"static",
"void",
"e",
"(",
"String",
"msg",
",",
"Element",
"element",
")",
"{",
"messager",
".",
"printMessage",
"(",
"Diagnostic",
".",
"Kind",
".",
"ERROR",
",",
"msg",
",",
"element",
")",
";",
"}"
] | Logs error message about the given element.
@param msg Message
@param element Offending element
@author vvakame | [
"Logs",
"error",
"message",
"about",
"the",
"given",
"element",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/Log.java#L114-L116 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/Log.java | Log.e | public static void e(Throwable e) {
messager.printMessage(Diagnostic.Kind.ERROR, "exception thrown! " + e.getMessage());
} | java | public static void e(Throwable e) {
messager.printMessage(Diagnostic.Kind.ERROR, "exception thrown! " + e.getMessage());
} | [
"public",
"static",
"void",
"e",
"(",
"Throwable",
"e",
")",
"{",
"messager",
".",
"printMessage",
"(",
"Diagnostic",
".",
"Kind",
".",
"ERROR",
",",
"\"exception thrown! \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}"
] | Logs error message about the given exception.
@param e Offending throwable
@author vvakame | [
"Logs",
"error",
"message",
"about",
"the",
"given",
"exception",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/util/jsonpullparser/factory/Log.java#L123-L125 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.isPrimitiveWrapper | public static boolean isPrimitiveWrapper(Element element) {
if (element == null) {
return false;
} else if (element.toString().equals(Boolean.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Integer.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Long.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Byte.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Short.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Character.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Double.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Float.class.getCanonicalName())) {
return true;
} else {
return false;
}
} | java | public static boolean isPrimitiveWrapper(Element element) {
if (element == null) {
return false;
} else if (element.toString().equals(Boolean.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Integer.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Long.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Byte.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Short.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Character.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Double.class.getCanonicalName())) {
return true;
} else if (element.toString().equals(Float.class.getCanonicalName())) {
return true;
} else {
return false;
}
} | [
"public",
"static",
"boolean",
"isPrimitiveWrapper",
"(",
"Element",
"element",
")",
"{",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"element",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"Boolean",
... | Tests if the given element is a primitive wrapper.
@param element
@return true if the element is a primitive wrapper, false otherwise.
@author vvakame | [
"Tests",
"if",
"the",
"given",
"element",
"is",
"a",
"primitive",
"wrapper",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L94-L116 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.isInternalType | public static boolean isInternalType(Types typeUtils, TypeMirror type) {
Element element = ((TypeElement) typeUtils.asElement(type)).getEnclosingElement();
return element.getKind() != ElementKind.PACKAGE;
} | java | public static boolean isInternalType(Types typeUtils, TypeMirror type) {
Element element = ((TypeElement) typeUtils.asElement(type)).getEnclosingElement();
return element.getKind() != ElementKind.PACKAGE;
} | [
"public",
"static",
"boolean",
"isInternalType",
"(",
"Types",
"typeUtils",
",",
"TypeMirror",
"type",
")",
"{",
"Element",
"element",
"=",
"(",
"(",
"TypeElement",
")",
"typeUtils",
".",
"asElement",
"(",
"type",
")",
")",
".",
"getEnclosingElement",
"(",
"... | Test if the given type is an internal type.
@param typeUtils
@param type
@return True if the type is an internal type, false otherwise.
@author vvakame | [
"Test",
"if",
"the",
"given",
"type",
"is",
"an",
"internal",
"type",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L135-L138 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.isPackagePrivate | public static boolean isPackagePrivate(Element element) {
if (isPublic(element)) {
return false;
} else if (isProtected(element)) {
return false;
} else if (isPrivate(element)) {
return false;
}
return true;
} | java | public static boolean isPackagePrivate(Element element) {
if (isPublic(element)) {
return false;
} else if (isProtected(element)) {
return false;
} else if (isPrivate(element)) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"isPackagePrivate",
"(",
"Element",
"element",
")",
"{",
"if",
"(",
"isPublic",
"(",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"isProtected",
"(",
"element",
")",
")",
"{",
"return",
"false",... | Tests if the given element has the package-private visibility.
@param element
@return true if package-private, false otherwise
@author vvakame | [
"Tests",
"if",
"the",
"given",
"element",
"has",
"the",
"package",
"-",
"private",
"visibility",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L360-L369 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.getElementSetter | public static String getElementSetter(Element element) {
// 後続処理注意 hogeに対して sethoge が取得される. setHoge ではない.
String setterName = null;
if (isPrimitiveBoolean(element)) {
Pattern pattern = Pattern.compile("^is[^a-z].*$");
Matcher matcher = pattern.matcher(element.getSimpleName().toString());
if (matcher.matches()) {
// boolean isHoge; に対して setIsHoge ではなく setHoge が生成される
setterName = "set" + element.getSimpleName().toString().substring(2);
}
}
if (setterName == null) {
setterName = "set" + element.getSimpleName().toString();
}
Element setter = null;
for (Element method : ElementFilter.methodsIn(element.getEnclosingElement()
.getEnclosedElements())) {
String methodName = method.getSimpleName().toString();
if (setterName.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
setter = method;
break;
}
}
}
if (setter != null) {
return setter.getSimpleName().toString();
} else {
return null;
}
} | java | public static String getElementSetter(Element element) {
// 後続処理注意 hogeに対して sethoge が取得される. setHoge ではない.
String setterName = null;
if (isPrimitiveBoolean(element)) {
Pattern pattern = Pattern.compile("^is[^a-z].*$");
Matcher matcher = pattern.matcher(element.getSimpleName().toString());
if (matcher.matches()) {
// boolean isHoge; に対して setIsHoge ではなく setHoge が生成される
setterName = "set" + element.getSimpleName().toString().substring(2);
}
}
if (setterName == null) {
setterName = "set" + element.getSimpleName().toString();
}
Element setter = null;
for (Element method : ElementFilter.methodsIn(element.getEnclosingElement()
.getEnclosedElements())) {
String methodName = method.getSimpleName().toString();
if (setterName.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
setter = method;
break;
}
}
}
if (setter != null) {
return setter.getSimpleName().toString();
} else {
return null;
}
} | [
"public",
"static",
"String",
"getElementSetter",
"(",
"Element",
"element",
")",
"{",
"// 後続処理注意 hogeに対して sethoge が取得される. setHoge ではない.",
"String",
"setterName",
"=",
"null",
";",
"if",
"(",
"isPrimitiveBoolean",
"(",
"element",
")",
")",
"{",
"Pattern",
"pattern",
... | Returns the name of corresponding setter.
@param element the field
@return setter name
@author vvakame | [
"Returns",
"the",
"name",
"of",
"corresponding",
"setter",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L425-L457 | train |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.getElementGetter | public static String getElementGetter(Element element) {
// TODO 型(boolean)による絞り込みをするべき
String getterName1 = "get" + element.getSimpleName().toString();
String getterName2 = "is" + element.getSimpleName().toString();
String getterName3 = element.getSimpleName().toString();
Element getter = null;
for (Element method : ElementFilter.methodsIn(element.getEnclosingElement()
.getEnclosedElements())) {
String methodName = method.getSimpleName().toString();
if (getterName1.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
} else if (getterName2.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
} else if (getterName3.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
}
}
if (getter != null) {
return getter.getSimpleName().toString();
} else {
return null;
}
} | java | public static String getElementGetter(Element element) {
// TODO 型(boolean)による絞り込みをするべき
String getterName1 = "get" + element.getSimpleName().toString();
String getterName2 = "is" + element.getSimpleName().toString();
String getterName3 = element.getSimpleName().toString();
Element getter = null;
for (Element method : ElementFilter.methodsIn(element.getEnclosingElement()
.getEnclosedElements())) {
String methodName = method.getSimpleName().toString();
if (getterName1.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
} else if (getterName2.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
} else if (getterName3.equalsIgnoreCase(methodName)) {
if (isStatic(method) == false && isPublic(method) || isPackagePrivate(method)) {
getter = method;
break;
}
}
}
if (getter != null) {
return getter.getSimpleName().toString();
} else {
return null;
}
} | [
"public",
"static",
"String",
"getElementGetter",
"(",
"Element",
"element",
")",
"{",
"// TODO 型(boolean)による絞り込みをするべき",
"String",
"getterName1",
"=",
"\"get\"",
"+",
"element",
".",
"getSimpleName",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"getterName2... | Returns the name of corresponding getter.
@param element the field
@return getter name
@author vvakame | [
"Returns",
"the",
"name",
"of",
"corresponding",
"getter",
"."
] | fce183ca66354723323a77f2ae8cb5222b5836bc | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L465-L498 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.setInputFile | public void setInputFile (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.inputFile = value;
} | java | public void setInputFile (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.inputFile = value;
} | [
"public",
"void",
"setInputFile",
"(",
"final",
"File",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path is not absolute: \"",
"+",
"value... | Sets the absolute path to the grammar file to pass into JTB for
preprocessing.
@param value
The absolute path to the grammar file to pass into JTB for
preprocessing. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"grammar",
"file",
"to",
"pass",
"into",
"JTB",
"for",
"preprocessing",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L138-L145 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.setOutputDirectory | public void setOutputDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.outputDirectory = value;
} | java | public void setOutputDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.outputDirectory = value;
} | [
"public",
"void",
"setOutputDirectory",
"(",
"final",
"File",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path is not absolute: \"",
"+",
... | Sets the absolute path to the output directory for the generated grammar
file.
@param value
The absolute path to the output directory for the generated grammar
file. If this directory does not exist yet, it is created. Note that
this path should already include the desired package hierarchy
because JTB will not append the required sub directories
automatically. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"for",
"the",
"generated",
"grammar",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L158-L165 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getOutputFile | public File getOutputFile ()
{
File outputFile = null;
if (this.outputDirectory != null && this.inputFile != null)
{
final String fileName = FileUtils.removeExtension (this.inputFile.getName ()) + ".jj";
outputFile = new File (this.outputDirectory, fileName);
}
return outputFile;
} | java | public File getOutputFile ()
{
File outputFile = null;
if (this.outputDirectory != null && this.inputFile != null)
{
final String fileName = FileUtils.removeExtension (this.inputFile.getName ()) + ".jj";
outputFile = new File (this.outputDirectory, fileName);
}
return outputFile;
} | [
"public",
"File",
"getOutputFile",
"(",
")",
"{",
"File",
"outputFile",
"=",
"null",
";",
"if",
"(",
"this",
".",
"outputDirectory",
"!=",
"null",
"&&",
"this",
".",
"inputFile",
"!=",
"null",
")",
"{",
"final",
"String",
"fileName",
"=",
"FileUtils",
".... | Gets the absolute path to the enhanced grammar file generated by JTB.
@return The absolute path to the enhanced grammar file generated by JTB or
<code>null</code> if either the input file or the output directory
have not been set. | [
"Gets",
"the",
"absolute",
"path",
"to",
"the",
"enhanced",
"grammar",
"file",
"generated",
"by",
"JTB",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L174-L183 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.setNodeDirectory | public void setNodeDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.nodeDirectory = value;
} | java | public void setNodeDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.nodeDirectory = value;
} | [
"public",
"void",
"setNodeDirectory",
"(",
"final",
"File",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path is not absolute: \"",
"+",
"v... | Sets the absolute path to the output directory for the syntax tree files.
@param value
The absolute path to the output directory for the generated syntax
tree files, may be <code>null</code> to use a sub directory in the
output directory of the grammar file. If this directory does not
exist yet, it is created. Note that this path should already include
the desired package hierarchy because JTB will not append the
required sub directories automatically. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"for",
"the",
"syntax",
"tree",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L196-L203 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getEffectiveNodeDirectory | private File getEffectiveNodeDirectory ()
{
if (this.nodeDirectory != null)
return this.nodeDirectory;
if (this.outputDirectory != null)
return new File (this.outputDirectory, getLastPackageName (getEffectiveNodePackageName ()));
return null;
} | java | private File getEffectiveNodeDirectory ()
{
if (this.nodeDirectory != null)
return this.nodeDirectory;
if (this.outputDirectory != null)
return new File (this.outputDirectory, getLastPackageName (getEffectiveNodePackageName ()));
return null;
} | [
"private",
"File",
"getEffectiveNodeDirectory",
"(",
")",
"{",
"if",
"(",
"this",
".",
"nodeDirectory",
"!=",
"null",
")",
"return",
"this",
".",
"nodeDirectory",
";",
"if",
"(",
"this",
".",
"outputDirectory",
"!=",
"null",
")",
"return",
"new",
"File",
"... | Gets the absolute path to the output directory for the syntax tree files.
@return The absolute path to the output directory for the syntax tree
files, only <code>null</code> if neither {@link #outputDirectory}
nor {@link #nodeDirectory} have been set. | [
"Gets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"for",
"the",
"syntax",
"tree",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L212-L219 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.setVisitorDirectory | public void setVisitorDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.visitorDirectory = value;
} | java | public void setVisitorDirectory (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.visitorDirectory = value;
} | [
"public",
"void",
"setVisitorDirectory",
"(",
"final",
"File",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path is not absolute: \"",
"+",
... | Sets the absolute path to the output directory for the visitor files.
@param value
The absolute path to the output directory for the generated visitor
files, may be <code>null</code> to use a sub directory in the output
directory of the grammar file. If this directory does not exist yet,
it is created. Note that this path should already include the
desired package hierarchy because JTB will not append the required
sub directories automatically. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"for",
"the",
"visitor",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L232-L239 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getEffectiveVisitorDirectory | private File getEffectiveVisitorDirectory ()
{
if (this.visitorDirectory != null)
return this.visitorDirectory;
if (this.outputDirectory != null)
return new File (this.outputDirectory, getLastPackageName (getEffectiveVisitorPackageName ()));
return null;
} | java | private File getEffectiveVisitorDirectory ()
{
if (this.visitorDirectory != null)
return this.visitorDirectory;
if (this.outputDirectory != null)
return new File (this.outputDirectory, getLastPackageName (getEffectiveVisitorPackageName ()));
return null;
} | [
"private",
"File",
"getEffectiveVisitorDirectory",
"(",
")",
"{",
"if",
"(",
"this",
".",
"visitorDirectory",
"!=",
"null",
")",
"return",
"this",
".",
"visitorDirectory",
";",
"if",
"(",
"this",
".",
"outputDirectory",
"!=",
"null",
")",
"return",
"new",
"F... | Gets the absolute path to the output directory for the visitor files.
@return The absolute path to the output directory for the visitor, only
<code>null</code> if neither {@link #outputDirectory} nor
{@link #visitorDirectory} have been set. | [
"Gets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"for",
"the",
"visitor",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L248-L255 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getEffectiveNodePackageName | private String getEffectiveNodePackageName ()
{
if (this.packageName != null)
return this.packageName.length () <= 0 ? SYNTAX_TREE : this.packageName + '.' + SYNTAX_TREE;
if (this.nodePackageName != null)
return this.nodePackageName;
return SYNTAX_TREE;
} | java | private String getEffectiveNodePackageName ()
{
if (this.packageName != null)
return this.packageName.length () <= 0 ? SYNTAX_TREE : this.packageName + '.' + SYNTAX_TREE;
if (this.nodePackageName != null)
return this.nodePackageName;
return SYNTAX_TREE;
} | [
"private",
"String",
"getEffectiveNodePackageName",
"(",
")",
"{",
"if",
"(",
"this",
".",
"packageName",
"!=",
"null",
")",
"return",
"this",
".",
"packageName",
".",
"length",
"(",
")",
"<=",
"0",
"?",
"SYNTAX_TREE",
":",
"this",
".",
"packageName",
"+",... | Gets the effective package name for the syntax tree files.
@return The effective package name for the syntax tree files, never
<code>null</code>. | [
"Gets",
"the",
"effective",
"package",
"name",
"for",
"the",
"syntax",
"tree",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L286-L294 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getEffectiveVisitorPackageName | private String getEffectiveVisitorPackageName ()
{
if (this.packageName != null)
return this.packageName.length () <= 0 ? VISITOR : this.packageName + '.' + VISITOR;
if (this.visitorPackageName != null)
return this.visitorPackageName;
return VISITOR;
} | java | private String getEffectiveVisitorPackageName ()
{
if (this.packageName != null)
return this.packageName.length () <= 0 ? VISITOR : this.packageName + '.' + VISITOR;
if (this.visitorPackageName != null)
return this.visitorPackageName;
return VISITOR;
} | [
"private",
"String",
"getEffectiveVisitorPackageName",
"(",
")",
"{",
"if",
"(",
"this",
".",
"packageName",
"!=",
"null",
")",
"return",
"this",
".",
"packageName",
".",
"length",
"(",
")",
"<=",
"0",
"?",
"VISITOR",
":",
"this",
".",
"packageName",
"+",
... | Gets the effective package name for the visitor files.
@return The effective package name for the visitor files, never
<code>null</code>. | [
"Gets",
"the",
"effective",
"package",
"name",
"for",
"the",
"visitor",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L313-L320 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.generateArguments | private String [] generateArguments ()
{
final List <String> argsList = new ArrayList <> ();
argsList.add ("-np");
argsList.add (getEffectiveNodePackageName ());
argsList.add ("-vp");
argsList.add (getEffectiveVisitorPackageName ());
if (this.supressErrorChecking != null && this.supressErrorChecking.booleanValue ())
{
argsList.add ("-e");
}
if (this.javadocFriendlyComments != null && this.javadocFriendlyComments.booleanValue ())
{
argsList.add ("-jd");
}
if (this.descriptiveFieldNames != null && this.descriptiveFieldNames.booleanValue ())
{
argsList.add ("-f");
}
if (this.nodeParentClass != null)
{
argsList.add ("-ns");
argsList.add (this.nodeParentClass);
}
if (this.parentPointers != null && this.parentPointers.booleanValue ())
{
argsList.add ("-pp");
}
if (this.specialTokens != null && this.specialTokens.booleanValue ())
{
argsList.add ("-tk");
}
if (this.scheme != null && this.scheme.booleanValue ())
{
argsList.add ("-scheme");
}
if (this.printer != null && this.printer.booleanValue ())
{
argsList.add ("-printer");
}
final File outputFile = getOutputFile ();
if (outputFile != null)
{
argsList.add ("-o");
argsList.add (outputFile.getAbsolutePath ());
}
if (this.inputFile != null)
{
argsList.add (this.inputFile.getAbsolutePath ());
}
return argsList.toArray (new String [argsList.size ()]);
} | java | private String [] generateArguments ()
{
final List <String> argsList = new ArrayList <> ();
argsList.add ("-np");
argsList.add (getEffectiveNodePackageName ());
argsList.add ("-vp");
argsList.add (getEffectiveVisitorPackageName ());
if (this.supressErrorChecking != null && this.supressErrorChecking.booleanValue ())
{
argsList.add ("-e");
}
if (this.javadocFriendlyComments != null && this.javadocFriendlyComments.booleanValue ())
{
argsList.add ("-jd");
}
if (this.descriptiveFieldNames != null && this.descriptiveFieldNames.booleanValue ())
{
argsList.add ("-f");
}
if (this.nodeParentClass != null)
{
argsList.add ("-ns");
argsList.add (this.nodeParentClass);
}
if (this.parentPointers != null && this.parentPointers.booleanValue ())
{
argsList.add ("-pp");
}
if (this.specialTokens != null && this.specialTokens.booleanValue ())
{
argsList.add ("-tk");
}
if (this.scheme != null && this.scheme.booleanValue ())
{
argsList.add ("-scheme");
}
if (this.printer != null && this.printer.booleanValue ())
{
argsList.add ("-printer");
}
final File outputFile = getOutputFile ();
if (outputFile != null)
{
argsList.add ("-o");
argsList.add (outputFile.getAbsolutePath ());
}
if (this.inputFile != null)
{
argsList.add (this.inputFile.getAbsolutePath ());
}
return argsList.toArray (new String [argsList.size ()]);
} | [
"private",
"String",
"[",
"]",
"generateArguments",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"argsList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"argsList",
".",
"add",
"(",
"\"-np\"",
")",
";",
"argsList",
".",
"add",
"(",
"getEffecti... | Assembles the command line arguments for the invocation of JTB according to
the configuration.
@return A string array that represents the command line arguments to use
for JTB. | [
"Assembles",
"the",
"command",
"line",
"arguments",
"for",
"the",
"invocation",
"of",
"JTB",
"according",
"to",
"the",
"configuration",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L455-L519 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTB.java | JTB.getLastPackageName | private String getLastPackageName (final String name)
{
if (name != null)
{
return name.substring (name.lastIndexOf ('.') + 1);
}
return null;
} | java | private String getLastPackageName (final String name)
{
if (name != null)
{
return name.substring (name.lastIndexOf ('.') + 1);
}
return null;
} | [
"private",
"String",
"getLastPackageName",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"return",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"}",
"return"... | Gets the last identifier from the specified package name. For example,
returns "apache" upon input of "org.apache". JTB uses this approach to
derive the output directories for the visitor and syntax tree files.
@param name
The package name from which to retrieve the last sub package, may be
<code>null</code>.
@return The name of the last sub package or <code>null</code> if the input
was <code>null</code> | [
"Gets",
"the",
"last",
"identifier",
"from",
"the",
"specified",
"package",
"name",
".",
"For",
"example",
"returns",
"apache",
"upon",
"input",
"of",
"org",
".",
"apache",
".",
"JTB",
"uses",
"this",
"approach",
"to",
"derive",
"the",
"output",
"directories... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTB.java#L532-L539 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJTreeJavaCCMojo.java | JJTreeJavaCCMojo.newJJTree | protected JJTree newJJTree ()
{
final JJTree jjtree = new JJTree ();
jjtree.setLog (getLog ());
jjtree.setGrammarEncoding (getGrammarEncoding ());
jjtree.setOutputEncoding (getOutputEncoding ());
jjtree.setJdkVersion (getJdkVersion ());
jjtree.setBuildNodeFiles (this.buildNodeFiles);
jjtree.setMulti (this.multi);
jjtree.setNodeDefaultVoid (this.nodeDefaultVoid);
jjtree.setNodeClass (this.nodeClass);
jjtree.setNodeFactory (this.nodeFactory);
jjtree.setNodePrefix (this.nodePrefix);
jjtree.setNodeScopeHook (this.nodeScopeHook);
jjtree.setNodeUsesParser (this.nodeUsesParser);
jjtree.setTrackTokens (this.trackTokens);
jjtree.setVisitor (this.visitor);
jjtree.setVisitorDataType (this.visitorDataType);
jjtree.setVisitorReturnType (this.visitorReturnType);
jjtree.setVisitorException (this.visitorException);
jjtree.setJavaTemplateType (this.getJavaTemplateType ());
return jjtree;
} | java | protected JJTree newJJTree ()
{
final JJTree jjtree = new JJTree ();
jjtree.setLog (getLog ());
jjtree.setGrammarEncoding (getGrammarEncoding ());
jjtree.setOutputEncoding (getOutputEncoding ());
jjtree.setJdkVersion (getJdkVersion ());
jjtree.setBuildNodeFiles (this.buildNodeFiles);
jjtree.setMulti (this.multi);
jjtree.setNodeDefaultVoid (this.nodeDefaultVoid);
jjtree.setNodeClass (this.nodeClass);
jjtree.setNodeFactory (this.nodeFactory);
jjtree.setNodePrefix (this.nodePrefix);
jjtree.setNodeScopeHook (this.nodeScopeHook);
jjtree.setNodeUsesParser (this.nodeUsesParser);
jjtree.setTrackTokens (this.trackTokens);
jjtree.setVisitor (this.visitor);
jjtree.setVisitorDataType (this.visitorDataType);
jjtree.setVisitorReturnType (this.visitorReturnType);
jjtree.setVisitorException (this.visitorException);
jjtree.setJavaTemplateType (this.getJavaTemplateType ());
return jjtree;
} | [
"protected",
"JJTree",
"newJJTree",
"(",
")",
"{",
"final",
"JJTree",
"jjtree",
"=",
"new",
"JJTree",
"(",
")",
";",
"jjtree",
".",
"setLog",
"(",
"getLog",
"(",
")",
")",
";",
"jjtree",
".",
"setGrammarEncoding",
"(",
"getGrammarEncoding",
"(",
")",
")"... | Creates a new facade to invoke JJTree. Most options for the invocation are
derived from the current values of the corresponding mojo parameters. The
caller is responsible to set the input file, output directory and package
on the returned facade.
@return The facade for the tool invocation, never <code>null</code>. | [
"Creates",
"a",
"new",
"facade",
"to",
"invoke",
"JJTree",
".",
"Most",
"options",
"for",
"the",
"invocation",
"are",
"derived",
"from",
"the",
"current",
"values",
"of",
"the",
"corresponding",
"mojo",
"parameters",
".",
"The",
"caller",
"is",
"responsible",
... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJTreeJavaCCMojo.java#L366-L388 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java | ForkedJvm.addClassPathEntry | public final void addClassPathEntry (@Nullable final File path)
{
if (path != null)
m_aClassPathEntries.add (path.getAbsolutePath ());
} | java | public final void addClassPathEntry (@Nullable final File path)
{
if (path != null)
m_aClassPathEntries.add (path.getAbsolutePath ());
} | [
"public",
"final",
"void",
"addClassPathEntry",
"(",
"@",
"Nullable",
"final",
"File",
"path",
")",
"{",
"if",
"(",
"path",
"!=",
"null",
")",
"m_aClassPathEntries",
".",
"add",
"(",
"path",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}"
] | Adds the specified path to the class path of the forked JVM.
@param path
The path to add, may be <code>null</code>. | [
"Adds",
"the",
"specified",
"path",
"to",
"the",
"class",
"path",
"of",
"the",
"forked",
"JVM",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java#L168-L172 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java | ForkedJvm._getResourceSource | @Nullable
private static File _getResourceSource (final String resource, final ClassLoader loader)
{
if (resource != null)
{
URL url;
if (loader != null)
{
url = loader.getResource (resource);
}
else
{
url = ClassLoader.getSystemResource (resource);
}
return UrlUtils.getResourceRoot (url, resource);
}
return null;
} | java | @Nullable
private static File _getResourceSource (final String resource, final ClassLoader loader)
{
if (resource != null)
{
URL url;
if (loader != null)
{
url = loader.getResource (resource);
}
else
{
url = ClassLoader.getSystemResource (resource);
}
return UrlUtils.getResourceRoot (url, resource);
}
return null;
} | [
"@",
"Nullable",
"private",
"static",
"File",
"_getResourceSource",
"(",
"final",
"String",
"resource",
",",
"final",
"ClassLoader",
"loader",
")",
"{",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"URL",
"url",
";",
"if",
"(",
"loader",
"!=",
"null",
... | Gets the JAR file or directory that contains the specified resource.
@param resource
The absolute name of the resource to find, may be <code>null</code>.
@param loader
The class loader to use for searching the resource, may be
<code>null</code>.
@return The absolute path to the resource location or <code>null</code> if
unknown. | [
"Gets",
"the",
"JAR",
"file",
"or",
"directory",
"that",
"contains",
"the",
"specified",
"resource",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java#L234-L251 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java | ForkedJvm._createCommandLine | private Commandline _createCommandLine ()
{
/*
* NOTE: This method is designed to work with plexus-utils:1.1 which is used
* by all Maven versions before 2.0.6 regardless of our plugin dependency.
* Therefore, we use setWorkingDirectory(String) rather than
* setWorkingDirectory(File) and addArguments() rather than createArg().
*/
final Commandline cli = new Commandline ();
cli.setExecutable (this.executable);
if (this.workingDirectory != null)
{
cli.setWorkingDirectory (this.workingDirectory.getAbsolutePath ());
}
final String classPath = _getClassPath ();
if (classPath != null && classPath.length () > 0)
{
cli.addArguments (new String [] { "-cp", classPath });
}
if (this.mainClass != null && this.mainClass.length () > 0)
{
cli.addArguments (new String [] { this.mainClass });
}
cli.addArguments (_getArguments ());
return cli;
} | java | private Commandline _createCommandLine ()
{
/*
* NOTE: This method is designed to work with plexus-utils:1.1 which is used
* by all Maven versions before 2.0.6 regardless of our plugin dependency.
* Therefore, we use setWorkingDirectory(String) rather than
* setWorkingDirectory(File) and addArguments() rather than createArg().
*/
final Commandline cli = new Commandline ();
cli.setExecutable (this.executable);
if (this.workingDirectory != null)
{
cli.setWorkingDirectory (this.workingDirectory.getAbsolutePath ());
}
final String classPath = _getClassPath ();
if (classPath != null && classPath.length () > 0)
{
cli.addArguments (new String [] { "-cp", classPath });
}
if (this.mainClass != null && this.mainClass.length () > 0)
{
cli.addArguments (new String [] { this.mainClass });
}
cli.addArguments (_getArguments ());
return cli;
} | [
"private",
"Commandline",
"_createCommandLine",
"(",
")",
"{",
"/*\n * NOTE: This method is designed to work with plexus-utils:1.1 which is used\n * by all Maven versions before 2.0.6 regardless of our plugin dependency.\n * Therefore, we use setWorkingDirectory(String) rather than\n * s... | Creates the command line for the new JVM based on the current
configuration.
@return The command line used to fork the JVM, never <code>null</code>. | [
"Creates",
"the",
"command",
"line",
"for",
"the",
"new",
"JVM",
"based",
"on",
"the",
"current",
"configuration",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java#L347-L379 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.getSourceDirectories | private File [] getSourceDirectories ()
{
final Set <File> directories = new LinkedHashSet <> ();
if (this.sourceDirectories != null && this.sourceDirectories.length > 0)
{
directories.addAll (Arrays.asList (this.sourceDirectories));
}
else
{
if (this.defaultGrammarDirectoryJavaCC != null)
{
directories.add (this.defaultGrammarDirectoryJavaCC);
}
if (this.defaultGrammarDirectoryJJTree != null)
{
directories.add (this.defaultGrammarDirectoryJJTree);
}
if (this.defaultGrammarDirectoryJTB != null)
{
directories.add (this.defaultGrammarDirectoryJTB);
}
}
return directories.toArray (new File [directories.size ()]);
} | java | private File [] getSourceDirectories ()
{
final Set <File> directories = new LinkedHashSet <> ();
if (this.sourceDirectories != null && this.sourceDirectories.length > 0)
{
directories.addAll (Arrays.asList (this.sourceDirectories));
}
else
{
if (this.defaultGrammarDirectoryJavaCC != null)
{
directories.add (this.defaultGrammarDirectoryJavaCC);
}
if (this.defaultGrammarDirectoryJJTree != null)
{
directories.add (this.defaultGrammarDirectoryJJTree);
}
if (this.defaultGrammarDirectoryJTB != null)
{
directories.add (this.defaultGrammarDirectoryJTB);
}
}
return directories.toArray (new File [directories.size ()]);
} | [
"private",
"File",
"[",
"]",
"getSourceDirectories",
"(",
")",
"{",
"final",
"Set",
"<",
"File",
">",
"directories",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"if",
"(",
"this",
".",
"sourceDirectories",
"!=",
"null",
"&&",
"this",
".",
"sourceDi... | Get the source directories that should be scanned for grammar files.
@return The source directories that should be scanned for grammar files,
never <code>null</code>. | [
"Get",
"the",
"source",
"directories",
"that",
"should",
"be",
"scanned",
"for",
"grammar",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L249-L272 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.executeReport | @Override
public void executeReport (final Locale locale) throws MavenReportException
{
final Sink sink = getSink ();
createReportHeader (getBundle (locale), sink);
final File [] sourceDirs = getSourceDirectories ();
for (final File sourceDir : sourceDirs)
{
final GrammarInfo [] grammarInfos = scanForGrammars (sourceDir);
if (grammarInfos == null)
{
getLog ().debug ("Skipping non-existing source directory: " + sourceDir);
}
else
{
Arrays.sort (grammarInfos, GrammarInfoComparator.getInstance ());
for (final GrammarInfo grammarInfo : grammarInfos)
{
final File grammarFile = grammarInfo.getGrammarFile ();
String relativeOutputFileName = grammarInfo.getRelativeGrammarFile ();
relativeOutputFileName = relativeOutputFileName.replaceAll ("(?i)\\.(jj|jjt|jtb)$",
getOutputFileExtension ());
final File jjdocOutputFile = new File (getJJDocOutputDirectory (), relativeOutputFileName);
final JJDoc jjdoc = newJJDoc ();
jjdoc.setInputFile (grammarFile);
jjdoc.setOutputFile (jjdocOutputFile);
try
{
jjdoc.run ();
}
catch (final Exception e)
{
throw new MavenReportException ("Failed to create BNF documentation: " + grammarFile, e);
}
createReportLink (sink, sourceDir, grammarFile, relativeOutputFileName);
}
}
}
createReportFooter (sink);
sink.flush ();
sink.close ();
} | java | @Override
public void executeReport (final Locale locale) throws MavenReportException
{
final Sink sink = getSink ();
createReportHeader (getBundle (locale), sink);
final File [] sourceDirs = getSourceDirectories ();
for (final File sourceDir : sourceDirs)
{
final GrammarInfo [] grammarInfos = scanForGrammars (sourceDir);
if (grammarInfos == null)
{
getLog ().debug ("Skipping non-existing source directory: " + sourceDir);
}
else
{
Arrays.sort (grammarInfos, GrammarInfoComparator.getInstance ());
for (final GrammarInfo grammarInfo : grammarInfos)
{
final File grammarFile = grammarInfo.getGrammarFile ();
String relativeOutputFileName = grammarInfo.getRelativeGrammarFile ();
relativeOutputFileName = relativeOutputFileName.replaceAll ("(?i)\\.(jj|jjt|jtb)$",
getOutputFileExtension ());
final File jjdocOutputFile = new File (getJJDocOutputDirectory (), relativeOutputFileName);
final JJDoc jjdoc = newJJDoc ();
jjdoc.setInputFile (grammarFile);
jjdoc.setOutputFile (jjdocOutputFile);
try
{
jjdoc.run ();
}
catch (final Exception e)
{
throw new MavenReportException ("Failed to create BNF documentation: " + grammarFile, e);
}
createReportLink (sink, sourceDir, grammarFile, relativeOutputFileName);
}
}
}
createReportFooter (sink);
sink.flush ();
sink.close ();
} | [
"@",
"Override",
"public",
"void",
"executeReport",
"(",
"final",
"Locale",
"locale",
")",
"throws",
"MavenReportException",
"{",
"final",
"Sink",
"sink",
"=",
"getSink",
"(",
")",
";",
"createReportHeader",
"(",
"getBundle",
"(",
"locale",
")",
",",
"sink",
... | Run the actual report.
@param locale
The locale to use for this report.
@throws MavenReportException
If the report generation failed. | [
"Run",
"the",
"actual",
"report",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L337-L386 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.createReportHeader | private void createReportHeader (final ResourceBundle bundle, final Sink sink)
{
sink.head ();
sink.title ();
sink.text (bundle.getString ("report.jjdoc.title"));
sink.title_ ();
sink.head_ ();
sink.body ();
sink.section1 ();
sink.sectionTitle1 ();
sink.text (bundle.getString ("report.jjdoc.title"));
sink.sectionTitle1_ ();
sink.text (bundle.getString ("report.jjdoc.description"));
sink.section1_ ();
sink.lineBreak ();
sink.table ();
sink.tableRow ();
sink.tableHeaderCell ();
sink.text (bundle.getString ("report.jjdoc.table.heading"));
sink.tableHeaderCell_ ();
sink.tableRow_ ();
} | java | private void createReportHeader (final ResourceBundle bundle, final Sink sink)
{
sink.head ();
sink.title ();
sink.text (bundle.getString ("report.jjdoc.title"));
sink.title_ ();
sink.head_ ();
sink.body ();
sink.section1 ();
sink.sectionTitle1 ();
sink.text (bundle.getString ("report.jjdoc.title"));
sink.sectionTitle1_ ();
sink.text (bundle.getString ("report.jjdoc.description"));
sink.section1_ ();
sink.lineBreak ();
sink.table ();
sink.tableRow ();
sink.tableHeaderCell ();
sink.text (bundle.getString ("report.jjdoc.table.heading"));
sink.tableHeaderCell_ ();
sink.tableRow_ ();
} | [
"private",
"void",
"createReportHeader",
"(",
"final",
"ResourceBundle",
"bundle",
",",
"final",
"Sink",
"sink",
")",
"{",
"sink",
".",
"head",
"(",
")",
";",
"sink",
".",
"title",
"(",
")",
";",
"sink",
".",
"text",
"(",
"bundle",
".",
"getString",
"(... | Create the header and title for the HTML report page.
@param bundle
The resource bundle with the text.
@param sink
The sink for writing to the main report file. | [
"Create",
"the",
"header",
"and",
"title",
"for",
"the",
"HTML",
"report",
"page",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L416-L440 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.createReportLink | private void createReportLink (final Sink sink, final File sourceDirectory, final File grammarFile, String linkPath)
{
sink.tableRow ();
sink.tableCell ();
if (linkPath.startsWith ("/"))
{
linkPath = linkPath.substring (1);
}
sink.link (linkPath);
String grammarFileRelativePath = sourceDirectory.toURI ().relativize (grammarFile.toURI ()).toString ();
if (grammarFileRelativePath.startsWith ("/"))
{
grammarFileRelativePath = grammarFileRelativePath.substring (1);
}
sink.text (grammarFileRelativePath);
sink.link_ ();
sink.tableCell_ ();
sink.tableRow_ ();
} | java | private void createReportLink (final Sink sink, final File sourceDirectory, final File grammarFile, String linkPath)
{
sink.tableRow ();
sink.tableCell ();
if (linkPath.startsWith ("/"))
{
linkPath = linkPath.substring (1);
}
sink.link (linkPath);
String grammarFileRelativePath = sourceDirectory.toURI ().relativize (grammarFile.toURI ()).toString ();
if (grammarFileRelativePath.startsWith ("/"))
{
grammarFileRelativePath = grammarFileRelativePath.substring (1);
}
sink.text (grammarFileRelativePath);
sink.link_ ();
sink.tableCell_ ();
sink.tableRow_ ();
} | [
"private",
"void",
"createReportLink",
"(",
"final",
"Sink",
"sink",
",",
"final",
"File",
"sourceDirectory",
",",
"final",
"File",
"grammarFile",
",",
"String",
"linkPath",
")",
"{",
"sink",
".",
"tableRow",
"(",
")",
";",
"sink",
".",
"tableCell",
"(",
"... | Create a table row containing a link to the JJDoc report for a grammar
file.
@param sink
The sink to write the report
@param sourceDirectory
The source directory of the grammar file.
@param grammarFile
The JavaCC grammar file.
@param linkPath
The path to the JJDoc output. | [
"Create",
"a",
"table",
"row",
"containing",
"a",
"link",
"to",
"the",
"JJDoc",
"report",
"for",
"a",
"grammar",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L455-L473 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.newJJDoc | private JJDoc newJJDoc ()
{
final JJDoc jjdoc = new JJDoc ();
jjdoc.setLog (getLog ());
jjdoc.setGrammarEncoding (this.grammarEncoding);
jjdoc.setOutputEncoding (this.outputEncoding);
jjdoc.setCssHref (this.cssHref);
jjdoc.setText (this.text);
jjdoc.setBnf (this.bnf);
jjdoc.setOneTable (Boolean.valueOf (this.oneTable));
return jjdoc;
} | java | private JJDoc newJJDoc ()
{
final JJDoc jjdoc = new JJDoc ();
jjdoc.setLog (getLog ());
jjdoc.setGrammarEncoding (this.grammarEncoding);
jjdoc.setOutputEncoding (this.outputEncoding);
jjdoc.setCssHref (this.cssHref);
jjdoc.setText (this.text);
jjdoc.setBnf (this.bnf);
jjdoc.setOneTable (Boolean.valueOf (this.oneTable));
return jjdoc;
} | [
"private",
"JJDoc",
"newJJDoc",
"(",
")",
"{",
"final",
"JJDoc",
"jjdoc",
"=",
"new",
"JJDoc",
"(",
")",
";",
"jjdoc",
".",
"setLog",
"(",
"getLog",
"(",
")",
")",
";",
"jjdoc",
".",
"setGrammarEncoding",
"(",
"this",
".",
"grammarEncoding",
")",
";",
... | Creates a new facade to invoke JJDoc. Most options for the invocation are
derived from the current values of the corresponding mojo parameters. The
caller is responsible to set the input file and output file on the returned
facade.
@return The facade for the tool invocation, never <code>null</code>. | [
"Creates",
"a",
"new",
"facade",
"to",
"invoke",
"JJDoc",
".",
"Most",
"options",
"for",
"the",
"invocation",
"are",
"derived",
"from",
"the",
"current",
"values",
"of",
"the",
"corresponding",
"mojo",
"parameters",
".",
"The",
"caller",
"is",
"responsible",
... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L495-L506 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java | JJDocMojo.scanForGrammars | private GrammarInfo [] scanForGrammars (final File sourceDirectory) throws MavenReportException
{
if (!sourceDirectory.isDirectory ())
{
return null;
}
GrammarInfo [] grammarInfos;
getLog ().debug ("Scanning for grammars: " + sourceDirectory);
try
{
final String [] includes = { "**/*.jj", "**/*.JJ", "**/*.jjt", "**/*.JJT", "**/*.jtb", "**/*.JTB" };
final GrammarDirectoryScanner scanner = new GrammarDirectoryScanner ();
scanner.setSourceDirectory (sourceDirectory);
scanner.setIncludes (includes);
scanner.scan ();
grammarInfos = scanner.getIncludedGrammars ();
}
catch (final Exception e)
{
throw new MavenReportException ("Failed to scan for grammars: " + sourceDirectory, e);
}
getLog ().debug ("Found grammars: " + Arrays.asList (grammarInfos));
return grammarInfos;
} | java | private GrammarInfo [] scanForGrammars (final File sourceDirectory) throws MavenReportException
{
if (!sourceDirectory.isDirectory ())
{
return null;
}
GrammarInfo [] grammarInfos;
getLog ().debug ("Scanning for grammars: " + sourceDirectory);
try
{
final String [] includes = { "**/*.jj", "**/*.JJ", "**/*.jjt", "**/*.JJT", "**/*.jtb", "**/*.JTB" };
final GrammarDirectoryScanner scanner = new GrammarDirectoryScanner ();
scanner.setSourceDirectory (sourceDirectory);
scanner.setIncludes (includes);
scanner.scan ();
grammarInfos = scanner.getIncludedGrammars ();
}
catch (final Exception e)
{
throw new MavenReportException ("Failed to scan for grammars: " + sourceDirectory, e);
}
getLog ().debug ("Found grammars: " + Arrays.asList (grammarInfos));
return grammarInfos;
} | [
"private",
"GrammarInfo",
"[",
"]",
"scanForGrammars",
"(",
"final",
"File",
"sourceDirectory",
")",
"throws",
"MavenReportException",
"{",
"if",
"(",
"!",
"sourceDirectory",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"GrammarInfo",
"[... | Searches the specified source directory to find grammar files that can be
documented.
@param sourceDirectory
The source directory to scan for grammar files.
@return An array of grammar infos describing the found grammar files or
<code>null</code> if the source directory does not exist.
@throws MavenReportException
If there is a problem while scanning for .jj files. | [
"Searches",
"the",
"specified",
"source",
"directory",
"to",
"find",
"grammar",
"files",
"that",
"can",
"be",
"documented",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java#L519-L545 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.execute | public void execute () throws MojoExecutionException, MojoFailureException
{
final GrammarInfo [] grammarInfos = scanForGrammars ();
if (grammarInfos == null)
{
getLog ().info ("Skipping non-existing source directory: " + getSourceDirectory ());
return;
}
else
if (grammarInfos.length <= 0)
{
getLog ().info ("Skipping - all parsers are up to date");
}
else
{
determineNonGeneratedSourceRoots ();
if (StringUtils.isEmpty (grammarEncoding))
{
getLog ().warn ("File encoding for grammars has not been configured, using platform default encoding, i.e. build is platform dependent!");
}
if (StringUtils.isEmpty (outputEncoding))
{
getLog ().warn ("File encoding for output has not been configured, defaulting to UTF-8!");
}
for (final GrammarInfo grammarInfo : grammarInfos)
{
processGrammar (grammarInfo);
}
getLog ().info ("Processed " + grammarInfos.length + " grammar" + (grammarInfos.length != 1 ? "s" : ""));
}
final Collection <File> compileSourceRoots = new LinkedHashSet <> (Arrays.asList (getCompileSourceRoots ()));
for (final File file : compileSourceRoots)
{
addSourceRoot (file);
}
} | java | public void execute () throws MojoExecutionException, MojoFailureException
{
final GrammarInfo [] grammarInfos = scanForGrammars ();
if (grammarInfos == null)
{
getLog ().info ("Skipping non-existing source directory: " + getSourceDirectory ());
return;
}
else
if (grammarInfos.length <= 0)
{
getLog ().info ("Skipping - all parsers are up to date");
}
else
{
determineNonGeneratedSourceRoots ();
if (StringUtils.isEmpty (grammarEncoding))
{
getLog ().warn ("File encoding for grammars has not been configured, using platform default encoding, i.e. build is platform dependent!");
}
if (StringUtils.isEmpty (outputEncoding))
{
getLog ().warn ("File encoding for output has not been configured, defaulting to UTF-8!");
}
for (final GrammarInfo grammarInfo : grammarInfos)
{
processGrammar (grammarInfo);
}
getLog ().info ("Processed " + grammarInfos.length + " grammar" + (grammarInfos.length != 1 ? "s" : ""));
}
final Collection <File> compileSourceRoots = new LinkedHashSet <> (Arrays.asList (getCompileSourceRoots ()));
for (final File file : compileSourceRoots)
{
addSourceRoot (file);
}
} | [
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"final",
"GrammarInfo",
"[",
"]",
"grammarInfos",
"=",
"scanForGrammars",
"(",
")",
";",
"if",
"(",
"grammarInfos",
"==",
"null",
")",
"{",
"getLog",
"... | Execute the tool.
@throws MojoExecutionException
If the invocation of the tool failed.
@throws MojoFailureException
If the tool reported a non-zero exit code. | [
"Execute",
"the",
"tool",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L433-L473 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.scanForGrammars | private GrammarInfo [] scanForGrammars () throws MojoExecutionException
{
if (!getSourceDirectory ().isDirectory ())
{
return null;
}
GrammarInfo [] grammarInfos;
getLog ().debug ("Scanning for grammars: " + getSourceDirectory ());
try
{
final GrammarDirectoryScanner scanner = new GrammarDirectoryScanner ();
scanner.setSourceDirectory (getSourceDirectory ());
scanner.setIncludes (getIncludes ());
scanner.setExcludes (getExcludes ());
scanner.setOutputDirectory (getOutputDirectory ());
scanner.setParserPackage (getParserPackage ());
scanner.setStaleMillis (getStaleMillis ());
scanner.scan ();
grammarInfos = scanner.getIncludedGrammars ();
}
catch (final Exception e)
{
throw new MojoExecutionException ("Failed to scan for grammars: " + getSourceDirectory (), e);
}
getLog ().debug ("Found grammars: " + Arrays.asList (grammarInfos));
return grammarInfos;
} | java | private GrammarInfo [] scanForGrammars () throws MojoExecutionException
{
if (!getSourceDirectory ().isDirectory ())
{
return null;
}
GrammarInfo [] grammarInfos;
getLog ().debug ("Scanning for grammars: " + getSourceDirectory ());
try
{
final GrammarDirectoryScanner scanner = new GrammarDirectoryScanner ();
scanner.setSourceDirectory (getSourceDirectory ());
scanner.setIncludes (getIncludes ());
scanner.setExcludes (getExcludes ());
scanner.setOutputDirectory (getOutputDirectory ());
scanner.setParserPackage (getParserPackage ());
scanner.setStaleMillis (getStaleMillis ());
scanner.scan ();
grammarInfos = scanner.getIncludedGrammars ();
}
catch (final Exception e)
{
throw new MojoExecutionException ("Failed to scan for grammars: " + getSourceDirectory (), e);
}
getLog ().debug ("Found grammars: " + Arrays.asList (grammarInfos));
return grammarInfos;
} | [
"private",
"GrammarInfo",
"[",
"]",
"scanForGrammars",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"!",
"getSourceDirectory",
"(",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"GrammarInfo",
"[",
"]",
"grammarInf... | Scans the configured source directory for grammar files which need
processing.
@return An array of grammar infos describing the found grammar files or
<code>null</code> if the source directory does not exist.
@throws MojoExecutionException
If the source directory could not be scanned. | [
"Scans",
"the",
"configured",
"source",
"directory",
"for",
"grammar",
"files",
"which",
"need",
"processing",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L497-L526 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.deleteTempDirectory | protected void deleteTempDirectory (final File tempDirectory)
{
try
{
FileUtils.deleteDirectory (tempDirectory);
}
catch (final IOException e)
{
getLog ().warn ("Failed to delete temporary directory: " + tempDirectory, e);
}
} | java | protected void deleteTempDirectory (final File tempDirectory)
{
try
{
FileUtils.deleteDirectory (tempDirectory);
}
catch (final IOException e)
{
getLog ().warn ("Failed to delete temporary directory: " + tempDirectory, e);
}
} | [
"protected",
"void",
"deleteTempDirectory",
"(",
"final",
"File",
"tempDirectory",
")",
"{",
"try",
"{",
"FileUtils",
".",
"deleteDirectory",
"(",
"tempDirectory",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"getLog",
"(",
")",
".",
... | Deletes the specified temporary directory.
@param tempDirectory
The directory to delete, must not be <code>null</code>. | [
"Deletes",
"the",
"specified",
"temporary",
"directory",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L544-L554 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.findSourceFile | private File findSourceFile (final String filename)
{
final Collection <File> sourceRoots = this.nonGeneratedSourceRoots;
for (final File sourceRoot : sourceRoots)
{
final File sourceFile = new File (sourceRoot, filename);
if (sourceFile.exists ())
{
return sourceFile;
}
}
return null;
} | java | private File findSourceFile (final String filename)
{
final Collection <File> sourceRoots = this.nonGeneratedSourceRoots;
for (final File sourceRoot : sourceRoots)
{
final File sourceFile = new File (sourceRoot, filename);
if (sourceFile.exists ())
{
return sourceFile;
}
}
return null;
} | [
"private",
"File",
"findSourceFile",
"(",
"final",
"String",
"filename",
")",
"{",
"final",
"Collection",
"<",
"File",
">",
"sourceRoots",
"=",
"this",
".",
"nonGeneratedSourceRoots",
";",
"for",
"(",
"final",
"File",
"sourceRoot",
":",
"sourceRoots",
")",
"{"... | Determines whether the specified source file is already present in any of the
compile source roots registered with the current Maven project.
@param filename
The source filename to check, relative to a source root, must not be
<code>null</code>.
@return The (absolute) path to the existing source file if any,
<code>null</code> otherwise. | [
"Determines",
"whether",
"the",
"specified",
"source",
"file",
"is",
"already",
"present",
"in",
"any",
"of",
"the",
"compile",
"source",
"roots",
"registered",
"with",
"the",
"current",
"Maven",
"project",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L693-L705 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.addSourceRoot | private void addSourceRoot (final File directory)
{
if (this.project != null)
{
getLog ().debug ("Adding compile source root: " + directory);
this.project.addCompileSourceRoot (directory.getAbsolutePath ());
}
} | java | private void addSourceRoot (final File directory)
{
if (this.project != null)
{
getLog ().debug ("Adding compile source root: " + directory);
this.project.addCompileSourceRoot (directory.getAbsolutePath ());
}
} | [
"private",
"void",
"addSourceRoot",
"(",
"final",
"File",
"directory",
")",
"{",
"if",
"(",
"this",
".",
"project",
"!=",
"null",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Adding compile source root: \"",
"+",
"directory",
")",
";",
"this",
".",
... | Registers the specified directory as a compile source root for the current
project.
@param directory
The absolute path to the source root, must not be <code>null</code>. | [
"Registers",
"the",
"specified",
"directory",
"as",
"a",
"compile",
"source",
"root",
"for",
"the",
"current",
"project",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L728-L735 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java | AbstractJavaCCMojo.newJavaCC | protected JavaCC newJavaCC ()
{
final JavaCC javacc = new JavaCC ();
javacc.setLog (getLog ());
javacc.setGrammarEncoding (this.grammarEncoding);
javacc.setOutputEncoding (this.outputEncoding);
javacc.setJdkVersion (this.jdkVersion);
javacc.setBuildParser (this.buildParser);
javacc.setBuildTokenManager (this.buildTokenManager);
javacc.setCacheTokens (this.cacheTokens);
javacc.setChoiceAmbiguityCheck (this.choiceAmbiguityCheck);
javacc.setCommonTokenAction (this.commonTokenAction);
javacc.setDebugLookAhead (this.debugLookAhead);
javacc.setDebugParser (this.debugParser);
javacc.setDebugTokenManager (this.debugTokenManager);
javacc.setErrorReporting (this.errorReporting);
javacc.setForceLaCheck (this.forceLaCheck);
javacc.setIgnoreCase (this.ignoreCase);
javacc.setJavaUnicodeEscape (this.javaUnicodeEscape);
javacc.setKeepLineColumn (this.keepLineColumn);
javacc.setLookAhead (this.lookAhead);
javacc.setOtherAmbiguityCheck (this.otherAmbiguityCheck);
javacc.setSanityCheck (this.sanityCheck);
javacc.setTokenManagerUsesParser (this.tokenManagerUsesParser);
javacc.setTokenExtends (this.tokenExtends);
javacc.setTokenFactory (this.tokenFactory);
javacc.setUnicodeInput (this.unicodeInput);
javacc.setUserCharStream (this.userCharStream);
javacc.setUserTokenManager (this.userTokenManager);
javacc.setSupportClassVisibilityPublic (this.supportClassVisibilityPublic);
javacc.setJavaTemplateType (this.javaTemplateType);
return javacc;
} | java | protected JavaCC newJavaCC ()
{
final JavaCC javacc = new JavaCC ();
javacc.setLog (getLog ());
javacc.setGrammarEncoding (this.grammarEncoding);
javacc.setOutputEncoding (this.outputEncoding);
javacc.setJdkVersion (this.jdkVersion);
javacc.setBuildParser (this.buildParser);
javacc.setBuildTokenManager (this.buildTokenManager);
javacc.setCacheTokens (this.cacheTokens);
javacc.setChoiceAmbiguityCheck (this.choiceAmbiguityCheck);
javacc.setCommonTokenAction (this.commonTokenAction);
javacc.setDebugLookAhead (this.debugLookAhead);
javacc.setDebugParser (this.debugParser);
javacc.setDebugTokenManager (this.debugTokenManager);
javacc.setErrorReporting (this.errorReporting);
javacc.setForceLaCheck (this.forceLaCheck);
javacc.setIgnoreCase (this.ignoreCase);
javacc.setJavaUnicodeEscape (this.javaUnicodeEscape);
javacc.setKeepLineColumn (this.keepLineColumn);
javacc.setLookAhead (this.lookAhead);
javacc.setOtherAmbiguityCheck (this.otherAmbiguityCheck);
javacc.setSanityCheck (this.sanityCheck);
javacc.setTokenManagerUsesParser (this.tokenManagerUsesParser);
javacc.setTokenExtends (this.tokenExtends);
javacc.setTokenFactory (this.tokenFactory);
javacc.setUnicodeInput (this.unicodeInput);
javacc.setUserCharStream (this.userCharStream);
javacc.setUserTokenManager (this.userTokenManager);
javacc.setSupportClassVisibilityPublic (this.supportClassVisibilityPublic);
javacc.setJavaTemplateType (this.javaTemplateType);
return javacc;
} | [
"protected",
"JavaCC",
"newJavaCC",
"(",
")",
"{",
"final",
"JavaCC",
"javacc",
"=",
"new",
"JavaCC",
"(",
")",
";",
"javacc",
".",
"setLog",
"(",
"getLog",
"(",
")",
")",
";",
"javacc",
".",
"setGrammarEncoding",
"(",
"this",
".",
"grammarEncoding",
")"... | Creates a new facade to invoke JavaCC. Most options for the invocation are
derived from the current values of the corresponding mojo parameters. The
caller is responsible to set the input file and output directory on the
returned facade.
@return The facade for the tool invocation, never <code>null</code>. | [
"Creates",
"a",
"new",
"facade",
"to",
"invoke",
"JavaCC",
".",
"Most",
"options",
"for",
"the",
"invocation",
"are",
"derived",
"from",
"the",
"current",
"values",
"of",
"the",
"corresponding",
"mojo",
"parameters",
".",
"The",
"caller",
"is",
"responsible",
... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java#L745-L777 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/UrlUtils.java | UrlUtils.getResourceRoot | public static File getResourceRoot (final URL url, final String resource)
{
String path = null;
if (url != null)
{
final String spec = url.toExternalForm ();
if ((JAR_FILE).regionMatches (true, 0, spec, 0, JAR_FILE.length ()))
{
URL jar;
try
{
jar = new URL (spec.substring (JAR.length (), spec.lastIndexOf ("!/")));
}
catch (final MalformedURLException e)
{
throw new IllegalArgumentException ("Invalid JAR URL: " + url + ", " + e.getMessage ());
}
path = decodeUrl (jar.getPath ());
}
else
if (FILE.regionMatches (true, 0, spec, 0, FILE.length ()))
{
path = decodeUrl (url.getPath ());
path = path.substring (0, path.length () - resource.length ());
}
else
{
throw new IllegalArgumentException ("Invalid class path URL: " + url);
}
}
return path != null ? new File (path) : null;
} | java | public static File getResourceRoot (final URL url, final String resource)
{
String path = null;
if (url != null)
{
final String spec = url.toExternalForm ();
if ((JAR_FILE).regionMatches (true, 0, spec, 0, JAR_FILE.length ()))
{
URL jar;
try
{
jar = new URL (spec.substring (JAR.length (), spec.lastIndexOf ("!/")));
}
catch (final MalformedURLException e)
{
throw new IllegalArgumentException ("Invalid JAR URL: " + url + ", " + e.getMessage ());
}
path = decodeUrl (jar.getPath ());
}
else
if (FILE.regionMatches (true, 0, spec, 0, FILE.length ()))
{
path = decodeUrl (url.getPath ());
path = path.substring (0, path.length () - resource.length ());
}
else
{
throw new IllegalArgumentException ("Invalid class path URL: " + url);
}
}
return path != null ? new File (path) : null;
} | [
"public",
"static",
"File",
"getResourceRoot",
"(",
"final",
"URL",
"url",
",",
"final",
"String",
"resource",
")",
"{",
"String",
"path",
"=",
"null",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"final",
"String",
"spec",
"=",
"url",
".",
"toExtern... | Gets the absolute filesystem path to the class path root for the specified
resource. The root is either a JAR file or a directory with loose class
files. If the URL does not use a supported protocol, an exception will be
thrown.
@param url
The URL to the resource, may be <code>null</code>.
@param resource
The name of the resource, must not be <code>null</code>.
@return The absolute filesystem path to the class path root of the resource
or <code>null</code> if the input URL was <code>null</code>. | [
"Gets",
"the",
"absolute",
"filesystem",
"path",
"to",
"the",
"class",
"path",
"root",
"for",
"the",
"specified",
"resource",
".",
"The",
"root",
"is",
"either",
"a",
"JAR",
"file",
"or",
"a",
"directory",
"with",
"loose",
"class",
"files",
".",
"If",
"t... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/UrlUtils.java#L70-L101 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JTBJavaCCMojo.java | JTBJavaCCMojo.newJTB | private JTB newJTB ()
{
final JTB jtb = new JTB ();
jtb.setLog (getLog ());
jtb.setDescriptiveFieldNames (this.descriptiveFieldNames);
jtb.setJavadocFriendlyComments (this.javadocFriendlyComments);
jtb.setNodeParentClass (this.nodeParentClass);
jtb.setParentPointers (this.parentPointers);
jtb.setPrinter (this.printer);
jtb.setScheme (this.scheme);
jtb.setSpecialTokens (this.specialTokens);
jtb.setSupressErrorChecking (this.supressErrorChecking);
return jtb;
} | java | private JTB newJTB ()
{
final JTB jtb = new JTB ();
jtb.setLog (getLog ());
jtb.setDescriptiveFieldNames (this.descriptiveFieldNames);
jtb.setJavadocFriendlyComments (this.javadocFriendlyComments);
jtb.setNodeParentClass (this.nodeParentClass);
jtb.setParentPointers (this.parentPointers);
jtb.setPrinter (this.printer);
jtb.setScheme (this.scheme);
jtb.setSpecialTokens (this.specialTokens);
jtb.setSupressErrorChecking (this.supressErrorChecking);
return jtb;
} | [
"private",
"JTB",
"newJTB",
"(",
")",
"{",
"final",
"JTB",
"jtb",
"=",
"new",
"JTB",
"(",
")",
";",
"jtb",
".",
"setLog",
"(",
"getLog",
"(",
")",
")",
";",
"jtb",
".",
"setDescriptiveFieldNames",
"(",
"this",
".",
"descriptiveFieldNames",
")",
";",
... | Creates a new facade to invoke JTB. Most options for the invocation are
derived from the current values of the corresponding mojo parameters. The
caller is responsible to set the input file, output directories and
packages on the returned facade.
@return The facade for the tool invocation, never <code>null</code>. | [
"Creates",
"a",
"new",
"facade",
"to",
"invoke",
"JTB",
".",
"Most",
"options",
"for",
"the",
"invocation",
"are",
"derived",
"from",
"the",
"current",
"values",
"of",
"the",
"corresponding",
"mojo",
"parameters",
".",
"The",
"caller",
"is",
"responsible",
"... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JTBJavaCCMojo.java#L401-L414 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java | GrammarDirectoryScanner.setSourceDirectory | public void setSourceDirectory (final File directory)
{
if (!directory.isAbsolute ())
{
throw new IllegalArgumentException ("source directory is not absolute: " + directory);
}
this.scanner.setBasedir (directory);
} | java | public void setSourceDirectory (final File directory)
{
if (!directory.isAbsolute ())
{
throw new IllegalArgumentException ("source directory is not absolute: " + directory);
}
this.scanner.setBasedir (directory);
} | [
"public",
"void",
"setSourceDirectory",
"(",
"final",
"File",
"directory",
")",
"{",
"if",
"(",
"!",
"directory",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"source directory is not absolute: \"",
"+",
"directory",
")... | Sets the absolute path to the source directory to scan for grammar files.
This directory must exist or the scanner will report an error.
@param directory
The absolute path to the source directory to scan, must not be
<code>null</code>. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"source",
"directory",
"to",
"scan",
"for",
"grammar",
"files",
".",
"This",
"directory",
"must",
"exist",
"or",
"the",
"scanner",
"will",
"report",
"an",
"error",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java#L90-L97 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java | GrammarDirectoryScanner.setOutputDirectory | public void setOutputDirectory (final File directory)
{
if (directory != null && !directory.isAbsolute ())
{
throw new IllegalArgumentException ("output directory is not absolute: " + directory);
}
this.outputDirectory = directory;
} | java | public void setOutputDirectory (final File directory)
{
if (directory != null && !directory.isAbsolute ())
{
throw new IllegalArgumentException ("output directory is not absolute: " + directory);
}
this.outputDirectory = directory;
} | [
"public",
"void",
"setOutputDirectory",
"(",
"final",
"File",
"directory",
")",
"{",
"if",
"(",
"directory",
"!=",
"null",
"&&",
"!",
"directory",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"output directory is not ... | Sets the absolute path to the output directory used to detect stale target
files.
@param directory
The absolute path to the output directory used to detect stale target
files by timestamp checking, may be <code>null</code> if no stale
detection should be performed. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"directory",
"used",
"to",
"detect",
"stale",
"target",
"files",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java#L145-L152 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java | GrammarDirectoryScanner.scan | public void scan () throws IOException
{
this.includedGrammars.clear ();
this.scanner.scan ();
final String [] includedFiles = this.scanner.getIncludedFiles ();
for (final String includedFile : includedFiles)
{
final GrammarInfo grammarInfo = new GrammarInfo (this.scanner.getBasedir (), includedFile, this.parserPackage);
if (this.outputDirectory != null)
{
final File sourceFile = grammarInfo.getGrammarFile ();
final File [] targetFiles = getTargetFiles (this.outputDirectory, includedFile, grammarInfo);
for (final File targetFile2 : targetFiles)
{
final File targetFile = targetFile2;
if (!targetFile.exists () || targetFile.lastModified () + this.staleMillis < sourceFile.lastModified ())
{
this.includedGrammars.add (grammarInfo);
break;
}
}
}
else
{
this.includedGrammars.add (grammarInfo);
}
}
} | java | public void scan () throws IOException
{
this.includedGrammars.clear ();
this.scanner.scan ();
final String [] includedFiles = this.scanner.getIncludedFiles ();
for (final String includedFile : includedFiles)
{
final GrammarInfo grammarInfo = new GrammarInfo (this.scanner.getBasedir (), includedFile, this.parserPackage);
if (this.outputDirectory != null)
{
final File sourceFile = grammarInfo.getGrammarFile ();
final File [] targetFiles = getTargetFiles (this.outputDirectory, includedFile, grammarInfo);
for (final File targetFile2 : targetFiles)
{
final File targetFile = targetFile2;
if (!targetFile.exists () || targetFile.lastModified () + this.staleMillis < sourceFile.lastModified ())
{
this.includedGrammars.add (grammarInfo);
break;
}
}
}
else
{
this.includedGrammars.add (grammarInfo);
}
}
} | [
"public",
"void",
"scan",
"(",
")",
"throws",
"IOException",
"{",
"this",
".",
"includedGrammars",
".",
"clear",
"(",
")",
";",
"this",
".",
"scanner",
".",
"scan",
"(",
")",
";",
"final",
"String",
"[",
"]",
"includedFiles",
"=",
"this",
".",
"scanner... | Scans the source directory for grammar files that match at least one
inclusion pattern but no exclusion pattern, optionally performing timestamp
checking to exclude grammars whose corresponding parser files are up to date.
@throws IOException
If a grammar file could not be analyzed for metadata. | [
"Scans",
"the",
"source",
"directory",
"for",
"grammar",
"files",
"that",
"match",
"at",
"least",
"one",
"inclusion",
"pattern",
"but",
"no",
"exclusion",
"pattern",
"optionally",
"performing",
"timestamp",
"checking",
"to",
"exclude",
"grammars",
"whose",
"corres... | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java#L176-L204 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java | GrammarDirectoryScanner.getTargetFiles | protected File [] getTargetFiles (final File targetDirectory, final String grammarFile, final GrammarInfo grammarInfo)
{
final File parserFile = new File (targetDirectory, grammarInfo.getParserFile ());
return new File [] { parserFile };
} | java | protected File [] getTargetFiles (final File targetDirectory, final String grammarFile, final GrammarInfo grammarInfo)
{
final File parserFile = new File (targetDirectory, grammarInfo.getParserFile ());
return new File [] { parserFile };
} | [
"protected",
"File",
"[",
"]",
"getTargetFiles",
"(",
"final",
"File",
"targetDirectory",
",",
"final",
"String",
"grammarFile",
",",
"final",
"GrammarInfo",
"grammarInfo",
")",
"{",
"final",
"File",
"parserFile",
"=",
"new",
"File",
"(",
"targetDirectory",
",",... | Determines the output files corresponding to the specified grammar file.
@param targetDirectory
The absolute path to the output directory for the target files, must
not be <code>null</code>.
@param grammarFile
The path to the grammar file, relative to the scanned source
directory, must not be <code>null</code>.
@param grammarInfo
The grammar info describing the grammar file, must not be
<code>null</code>
@return A file array with target files, never <code>null</code>. | [
"Determines",
"the",
"output",
"files",
"corresponding",
"to",
"the",
"specified",
"grammar",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java#L220-L224 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarInfo.java | GrammarInfo.findPackageName | private String findPackageName (final String grammar)
{
final String packageDeclaration = "package\\s+([^\\s.;]+(\\.[^\\s.;]+)*)\\s*;";
final Matcher matcher = Pattern.compile (packageDeclaration).matcher (grammar);
if (matcher.find ())
{
return matcher.group (1);
}
return "";
} | java | private String findPackageName (final String grammar)
{
final String packageDeclaration = "package\\s+([^\\s.;]+(\\.[^\\s.;]+)*)\\s*;";
final Matcher matcher = Pattern.compile (packageDeclaration).matcher (grammar);
if (matcher.find ())
{
return matcher.group (1);
}
return "";
} | [
"private",
"String",
"findPackageName",
"(",
"final",
"String",
"grammar",
")",
"{",
"final",
"String",
"packageDeclaration",
"=",
"\"package\\\\s+([^\\\\s.;]+(\\\\.[^\\\\s.;]+)*)\\\\s*;\"",
";",
"final",
"Matcher",
"matcher",
"=",
"Pattern",
".",
"compile",
"(",
"packa... | Extracts the declared package name from the specified grammar file.
@param grammar
The contents of the grammar file, must not be <code>null</code>.
@return The declared package name or an empty string if not found. | [
"Extracts",
"the",
"declared",
"package",
"name",
"from",
"the",
"specified",
"grammar",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarInfo.java#L171-L180 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/GrammarInfo.java | GrammarInfo.findParserName | private String findParserName (final String grammar)
{
final String parserBegin = "PARSER_BEGIN\\s*\\(\\s*([^\\s\\)]+)\\s*\\)";
final Matcher matcher = Pattern.compile (parserBegin).matcher (grammar);
if (matcher.find ())
{
return matcher.group (1);
}
return "";
} | java | private String findParserName (final String grammar)
{
final String parserBegin = "PARSER_BEGIN\\s*\\(\\s*([^\\s\\)]+)\\s*\\)";
final Matcher matcher = Pattern.compile (parserBegin).matcher (grammar);
if (matcher.find ())
{
return matcher.group (1);
}
return "";
} | [
"private",
"String",
"findParserName",
"(",
"final",
"String",
"grammar",
")",
"{",
"final",
"String",
"parserBegin",
"=",
"\"PARSER_BEGIN\\\\s*\\\\(\\\\s*([^\\\\s\\\\)]+)\\\\s*\\\\)\"",
";",
"final",
"Matcher",
"matcher",
"=",
"Pattern",
".",
"compile",
"(",
"parserBeg... | Extracts the simple parser name from the specified grammar file.
@param grammar
The contents of the grammar file, must not be <code>null</code>.
@return The parser name or an empty string if not found. | [
"Extracts",
"the",
"simple",
"parser",
"name",
"from",
"the",
"specified",
"grammar",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/GrammarInfo.java#L189-L198 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractToolFacade.java | AbstractToolFacade.getToolName | protected String getToolName ()
{
final String name = getClass ().getName ();
return name.substring (name.lastIndexOf ('.') + 1);
} | java | protected String getToolName ()
{
final String name = getClass ().getName ();
return name.substring (name.lastIndexOf ('.') + 1);
} | [
"protected",
"String",
"getToolName",
"(",
")",
"{",
"final",
"String",
"name",
"=",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"return",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"... | Gets the name of the tool.
@return The name of the tool, never <code>null</code>. | [
"Gets",
"the",
"name",
"of",
"the",
"tool",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractToolFacade.java#L81-L85 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/AbstractToolFacade.java | AbstractToolFacade.run | public void run () throws MojoExecutionException, MojoFailureException
{
ESuccess exitCode;
try
{
if (getLog ().isDebugEnabled ())
{
getLog ().debug ("Running " + getToolName () + ": " + this);
}
exitCode = execute ();
}
catch (final Exception e)
{
throw new MojoExecutionException ("Failed to execute " + getToolName (), e);
}
if (exitCode.isFailure ())
{
throw new MojoFailureException (getToolName () + " reported failure: " + this);
}
} | java | public void run () throws MojoExecutionException, MojoFailureException
{
ESuccess exitCode;
try
{
if (getLog ().isDebugEnabled ())
{
getLog ().debug ("Running " + getToolName () + ": " + this);
}
exitCode = execute ();
}
catch (final Exception e)
{
throw new MojoExecutionException ("Failed to execute " + getToolName (), e);
}
if (exitCode.isFailure ())
{
throw new MojoFailureException (getToolName () + " reported failure: " + this);
}
} | [
"public",
"void",
"run",
"(",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"ESuccess",
"exitCode",
";",
"try",
"{",
"if",
"(",
"getLog",
"(",
")",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
... | Runs the tool using the previously set parameters.
@throws MojoExecutionException
If the tool could not be invoked.
@throws MojoFailureException
If the tool reported a non-zero exit code. | [
"Runs",
"the",
"tool",
"using",
"the",
"previously",
"set",
"parameters",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/AbstractToolFacade.java#L105-L124 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDoc.java | JJDoc.setOutputFile | public void setOutputFile (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.outputFile = value;
} | java | public void setOutputFile (final File value)
{
if (value != null && !value.isAbsolute ())
{
throw new IllegalArgumentException ("path is not absolute: " + value);
}
this.outputFile = value;
} | [
"public",
"void",
"setOutputFile",
"(",
"final",
"File",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path is not absolute: \"",
"+",
"valu... | Sets the absolute path to the output file.
@param value
The absolute path to the HTML/text file to generate. | [
"Sets",
"the",
"absolute",
"path",
"to",
"the",
"output",
"file",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDoc.java#L104-L111 | train |
phax/ph-javacc-maven-plugin | src/main/java/org/codehaus/mojo/javacc/JJDoc.java | JJDoc._generateArguments | private String [] _generateArguments ()
{
final List <String> argsList = new ArrayList <> ();
if (StringUtils.isNotEmpty (this.grammarEncoding))
{
argsList.add ("-GRAMMAR_ENCODING=" + this.grammarEncoding);
}
if (StringUtils.isNotEmpty (this.outputEncoding))
{
argsList.add ("-OUTPUT_ENCODING=" + this.outputEncoding);
}
if (this.text != null)
{
argsList.add ("-TEXT=" + this.text);
}
if (this.bnf != null)
{
argsList.add ("-BNF=" + this.bnf);
}
if (this.oneTable != null)
{
argsList.add ("-ONE_TABLE=" + this.oneTable);
}
if (this.outputFile != null)
{
argsList.add ("-OUTPUT_FILE=" + this.outputFile.getAbsolutePath ());
}
if (StringUtils.isNotEmpty (this.cssHref))
{
argsList.add ("-CSS=" + this.cssHref);
}
if (this.inputFile != null)
{
argsList.add (this.inputFile.getAbsolutePath ());
}
return argsList.toArray (new String [argsList.size ()]);
} | java | private String [] _generateArguments ()
{
final List <String> argsList = new ArrayList <> ();
if (StringUtils.isNotEmpty (this.grammarEncoding))
{
argsList.add ("-GRAMMAR_ENCODING=" + this.grammarEncoding);
}
if (StringUtils.isNotEmpty (this.outputEncoding))
{
argsList.add ("-OUTPUT_ENCODING=" + this.outputEncoding);
}
if (this.text != null)
{
argsList.add ("-TEXT=" + this.text);
}
if (this.bnf != null)
{
argsList.add ("-BNF=" + this.bnf);
}
if (this.oneTable != null)
{
argsList.add ("-ONE_TABLE=" + this.oneTable);
}
if (this.outputFile != null)
{
argsList.add ("-OUTPUT_FILE=" + this.outputFile.getAbsolutePath ());
}
if (StringUtils.isNotEmpty (this.cssHref))
{
argsList.add ("-CSS=" + this.cssHref);
}
if (this.inputFile != null)
{
argsList.add (this.inputFile.getAbsolutePath ());
}
return argsList.toArray (new String [argsList.size ()]);
} | [
"private",
"String",
"[",
"]",
"_generateArguments",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"argsList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"this",
".",
"grammarEncoding",
")",
")",... | Assembles the command line arguments for the invocation of JJDoc according
to the configuration.
@return A string array that represents the arguments to use for JJDoc. | [
"Assembles",
"the",
"command",
"line",
"arguments",
"for",
"the",
"invocation",
"of",
"JJDoc",
"according",
"to",
"the",
"configuration",
"."
] | 99497a971fe59ab2289258ca7ddcfa40e651f19f | https://github.com/phax/ph-javacc-maven-plugin/blob/99497a971fe59ab2289258ca7ddcfa40e651f19f/src/main/java/org/codehaus/mojo/javacc/JJDoc.java#L217-L262 | train |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java | PowerAdapter.offset | @CheckResult
@NonNull
public final PowerAdapter offset(int offset) {
if (offset <= 0) {
return this;
}
if (offset == Integer.MAX_VALUE) {
return EMPTY;
}
return new OffsetAdapter(this, offset);
} | java | @CheckResult
@NonNull
public final PowerAdapter offset(int offset) {
if (offset <= 0) {
return this;
}
if (offset == Integer.MAX_VALUE) {
return EMPTY;
}
return new OffsetAdapter(this, offset);
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"final",
"PowerAdapter",
"offset",
"(",
"int",
"offset",
")",
"{",
"if",
"(",
"offset",
"<=",
"0",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"offset",
"==",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"... | Returns a new adapter that presents all items of this adapter, starting at the specified offset.
@param offset The item offset.
@return A new adapter. | [
"Returns",
"a",
"new",
"adapter",
"that",
"presents",
"all",
"items",
"of",
"this",
"adapter",
"starting",
"at",
"the",
"specified",
"offset",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java#L482-L492 | train |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java | PowerAdapter.limit | @CheckResult
@NonNull
public final PowerAdapter limit(int limit) {
if (limit == Integer.MAX_VALUE) {
return this;
}
if (limit <= 0) {
return EMPTY;
}
return new LimitAdapter(this, limit);
} | java | @CheckResult
@NonNull
public final PowerAdapter limit(int limit) {
if (limit == Integer.MAX_VALUE) {
return this;
}
if (limit <= 0) {
return EMPTY;
}
return new LimitAdapter(this, limit);
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"final",
"PowerAdapter",
"limit",
"(",
"int",
"limit",
")",
"{",
"if",
"(",
"limit",
"==",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"limit",
"<=",
"0",
")",
"{",
"retu... | Returns a new adapter that presents all items of this adapter, up until the specified limit.
@param limit The item limit.
@return A new adapter. | [
"Returns",
"a",
"new",
"adapter",
"that",
"presents",
"all",
"items",
"of",
"this",
"adapter",
"up",
"until",
"the",
"specified",
"limit",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/PowerAdapter.java#L499-L509 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/widget/DataLayout.java | DataLayout.shouldAnimate | private boolean shouldAnimate() {
if (!mAnimationEnabled) {
return false;
}
Display display = currentDisplay();
if (display == null) {
return false;
}
if (mVisibleStartTime <= 0) {
return false;
}
long threshold = (long) (1000 / display.getRefreshRate());
long millisVisible = elapsedRealtime() - mVisibleStartTime;
return millisVisible > threshold;
} | java | private boolean shouldAnimate() {
if (!mAnimationEnabled) {
return false;
}
Display display = currentDisplay();
if (display == null) {
return false;
}
if (mVisibleStartTime <= 0) {
return false;
}
long threshold = (long) (1000 / display.getRefreshRate());
long millisVisible = elapsedRealtime() - mVisibleStartTime;
return millisVisible > threshold;
} | [
"private",
"boolean",
"shouldAnimate",
"(",
")",
"{",
"if",
"(",
"!",
"mAnimationEnabled",
")",
"{",
"return",
"false",
";",
"}",
"Display",
"display",
"=",
"currentDisplay",
"(",
")",
";",
"if",
"(",
"display",
"==",
"null",
")",
"{",
"return",
"false",... | Returns whether now is an appropriate time to perform animations. | [
"Returns",
"whether",
"now",
"is",
"an",
"appropriate",
"time",
"to",
"perform",
"animations",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/widget/DataLayout.java#L733-L747 | train |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/Condition.java | Condition.notifyChanged | protected final void notifyChanged() {
for (int i = mObservers.size() - 1; i >= 0; i--) {
mObservers.get(i).onChanged();
}
} | java | protected final void notifyChanged() {
for (int i = mObservers.size() - 1; i >= 0; i--) {
mObservers.get(i).onChanged();
}
} | [
"protected",
"final",
"void",
"notifyChanged",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"mObservers",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"mObservers",
".",
"get",
"(",
"i",
")",
".",
"onChanged",
... | Notify observers that the condition has changed. | [
"Notify",
"observers",
"that",
"the",
"condition",
"has",
"changed",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/Condition.java#L36-L40 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/Data.java | Data.notifyError | protected final void notifyError(@NonNull final Throwable e) {
//noinspection ThrowableResultOfMethodCallIgnored
checkNotNull(e, "e");
runOnUiThread(new Runnable() {
@Override
public void run() {
mErrorObservable.notifyError(e);
}
});
} | java | protected final void notifyError(@NonNull final Throwable e) {
//noinspection ThrowableResultOfMethodCallIgnored
checkNotNull(e, "e");
runOnUiThread(new Runnable() {
@Override
public void run() {
mErrorObservable.notifyError(e);
}
});
} | [
"protected",
"final",
"void",
"notifyError",
"(",
"@",
"NonNull",
"final",
"Throwable",
"e",
")",
"{",
"//noinspection ThrowableResultOfMethodCallIgnored",
"checkNotNull",
"(",
"e",
",",
"\"e\"",
")",
";",
"runOnUiThread",
"(",
"new",
"Runnable",
"(",
")",
"{",
... | Dispatch an error notification on the UI thread. | [
"Dispatch",
"an",
"error",
"notification",
"on",
"the",
"UI",
"thread",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/Data.java#L420-L429 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/Data.java | Data.filter | @CheckResult
@NonNull
public final <O> Data<O> filter(@NonNull final Class<O> type) {
//noinspection unchecked
return (Data<O>) new FilterData<>(this, new Predicate<Object>() {
@Override
public boolean apply(Object o) {
return type.isInstance(o);
}
});
} | java | @CheckResult
@NonNull
public final <O> Data<O> filter(@NonNull final Class<O> type) {
//noinspection unchecked
return (Data<O>) new FilterData<>(this, new Predicate<Object>() {
@Override
public boolean apply(Object o) {
return type.isInstance(o);
}
});
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"final",
"<",
"O",
">",
"Data",
"<",
"O",
">",
"filter",
"(",
"@",
"NonNull",
"final",
"Class",
"<",
"O",
">",
"type",
")",
"{",
"//noinspection unchecked",
"return",
"(",
"Data",
"<",
"O",
">",
")",
"new... | Filter this data by class. The resulting elements are guaranteed to be of the given type. | [
"Filter",
"this",
"data",
"by",
"class",
".",
"The",
"resulting",
"elements",
"are",
"guaranteed",
"to",
"be",
"of",
"the",
"given",
"type",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/Data.java#L457-L467 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/IncrementalArrayData.java | IncrementalArrayData.loadLoop | private void loadLoop() throws InterruptedException {
boolean firstItem = true;
boolean moreAvailable = true;
// Loop until all loaded.
while (moreAvailable) {
// Thread interruptions terminate the loop.
if (currentThread().isInterrupted()) {
throw new InterruptedException();
}
try {
setLoading(true);
// Load next increment of items.
final Result<? extends T> result = load();
moreAvailable = result != null && result.getRemaining() > 0;
setAvailable(result != null ? result.getRemaining() : 0);
// If invalidated while shown, we lazily clear the data so the user doesn't see blank data while loading.
final boolean needToClear = firstItem;
firstItem = false;
runOnUiThread(new Runnable() {
@Override
public void run() {
List<? extends T> elements =
result != null ? result.getElements() : Collections.<T>emptyList();
if (needToClear) {
overwriteResult(elements);
} else {
appendResult(elements);
}
setLoading(false);
}
});
} catch (InterruptedException e) {
throw e;
} catch (InterruptedIOException e) {
InterruptedException interruptedException = new InterruptedException();
interruptedException.initCause(e);
throw interruptedException;
} catch (final Throwable e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
notifyError(e);
}
});
mError = true;
setLoading(false);
}
// Block until instructed to continue, even if an error occurred.
// In this case, loading must be explicitly resumed.
block();
}
} | java | private void loadLoop() throws InterruptedException {
boolean firstItem = true;
boolean moreAvailable = true;
// Loop until all loaded.
while (moreAvailable) {
// Thread interruptions terminate the loop.
if (currentThread().isInterrupted()) {
throw new InterruptedException();
}
try {
setLoading(true);
// Load next increment of items.
final Result<? extends T> result = load();
moreAvailable = result != null && result.getRemaining() > 0;
setAvailable(result != null ? result.getRemaining() : 0);
// If invalidated while shown, we lazily clear the data so the user doesn't see blank data while loading.
final boolean needToClear = firstItem;
firstItem = false;
runOnUiThread(new Runnable() {
@Override
public void run() {
List<? extends T> elements =
result != null ? result.getElements() : Collections.<T>emptyList();
if (needToClear) {
overwriteResult(elements);
} else {
appendResult(elements);
}
setLoading(false);
}
});
} catch (InterruptedException e) {
throw e;
} catch (InterruptedIOException e) {
InterruptedException interruptedException = new InterruptedException();
interruptedException.initCause(e);
throw interruptedException;
} catch (final Throwable e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
notifyError(e);
}
});
mError = true;
setLoading(false);
}
// Block until instructed to continue, even if an error occurred.
// In this case, loading must be explicitly resumed.
block();
}
} | [
"private",
"void",
"loadLoop",
"(",
")",
"throws",
"InterruptedException",
"{",
"boolean",
"firstItem",
"=",
"true",
";",
"boolean",
"moreAvailable",
"=",
"true",
";",
"// Loop until all loaded.",
"while",
"(",
"moreAvailable",
")",
"{",
"// Thread interruptions termi... | Loads each increment until full range has been loading, halting in between increment until instructed to
proceed. | [
"Loads",
"each",
"increment",
"until",
"full",
"range",
"has",
"been",
"loading",
"halting",
"in",
"between",
"increment",
"until",
"instructed",
"to",
"proceed",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/IncrementalArrayData.java#L228-L283 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/CursorData.java | CursorData.updateCursorObserver | private void updateCursorObserver() {
Cursor newObservedCursor = getDataObserverCount() > 0 ? mCursor : null;
if (newObservedCursor != mObservedCursor) {
if (mObservedCursor != null) {
mObservedCursor.unregisterContentObserver(mCursorContentObserver);
}
mObservedCursor = newObservedCursor;
if (mObservedCursor != null) {
mObservedCursor.registerContentObserver(mCursorContentObserver);
}
}
} | java | private void updateCursorObserver() {
Cursor newObservedCursor = getDataObserverCount() > 0 ? mCursor : null;
if (newObservedCursor != mObservedCursor) {
if (mObservedCursor != null) {
mObservedCursor.unregisterContentObserver(mCursorContentObserver);
}
mObservedCursor = newObservedCursor;
if (mObservedCursor != null) {
mObservedCursor.registerContentObserver(mCursorContentObserver);
}
}
} | [
"private",
"void",
"updateCursorObserver",
"(",
")",
"{",
"Cursor",
"newObservedCursor",
"=",
"getDataObserverCount",
"(",
")",
">",
"0",
"?",
"mCursor",
":",
"null",
";",
"if",
"(",
"newObservedCursor",
"!=",
"mObservedCursor",
")",
"{",
"if",
"(",
"mObserved... | Registers or unregisters with the cursor. Idempotent. | [
"Registers",
"or",
"unregisters",
"with",
"the",
"cursor",
".",
"Idempotent",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/CursorData.java#L208-L219 | train |
NextFaze/power-adapters | power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/CursorData.java | CursorData.closeCursor | private void closeCursor() {
if (mCursor != null) {
int count = mCursor.getCount();
mCursor.close();
mCursor = null;
notifyItemRangeRemoved(0, count);
}
updateCursorObserver();
} | java | private void closeCursor() {
if (mCursor != null) {
int count = mCursor.getCount();
mCursor.close();
mCursor = null;
notifyItemRangeRemoved(0, count);
}
updateCursorObserver();
} | [
"private",
"void",
"closeCursor",
"(",
")",
"{",
"if",
"(",
"mCursor",
"!=",
"null",
")",
"{",
"int",
"count",
"=",
"mCursor",
".",
"getCount",
"(",
")",
";",
"mCursor",
".",
"close",
"(",
")",
";",
"mCursor",
"=",
"null",
";",
"notifyItemRangeRemoved"... | Closes the cursor, notifying observers of data changes as necessary. | [
"Closes",
"the",
"cursor",
"notifying",
"observers",
"of",
"data",
"changes",
"as",
"necessary",
"."
] | cdf00b1b723ed9d6bcd549ae9741a19dd59651e1 | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters-data/src/main/java/com/nextfaze/poweradapters/data/CursorData.java#L222-L230 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java | XmlPrintStream.printElement | public void printElement(String elementName, Object value) {
println("<" + elementName + ">" + (value == null ? "" : escape(value.toString())) + "</" + elementName + ">");
} | java | public void printElement(String elementName, Object value) {
println("<" + elementName + ">" + (value == null ? "" : escape(value.toString())) + "</" + elementName + ">");
} | [
"public",
"void",
"printElement",
"(",
"String",
"elementName",
",",
"Object",
"value",
")",
"{",
"println",
"(",
"\"<\"",
"+",
"elementName",
"+",
"\">\"",
"+",
"(",
"value",
"==",
"null",
"?",
"\"\"",
":",
"escape",
"(",
"value",
".",
"toString",
"(",
... | Output a complete element with the given content.
@param elementName Name of element.
@param value Content of element. | [
"Output",
"a",
"complete",
"element",
"with",
"the",
"given",
"content",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java#L109-L111 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java | XmlPrintStream.printElement | public void printElement(String elementName, String value, Map<String, String> attributes) {
print("<" + elementName);
for (Entry<String, String> entry : attributes.entrySet()) {
print(" " + entry.getKey() + "=\"" + escape(entry.getValue()) + "\"");
}
if (value != null) {
println(">" + escape(value) + "</" + elementName + ">");
} else {
println("/>");
}
} | java | public void printElement(String elementName, String value, Map<String, String> attributes) {
print("<" + elementName);
for (Entry<String, String> entry : attributes.entrySet()) {
print(" " + entry.getKey() + "=\"" + escape(entry.getValue()) + "\"");
}
if (value != null) {
println(">" + escape(value) + "</" + elementName + ">");
} else {
println("/>");
}
} | [
"public",
"void",
"printElement",
"(",
"String",
"elementName",
",",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"print",
"(",
"\"<\"",
"+",
"elementName",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
... | Output a complete element with the given content and attributes.
@param elementName Name of element.
@param value Content of element.
@param attributes A map of name value pairs which will be used to add attributes to
the element. | [
"Output",
"a",
"complete",
"element",
"with",
"the",
"given",
"content",
"and",
"attributes",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java#L133-L145 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java | XmlPrintStream.escape | public String escape(String in) {
StringBuffer out = new StringBuffer();
for (char c : in.toCharArray()) {
switch (c) {
case '<':
out.append("<");
break;
case '>':
out.append(">");
break;
case '&':
out.append("&");
break;
case '"':
out.append(""");
break;
default:
out.append(c);
}
}
return out.toString();
} | java | public String escape(String in) {
StringBuffer out = new StringBuffer();
for (char c : in.toCharArray()) {
switch (c) {
case '<':
out.append("<");
break;
case '>':
out.append(">");
break;
case '&':
out.append("&");
break;
case '"':
out.append(""");
break;
default:
out.append(c);
}
}
return out.toString();
} | [
"public",
"String",
"escape",
"(",
"String",
"in",
")",
"{",
"StringBuffer",
"out",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"char",
"c",
":",
"in",
".",
"toCharArray",
"(",
")",
")",
"{",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
... | Translate reserved XML characters to XML entities.
@param in Input string. | [
"Translate",
"reserved",
"XML",
"characters",
"to",
"XML",
"entities",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java#L167-L190 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java | XmlPrintStream.removeNewLines | public static String removeNewLines(String textContent) {
if (textContent == null) {
return "";
}
StringBuilder s = new StringBuilder();
boolean inNl = false;
for (char c : textContent.toCharArray()) {
if (c == '\n') {
if (!inNl) {
s.append(' ');
inNl = true;
}
} else {
inNl = false;
s.append(c);
}
}
return s.toString();
} | java | public static String removeNewLines(String textContent) {
if (textContent == null) {
return "";
}
StringBuilder s = new StringBuilder();
boolean inNl = false;
for (char c : textContent.toCharArray()) {
if (c == '\n') {
if (!inNl) {
s.append(' ');
inNl = true;
}
} else {
inNl = false;
s.append(c);
}
}
return s.toString();
} | [
"public",
"static",
"String",
"removeNewLines",
"(",
"String",
"textContent",
")",
"{",
"if",
"(",
"textContent",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"inNl",
"=",
... | Replace multiple newline characters with a single space.
@param textContent input String | [
"Replace",
"multiple",
"newline",
"characters",
"with",
"a",
"single",
"space",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/util/XmlPrintStream.java#L196-L216 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java | Element.buildAll | public void buildAll(MessageMLParser context, org.w3c.dom.Element element) throws InvalidInputException,
ProcessingException {
NamedNodeMap attr = element.getAttributes();
for (int i = 0; i < attr.getLength(); i++) {
buildAttribute(attr.item(i));
}
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
buildNode(context, children.item(i));
}
} | java | public void buildAll(MessageMLParser context, org.w3c.dom.Element element) throws InvalidInputException,
ProcessingException {
NamedNodeMap attr = element.getAttributes();
for (int i = 0; i < attr.getLength(); i++) {
buildAttribute(attr.item(i));
}
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
buildNode(context, children.item(i));
}
} | [
"public",
"void",
"buildAll",
"(",
"MessageMLParser",
"context",
",",
"org",
".",
"w3c",
".",
"dom",
".",
"Element",
"element",
")",
"throws",
"InvalidInputException",
",",
"ProcessingException",
"{",
"NamedNodeMap",
"attr",
"=",
"element",
".",
"getAttributes",
... | Process a DOM element, descending into its children, and construct the output MessageML tree. | [
"Process",
"a",
"DOM",
"element",
"descending",
"into",
"its",
"children",
"and",
"construct",
"the",
"output",
"MessageML",
"tree",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java#L80-L93 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java | Element.buildAttribute | void buildAttribute(org.w3c.dom.Node item) throws InvalidInputException {
switch (item.getNodeName()) {
case CLASS_ATTR:
attributes.put(CLASS_ATTR, getStringAttribute(item));
break;
case STYLE_ATTR:
final String styleAttribute = getStringAttribute(item);
Styles.validate(styleAttribute);
attributes.put(STYLE_ATTR, styleAttribute);
break;
default:
throw new InvalidInputException("Attribute \"" + item.getNodeName()
+ "\" is not allowed in \"" + getMessageMLTag() + "\"");
}
} | java | void buildAttribute(org.w3c.dom.Node item) throws InvalidInputException {
switch (item.getNodeName()) {
case CLASS_ATTR:
attributes.put(CLASS_ATTR, getStringAttribute(item));
break;
case STYLE_ATTR:
final String styleAttribute = getStringAttribute(item);
Styles.validate(styleAttribute);
attributes.put(STYLE_ATTR, styleAttribute);
break;
default:
throw new InvalidInputException("Attribute \"" + item.getNodeName()
+ "\" is not allowed in \"" + getMessageMLTag() + "\"");
}
} | [
"void",
"buildAttribute",
"(",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"item",
")",
"throws",
"InvalidInputException",
"{",
"switch",
"(",
"item",
".",
"getNodeName",
"(",
")",
")",
"{",
"case",
"CLASS_ATTR",
":",
"attributes",
".",
"put",
"(",
"CLAS... | Parse a DOM attribute into MessageML element properties. | [
"Parse",
"a",
"DOM",
"attribute",
"into",
"MessageML",
"element",
"properties",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java#L98-L112 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java | Element.buildNode | private void buildNode(MessageMLParser context, org.w3c.dom.Node node) throws InvalidInputException, ProcessingException {
switch (node.getNodeType()) {
case org.w3c.dom.Node.TEXT_NODE:
buildText((Text) node);
break;
case org.w3c.dom.Node.ELEMENT_NODE:
buildElement(context, (org.w3c.dom.Element) node);
break;
default:
throw new InvalidInputException("Invalid element \"" + node.getNodeName() + "\"");
}
} | java | private void buildNode(MessageMLParser context, org.w3c.dom.Node node) throws InvalidInputException, ProcessingException {
switch (node.getNodeType()) {
case org.w3c.dom.Node.TEXT_NODE:
buildText((Text) node);
break;
case org.w3c.dom.Node.ELEMENT_NODE:
buildElement(context, (org.w3c.dom.Element) node);
break;
default:
throw new InvalidInputException("Invalid element \"" + node.getNodeName() + "\"");
}
} | [
"private",
"void",
"buildNode",
"(",
"MessageMLParser",
"context",
",",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"node",
")",
"throws",
"InvalidInputException",
",",
"ProcessingException",
"{",
"switch",
"(",
"node",
".",
"getNodeType",
"(",
")",
")",
"{"... | Build a text node or a MessageML element based on the provided DOM node. | [
"Build",
"a",
"text",
"node",
"or",
"a",
"MessageML",
"element",
"based",
"on",
"the",
"provided",
"DOM",
"node",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java#L117-L131 | train |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java | Element.buildElement | private void buildElement(MessageMLParser context, org.w3c.dom.Element element) throws InvalidInputException,
ProcessingException {
Element child = context.createElement(element, this);
child.buildAll(context, element);
child.validate();
addChild(child);
} | java | private void buildElement(MessageMLParser context, org.w3c.dom.Element element) throws InvalidInputException,
ProcessingException {
Element child = context.createElement(element, this);
child.buildAll(context, element);
child.validate();
addChild(child);
} | [
"private",
"void",
"buildElement",
"(",
"MessageMLParser",
"context",
",",
"org",
".",
"w3c",
".",
"dom",
".",
"Element",
"element",
")",
"throws",
"InvalidInputException",
",",
"ProcessingException",
"{",
"Element",
"child",
"=",
"context",
".",
"createElement",
... | Build a MessageML element based on the provided DOM element and descend into its children. | [
"Build",
"a",
"MessageML",
"element",
"based",
"on",
"the",
"provided",
"DOM",
"element",
"and",
"descend",
"into",
"its",
"children",
"."
] | 68daed66267062d144a05b3ee9a9bf4b715e3f95 | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java#L136-L142 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.