id
int32 0
165k
| 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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,100 | fernandospr/javapns-jdk16 | src/main/java/javapns/communication/KeystoreManager.java | KeystoreManager.verifyKeystoreContent | public static void verifyKeystoreContent(AppleServer server, Object keystore) throws KeystoreException {
KeyStore keystoreToValidate = null;
if (keystore instanceof KeyStore) keystoreToValidate = (KeyStore) keystore;
else keystoreToValidate = loadKeystore(server, keystore);
verifyKeystoreContent(keystoreToValidate);
} | java | public static void verifyKeystoreContent(AppleServer server, Object keystore) throws KeystoreException {
KeyStore keystoreToValidate = null;
if (keystore instanceof KeyStore) keystoreToValidate = (KeyStore) keystore;
else keystoreToValidate = loadKeystore(server, keystore);
verifyKeystoreContent(keystoreToValidate);
} | [
"public",
"static",
"void",
"verifyKeystoreContent",
"(",
"AppleServer",
"server",
",",
"Object",
"keystore",
")",
"throws",
"KeystoreException",
"{",
"KeyStore",
"keystoreToValidate",
"=",
"null",
";",
"if",
"(",
"keystore",
"instanceof",
"KeyStore",
")",
"keystoreToValidate",
"=",
"(",
"KeyStore",
")",
"keystore",
";",
"else",
"keystoreToValidate",
"=",
"loadKeystore",
"(",
"server",
",",
"keystore",
")",
";",
"verifyKeystoreContent",
"(",
"keystoreToValidate",
")",
";",
"}"
] | Perform basic tests on a keystore to detect common user mistakes.
If a problem is found, a KeystoreException is thrown.
If no problem is found, this method simply returns without exceptions.
@param server the server the keystore is intended for
@param keystore a keystore containing your private key and the certificate signed by Apple (File, InputStream, byte[], KeyStore or String for a file path)
@throws KeystoreException | [
"Perform",
"basic",
"tests",
"on",
"a",
"keystore",
"to",
"detect",
"common",
"user",
"mistakes",
".",
"If",
"a",
"problem",
"is",
"found",
"a",
"KeystoreException",
"is",
"thrown",
".",
"If",
"no",
"problem",
"is",
"found",
"this",
"method",
"simply",
"returns",
"without",
"exceptions",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/communication/KeystoreManager.java#L101-L106 |
2,101 | fernandospr/javapns-jdk16 | src/main/java/javapns/communication/KeystoreManager.java | KeystoreManager.validateKeystoreParameter | public static void validateKeystoreParameter(Object keystore) throws InvalidKeystoreReferenceException {
if (keystore == null) throw new InvalidKeystoreReferenceException((Object) null);
if (keystore instanceof KeyStore) return;
if (keystore instanceof InputStream) return;
if (keystore instanceof String) keystore = new File((String) keystore);
if (keystore instanceof File) {
File file = (File) keystore;
if (!file.exists()) throw new InvalidKeystoreReferenceException("Invalid keystore reference. File does not exist: " + file.getAbsolutePath());
if (!file.isFile()) throw new InvalidKeystoreReferenceException("Invalid keystore reference. Path does not refer to a valid file: " + file.getAbsolutePath());
if (file.length() <= 0) throw new InvalidKeystoreReferenceException("Invalid keystore reference. File is empty: " + file.getAbsolutePath());
return;
}
if (keystore instanceof byte[]) {
byte[] bytes = (byte[]) keystore;
if (bytes.length == 0) throw new InvalidKeystoreReferenceException("Invalid keystore reference. Byte array is empty");
return;
} | java | public static void validateKeystoreParameter(Object keystore) throws InvalidKeystoreReferenceException {
if (keystore == null) throw new InvalidKeystoreReferenceException((Object) null);
if (keystore instanceof KeyStore) return;
if (keystore instanceof InputStream) return;
if (keystore instanceof String) keystore = new File((String) keystore);
if (keystore instanceof File) {
File file = (File) keystore;
if (!file.exists()) throw new InvalidKeystoreReferenceException("Invalid keystore reference. File does not exist: " + file.getAbsolutePath());
if (!file.isFile()) throw new InvalidKeystoreReferenceException("Invalid keystore reference. Path does not refer to a valid file: " + file.getAbsolutePath());
if (file.length() <= 0) throw new InvalidKeystoreReferenceException("Invalid keystore reference. File is empty: " + file.getAbsolutePath());
return;
}
if (keystore instanceof byte[]) {
byte[] bytes = (byte[]) keystore;
if (bytes.length == 0) throw new InvalidKeystoreReferenceException("Invalid keystore reference. Byte array is empty");
return;
} | [
"public",
"static",
"void",
"validateKeystoreParameter",
"(",
"Object",
"keystore",
")",
"throws",
"InvalidKeystoreReferenceException",
"{",
"if",
"(",
"keystore",
"==",
"null",
")",
"throw",
"new",
"InvalidKeystoreReferenceException",
"(",
"(",
"Object",
")",
"null",
")",
";",
"if",
"(",
"keystore",
"instanceof",
"KeyStore",
")",
"return",
";",
"if",
"(",
"keystore",
"instanceof",
"InputStream",
")",
"return",
";",
"if",
"(",
"keystore",
"instanceof",
"String",
")",
"keystore",
"=",
"new",
"File",
"(",
"(",
"String",
")",
"keystore",
")",
";",
"if",
"(",
"keystore",
"instanceof",
"File",
")",
"{",
"File",
"file",
"=",
"(",
"File",
")",
"keystore",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"InvalidKeystoreReferenceException",
"(",
"\"Invalid keystore reference. File does not exist: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"!",
"file",
".",
"isFile",
"(",
")",
")",
"throw",
"new",
"InvalidKeystoreReferenceException",
"(",
"\"Invalid keystore reference. Path does not refer to a valid file: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"file",
".",
"length",
"(",
")",
"<=",
"0",
")",
"throw",
"new",
"InvalidKeystoreReferenceException",
"(",
"\"Invalid keystore reference. File is empty: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"keystore",
"instanceof",
"byte",
"[",
"]",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"(",
"byte",
"[",
"]",
")",
"keystore",
";",
"if",
"(",
"bytes",
".",
"length",
"==",
"0",
")",
"throw",
"new",
"InvalidKeystoreReferenceException",
"(",
"\"Invalid keystore reference. Byte array is empty\"",
")",
";",
"return",
";",
"}"
] | Ensures that a keystore parameter is actually supported by the KeystoreManager.
@param keystore a keystore containing your private key and the certificate signed by Apple (File, InputStream, byte[], KeyStore or String for a file path)
@throws InvalidKeystoreReferenceException thrown if the provided keystore parameter is not supported | [
"Ensures",
"that",
"a",
"keystore",
"parameter",
"is",
"actually",
"supported",
"by",
"the",
"KeystoreManager",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/communication/KeystoreManager.java#L212-L228 |
2,102 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.addCustomDictionary | public void addCustomDictionary(String name, String value) throws JSONException {
logger.debug("Adding custom Dictionary [" + name + "] = [" + value + "]");
put(name, value, payload, false);
} | java | public void addCustomDictionary(String name, String value) throws JSONException {
logger.debug("Adding custom Dictionary [" + name + "] = [" + value + "]");
put(name, value, payload, false);
} | [
"public",
"void",
"addCustomDictionary",
"(",
"String",
"name",
",",
"String",
"value",
")",
"throws",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding custom Dictionary [\"",
"+",
"name",
"+",
"\"] = [\"",
"+",
"value",
"+",
"\"]\"",
")",
";",
"put",
"(",
"name",
",",
"value",
",",
"payload",
",",
"false",
")",
";",
"}"
] | Add a custom dictionnary with a string value
@param name
@param value
@throws JSONException | [
"Add",
"a",
"custom",
"dictionnary",
"with",
"a",
"string",
"value"
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L77-L80 |
2,103 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.addCustomDictionary | public void addCustomDictionary(String name, List values) throws JSONException {
logger.debug("Adding custom Dictionary [" + name + "] = (list)");
put(name, values, payload, false);
} | java | public void addCustomDictionary(String name, List values) throws JSONException {
logger.debug("Adding custom Dictionary [" + name + "] = (list)");
put(name, values, payload, false);
} | [
"public",
"void",
"addCustomDictionary",
"(",
"String",
"name",
",",
"List",
"values",
")",
"throws",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding custom Dictionary [\"",
"+",
"name",
"+",
"\"] = (list)\"",
")",
";",
"put",
"(",
"name",
",",
"values",
",",
"payload",
",",
"false",
")",
";",
"}"
] | Add a custom dictionnary with multiple values
@param name
@param values
@throws JSONException | [
"Add",
"a",
"custom",
"dictionnary",
"with",
"multiple",
"values"
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L101-L104 |
2,104 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.getPayloadAsBytesUnchecked | private byte[] getPayloadAsBytesUnchecked() throws Exception {
byte[] bytes = null;
try {
bytes = toString().getBytes(characterEncoding);
} catch (Exception ex) {
bytes = toString().getBytes();
}
return bytes;
} | java | private byte[] getPayloadAsBytesUnchecked() throws Exception {
byte[] bytes = null;
try {
bytes = toString().getBytes(characterEncoding);
} catch (Exception ex) {
bytes = toString().getBytes();
}
return bytes;
} | [
"private",
"byte",
"[",
"]",
"getPayloadAsBytesUnchecked",
"(",
")",
"throws",
"Exception",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"null",
";",
"try",
"{",
"bytes",
"=",
"toString",
"(",
")",
".",
"getBytes",
"(",
"characterEncoding",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"bytes",
"=",
"toString",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"}",
"return",
"bytes",
";",
"}"
] | Get this payload as a byte array using the preconfigured character encoding.
This method does NOT check if the payload exceeds the maximum payload length.
@return byte[] bytes ready to be streamed directly to Apple servers (but that might exceed the maximum size limit) | [
"Get",
"this",
"payload",
"as",
"a",
"byte",
"array",
"using",
"the",
"preconfigured",
"character",
"encoding",
".",
"This",
"method",
"does",
"NOT",
"check",
"if",
"the",
"payload",
"exceeds",
"the",
"maximum",
"payload",
"length",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L151-L159 |
2,105 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.estimatePayloadSizeAfterAdding | public int estimatePayloadSizeAfterAdding(String propertyName, Object propertyValue) {
try {
int maximumPayloadSize = getMaximumPayloadSize();
int currentPayloadSize = getPayloadAsBytesUnchecked().length;
int estimatedSize = currentPayloadSize;
if (propertyName != null && propertyValue != null) {
estimatedSize += 5; // "":""
estimatedSize += propertyName.getBytes(getCharacterEncoding()).length;
int estimatedValueSize = 0;
if (propertyValue instanceof String || propertyValue instanceof Number) estimatedValueSize = propertyValue.toString().getBytes(getCharacterEncoding()).length;
estimatedSize += estimatedValueSize;
}
return estimatedSize;
} catch (Exception e) {
try {
return getPayloadSize();
} catch (Exception e1) {
return 0;
}
}
} | java | public int estimatePayloadSizeAfterAdding(String propertyName, Object propertyValue) {
try {
int maximumPayloadSize = getMaximumPayloadSize();
int currentPayloadSize = getPayloadAsBytesUnchecked().length;
int estimatedSize = currentPayloadSize;
if (propertyName != null && propertyValue != null) {
estimatedSize += 5; // "":""
estimatedSize += propertyName.getBytes(getCharacterEncoding()).length;
int estimatedValueSize = 0;
if (propertyValue instanceof String || propertyValue instanceof Number) estimatedValueSize = propertyValue.toString().getBytes(getCharacterEncoding()).length;
estimatedSize += estimatedValueSize;
}
return estimatedSize;
} catch (Exception e) {
try {
return getPayloadSize();
} catch (Exception e1) {
return 0;
}
}
} | [
"public",
"int",
"estimatePayloadSizeAfterAdding",
"(",
"String",
"propertyName",
",",
"Object",
"propertyValue",
")",
"{",
"try",
"{",
"int",
"maximumPayloadSize",
"=",
"getMaximumPayloadSize",
"(",
")",
";",
"int",
"currentPayloadSize",
"=",
"getPayloadAsBytesUnchecked",
"(",
")",
".",
"length",
";",
"int",
"estimatedSize",
"=",
"currentPayloadSize",
";",
"if",
"(",
"propertyName",
"!=",
"null",
"&&",
"propertyValue",
"!=",
"null",
")",
"{",
"estimatedSize",
"+=",
"5",
";",
"// \"\":\"\"",
"estimatedSize",
"+=",
"propertyName",
".",
"getBytes",
"(",
"getCharacterEncoding",
"(",
")",
")",
".",
"length",
";",
"int",
"estimatedValueSize",
"=",
"0",
";",
"if",
"(",
"propertyValue",
"instanceof",
"String",
"||",
"propertyValue",
"instanceof",
"Number",
")",
"estimatedValueSize",
"=",
"propertyValue",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"getCharacterEncoding",
"(",
")",
")",
".",
"length",
";",
"estimatedSize",
"+=",
"estimatedValueSize",
";",
"}",
"return",
"estimatedSize",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"try",
"{",
"return",
"getPayloadSize",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"return",
"0",
";",
"}",
"}",
"}"
] | Estimate the size that this payload will take after adding a given property.
For performance reasons, this estimate is not as reliable as actually adding
the property and checking the payload size afterwards.
Currently works well with strings and numbers.
@param propertyName the name of the property to use for calculating the estimation
@param propertyValue the value of the property to use for calculating the estimation
@return an estimated payload size if the property were to be added to the payload | [
"Estimate",
"the",
"size",
"that",
"this",
"payload",
"will",
"take",
"after",
"adding",
"a",
"given",
"property",
".",
"For",
"performance",
"reasons",
"this",
"estimate",
"is",
"not",
"as",
"reliable",
"as",
"actually",
"adding",
"the",
"property",
"and",
"checking",
"the",
"payload",
"size",
"afterwards",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L200-L222 |
2,106 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.isEstimatedPayloadSizeAllowedAfterAdding | public boolean isEstimatedPayloadSizeAllowedAfterAdding(String propertyName, Object propertyValue) {
int maximumPayloadSize = getMaximumPayloadSize();
int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
boolean estimatedToBeAllowed = estimatedPayloadSize <= maximumPayloadSize;
return estimatedToBeAllowed;
} | java | public boolean isEstimatedPayloadSizeAllowedAfterAdding(String propertyName, Object propertyValue) {
int maximumPayloadSize = getMaximumPayloadSize();
int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
boolean estimatedToBeAllowed = estimatedPayloadSize <= maximumPayloadSize;
return estimatedToBeAllowed;
} | [
"public",
"boolean",
"isEstimatedPayloadSizeAllowedAfterAdding",
"(",
"String",
"propertyName",
",",
"Object",
"propertyValue",
")",
"{",
"int",
"maximumPayloadSize",
"=",
"getMaximumPayloadSize",
"(",
")",
";",
"int",
"estimatedPayloadSize",
"=",
"estimatePayloadSizeAfterAdding",
"(",
"propertyName",
",",
"propertyValue",
")",
";",
"boolean",
"estimatedToBeAllowed",
"=",
"estimatedPayloadSize",
"<=",
"maximumPayloadSize",
";",
"return",
"estimatedToBeAllowed",
";",
"}"
] | Validate if the estimated payload size after adding a given property will be allowed.
For performance reasons, this estimate is not as reliable as actually adding
the property and checking the payload size afterwards.
@param propertyName the name of the property to use for calculating the estimation
@param propertyValue the value of the property to use for calculating the estimation
@return true if the payload size is not expected to exceed the maximum allowed, false if it might be too big | [
"Validate",
"if",
"the",
"estimated",
"payload",
"size",
"after",
"adding",
"a",
"given",
"property",
"will",
"be",
"allowed",
".",
"For",
"performance",
"reasons",
"this",
"estimate",
"is",
"not",
"as",
"reliable",
"as",
"actually",
"adding",
"the",
"property",
"and",
"checking",
"the",
"payload",
"size",
"afterwards",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L234-L239 |
2,107 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.validateMaximumPayloadSize | private void validateMaximumPayloadSize(int currentPayloadSize) throws PayloadMaxSizeExceededException {
int maximumPayloadSize = getMaximumPayloadSize();
if (currentPayloadSize > maximumPayloadSize) {
throw new PayloadMaxSizeExceededException(maximumPayloadSize, currentPayloadSize);
}
} | java | private void validateMaximumPayloadSize(int currentPayloadSize) throws PayloadMaxSizeExceededException {
int maximumPayloadSize = getMaximumPayloadSize();
if (currentPayloadSize > maximumPayloadSize) {
throw new PayloadMaxSizeExceededException(maximumPayloadSize, currentPayloadSize);
}
} | [
"private",
"void",
"validateMaximumPayloadSize",
"(",
"int",
"currentPayloadSize",
")",
"throws",
"PayloadMaxSizeExceededException",
"{",
"int",
"maximumPayloadSize",
"=",
"getMaximumPayloadSize",
"(",
")",
";",
"if",
"(",
"currentPayloadSize",
">",
"maximumPayloadSize",
")",
"{",
"throw",
"new",
"PayloadMaxSizeExceededException",
"(",
"maximumPayloadSize",
",",
"currentPayloadSize",
")",
";",
"}",
"}"
] | Validate that the payload does not exceed the maximum size allowed.
If the limit is exceeded, a PayloadMaxSizeExceededException is thrown.
@param currentPayloadSize the total size of the payload in bytes
@throws PayloadMaxSizeExceededException if the payload exceeds the maximum size allowed | [
"Validate",
"that",
"the",
"payload",
"does",
"not",
"exceed",
"the",
"maximum",
"size",
"allowed",
".",
"If",
"the",
"limit",
"is",
"exceeded",
"a",
"PayloadMaxSizeExceededException",
"is",
"thrown",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L249-L254 |
2,108 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/Payload.java | Payload.put | protected void put(String propertyName, Object propertyValue, JSONObject object, boolean opt) throws JSONException {
try {
if (isPayloadSizeEstimatedWhenAdding()) {
int maximumPayloadSize = getMaximumPayloadSize();
int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
boolean estimatedToExceed = estimatedPayloadSize > maximumPayloadSize;
if (estimatedToExceed) throw new PayloadMaxSizeProbablyExceededException(maximumPayloadSize, estimatedPayloadSize);
}
} catch (PayloadMaxSizeProbablyExceededException e) {
throw e;
} catch (Exception e) {
}
if (opt) object.putOpt(propertyName, propertyValue);
else object.put(propertyName, propertyValue);
} | java | protected void put(String propertyName, Object propertyValue, JSONObject object, boolean opt) throws JSONException {
try {
if (isPayloadSizeEstimatedWhenAdding()) {
int maximumPayloadSize = getMaximumPayloadSize();
int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
boolean estimatedToExceed = estimatedPayloadSize > maximumPayloadSize;
if (estimatedToExceed) throw new PayloadMaxSizeProbablyExceededException(maximumPayloadSize, estimatedPayloadSize);
}
} catch (PayloadMaxSizeProbablyExceededException e) {
throw e;
} catch (Exception e) {
}
if (opt) object.putOpt(propertyName, propertyValue);
else object.put(propertyName, propertyValue);
} | [
"protected",
"void",
"put",
"(",
"String",
"propertyName",
",",
"Object",
"propertyValue",
",",
"JSONObject",
"object",
",",
"boolean",
"opt",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"if",
"(",
"isPayloadSizeEstimatedWhenAdding",
"(",
")",
")",
"{",
"int",
"maximumPayloadSize",
"=",
"getMaximumPayloadSize",
"(",
")",
";",
"int",
"estimatedPayloadSize",
"=",
"estimatePayloadSizeAfterAdding",
"(",
"propertyName",
",",
"propertyValue",
")",
";",
"boolean",
"estimatedToExceed",
"=",
"estimatedPayloadSize",
">",
"maximumPayloadSize",
";",
"if",
"(",
"estimatedToExceed",
")",
"throw",
"new",
"PayloadMaxSizeProbablyExceededException",
"(",
"maximumPayloadSize",
",",
"estimatedPayloadSize",
")",
";",
"}",
"}",
"catch",
"(",
"PayloadMaxSizeProbablyExceededException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"if",
"(",
"opt",
")",
"object",
".",
"putOpt",
"(",
"propertyName",
",",
"propertyValue",
")",
";",
"else",
"object",
".",
"put",
"(",
"propertyName",
",",
"propertyValue",
")",
";",
"}"
] | Puts a property in a JSONObject, while possibly checking for estimated payload size violation.
@param propertyName the name of the property to use for calculating the estimation
@param propertyValue the value of the property to use for calculating the estimation
@param object the JSONObject to put the property in
@param opt true to use putOpt, false to use put
@throws JSONException | [
"Puts",
"a",
"property",
"in",
"a",
"JSONObject",
"while",
"possibly",
"checking",
"for",
"estimated",
"payload",
"size",
"violation",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/Payload.java#L266-L281 |
2,109 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.alert | public static PushNotificationPayload alert(String message) {
if (message == null) throw new IllegalArgumentException("Alert cannot be null");
PushNotificationPayload payload = complex();
try {
payload.addAlert(message);
} catch (JSONException e) {
}
return payload;
} | java | public static PushNotificationPayload alert(String message) {
if (message == null) throw new IllegalArgumentException("Alert cannot be null");
PushNotificationPayload payload = complex();
try {
payload.addAlert(message);
} catch (JSONException e) {
}
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"alert",
"(",
"String",
"message",
")",
"{",
"if",
"(",
"message",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Alert cannot be null\"",
")",
";",
"PushNotificationPayload",
"payload",
"=",
"complex",
"(",
")",
";",
"try",
"{",
"payload",
".",
"addAlert",
"(",
"message",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"}",
"return",
"payload",
";",
"}"
] | Create a pre-defined payload with a simple alert message.
@param message the alert's message
@return a ready-to-send payload | [
"Create",
"a",
"pre",
"-",
"defined",
"payload",
"with",
"a",
"simple",
"alert",
"message",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L28-L36 |
2,110 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.badge | public static PushNotificationPayload badge(int badge) {
PushNotificationPayload payload = complex();
try {
payload.addBadge(badge);
} catch (JSONException e) {
}
return payload;
} | java | public static PushNotificationPayload badge(int badge) {
PushNotificationPayload payload = complex();
try {
payload.addBadge(badge);
} catch (JSONException e) {
}
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"badge",
"(",
"int",
"badge",
")",
"{",
"PushNotificationPayload",
"payload",
"=",
"complex",
"(",
")",
";",
"try",
"{",
"payload",
".",
"addBadge",
"(",
"badge",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"}",
"return",
"payload",
";",
"}"
] | Create a pre-defined payload with a badge.
@param badge the badge
@return a ready-to-send payload | [
"Create",
"a",
"pre",
"-",
"defined",
"payload",
"with",
"a",
"badge",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L45-L52 |
2,111 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.sound | public static PushNotificationPayload sound(String sound) {
if (sound == null) throw new IllegalArgumentException("Sound name cannot be null");
PushNotificationPayload payload = complex();
try {
payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | java | public static PushNotificationPayload sound(String sound) {
if (sound == null) throw new IllegalArgumentException("Sound name cannot be null");
PushNotificationPayload payload = complex();
try {
payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"sound",
"(",
"String",
"sound",
")",
"{",
"if",
"(",
"sound",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Sound name cannot be null\"",
")",
";",
"PushNotificationPayload",
"payload",
"=",
"complex",
"(",
")",
";",
"try",
"{",
"payload",
".",
"addSound",
"(",
"sound",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"}",
"return",
"payload",
";",
"}"
] | Create a pre-defined payload with a sound name.
@param sound the name of the sound
@return a ready-to-send payload | [
"Create",
"a",
"pre",
"-",
"defined",
"payload",
"with",
"a",
"sound",
"name",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L61-L69 |
2,112 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.combined | public static PushNotificationPayload combined(String message, int badge, String sound) {
if (message == null && badge < 0 && sound == null) throw new IllegalArgumentException("Must provide at least one non-null argument");
PushNotificationPayload payload = complex();
try {
if (message != null) payload.addAlert(message);
if (badge >= 0) payload.addBadge(badge);
if (sound != null) payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | java | public static PushNotificationPayload combined(String message, int badge, String sound) {
if (message == null && badge < 0 && sound == null) throw new IllegalArgumentException("Must provide at least one non-null argument");
PushNotificationPayload payload = complex();
try {
if (message != null) payload.addAlert(message);
if (badge >= 0) payload.addBadge(badge);
if (sound != null) payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"combined",
"(",
"String",
"message",
",",
"int",
"badge",
",",
"String",
"sound",
")",
"{",
"if",
"(",
"message",
"==",
"null",
"&&",
"badge",
"<",
"0",
"&&",
"sound",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must provide at least one non-null argument\"",
")",
";",
"PushNotificationPayload",
"payload",
"=",
"complex",
"(",
")",
";",
"try",
"{",
"if",
"(",
"message",
"!=",
"null",
")",
"payload",
".",
"addAlert",
"(",
"message",
")",
";",
"if",
"(",
"badge",
">=",
"0",
")",
"payload",
".",
"addBadge",
"(",
"badge",
")",
";",
"if",
"(",
"sound",
"!=",
"null",
")",
"payload",
".",
"addSound",
"(",
"sound",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"}",
"return",
"payload",
";",
"}"
] | Create a pre-defined payload with a simple alert message, a badge and a sound.
@param message the alert message
@param badge the badge
@param sound the name of the sound
@return a ready-to-send payload | [
"Create",
"a",
"pre",
"-",
"defined",
"payload",
"with",
"a",
"simple",
"alert",
"message",
"a",
"badge",
"and",
"a",
"sound",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L80-L90 |
2,113 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.fromJSON | public static PushNotificationPayload fromJSON(String rawJSON) throws JSONException {
PushNotificationPayload payload = new PushNotificationPayload(rawJSON);
return payload;
} | java | public static PushNotificationPayload fromJSON(String rawJSON) throws JSONException {
PushNotificationPayload payload = new PushNotificationPayload(rawJSON);
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"fromJSON",
"(",
"String",
"rawJSON",
")",
"throws",
"JSONException",
"{",
"PushNotificationPayload",
"payload",
"=",
"new",
"PushNotificationPayload",
"(",
"rawJSON",
")",
";",
"return",
"payload",
";",
"}"
] | Create a PushNotificationPayload object from a preformatted JSON payload.
@param rawJSON a JSON-formatted string representing a payload (ex: {"aps":{"alert":"Hello World!"}} )
@return a ready-to-send payload
@throws JSONException if any exception occurs parsing the JSON string | [
"Create",
"a",
"PushNotificationPayload",
"object",
"from",
"a",
"preformatted",
"JSON",
"payload",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L125-L128 |
2,114 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.addBadge | public void addBadge(int badge) throws JSONException {
logger.debug("Adding badge [" + badge + "]");
put("badge", badge, this.apsDictionary, true);
} | java | public void addBadge(int badge) throws JSONException {
logger.debug("Adding badge [" + badge + "]");
put("badge", badge, this.apsDictionary, true);
} | [
"public",
"void",
"addBadge",
"(",
"int",
"badge",
")",
"throws",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding badge [\"",
"+",
"badge",
"+",
"\"]\"",
")",
";",
"put",
"(",
"\"badge\"",
",",
"badge",
",",
"this",
".",
"apsDictionary",
",",
"true",
")",
";",
"}"
] | Add a badge.
@param badge a badge number
@throws JSONException | [
"Add",
"a",
"badge",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L193-L196 |
2,115 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.addSound | public void addSound(String sound) throws JSONException {
logger.debug("Adding sound [" + sound + "]");
put("sound", sound, this.apsDictionary, true);
} | java | public void addSound(String sound) throws JSONException {
logger.debug("Adding sound [" + sound + "]");
put("sound", sound, this.apsDictionary, true);
} | [
"public",
"void",
"addSound",
"(",
"String",
"sound",
")",
"throws",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding sound [\"",
"+",
"sound",
"+",
"\"]\"",
")",
";",
"put",
"(",
"\"sound\"",
",",
"sound",
",",
"this",
".",
"apsDictionary",
",",
"true",
")",
";",
"}"
] | Add a sound.
@param sound the name of a sound
@throws JSONException | [
"Add",
"a",
"sound",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L205-L208 |
2,116 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.getOrAddCustomAlert | private JSONObject getOrAddCustomAlert() throws JSONException {
JSONObject alert = getCompatibleProperty("alert", JSONObject.class, "A simple alert (\"%s\") was already added to this payload");
if (alert == null) {
alert = new JSONObject();
put("alert", alert, this.apsDictionary, false);
}
return alert;
} | java | private JSONObject getOrAddCustomAlert() throws JSONException {
JSONObject alert = getCompatibleProperty("alert", JSONObject.class, "A simple alert (\"%s\") was already added to this payload");
if (alert == null) {
alert = new JSONObject();
put("alert", alert, this.apsDictionary, false);
}
return alert;
} | [
"private",
"JSONObject",
"getOrAddCustomAlert",
"(",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"alert",
"=",
"getCompatibleProperty",
"(",
"\"alert\"",
",",
"JSONObject",
".",
"class",
",",
"\"A simple alert (\\\"%s\\\") was already added to this payload\"",
")",
";",
"if",
"(",
"alert",
"==",
"null",
")",
"{",
"alert",
"=",
"new",
"JSONObject",
"(",
")",
";",
"put",
"(",
"\"alert\"",
",",
"alert",
",",
"this",
".",
"apsDictionary",
",",
"false",
")",
";",
"}",
"return",
"alert",
";",
"}"
] | Get the custom alert object, creating it if it does not yet exist.
@return the JSON object defining the custom alert
@throws JSONException if a simple alert has already been added to this payload | [
"Get",
"the",
"custom",
"alert",
"object",
"creating",
"it",
"if",
"it",
"does",
"not",
"yet",
"exist",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L231-L238 |
2,117 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.setContentAvailable | public void setContentAvailable(boolean available) throws JSONException {
if (available == true) {
logger.debug("Setting content available");
put("content-available", 1, this.apsDictionary, false);
} else {
logger.debug("Removing content available");
remove("content-available", this.apsDictionary);
}
} | java | public void setContentAvailable(boolean available) throws JSONException {
if (available == true) {
logger.debug("Setting content available");
put("content-available", 1, this.apsDictionary, false);
} else {
logger.debug("Removing content available");
remove("content-available", this.apsDictionary);
}
} | [
"public",
"void",
"setContentAvailable",
"(",
"boolean",
"available",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"available",
"==",
"true",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Setting content available\"",
")",
";",
"put",
"(",
"\"content-available\"",
",",
"1",
",",
"this",
".",
"apsDictionary",
",",
"false",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Removing content available\"",
")",
";",
"remove",
"(",
"\"content-available\"",
",",
"this",
".",
"apsDictionary",
")",
";",
"}",
"}"
] | Sets the content available.
@param available
@throws JSONException | [
"Sets",
"the",
"content",
"available",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L397-L405 |
2,118 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.addCategory | public void addCategory(String category) throws JSONException {
logger.debug("Adding category [" + category + "]");
put("category", category, this.apsDictionary, true);
} | java | public void addCategory(String category) throws JSONException {
logger.debug("Adding category [" + category + "]");
put("category", category, this.apsDictionary, true);
} | [
"public",
"void",
"addCategory",
"(",
"String",
"category",
")",
"throws",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding category [\"",
"+",
"category",
"+",
"\"]\"",
")",
";",
"put",
"(",
"\"category\"",
",",
"category",
",",
"this",
".",
"apsDictionary",
",",
"true",
")",
";",
"}"
] | Add a category.
@param category the category of a message
@throws JSONException | [
"Add",
"a",
"category",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L413-L416 |
2,119 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.setMutableContent | public void setMutableContent(boolean mutable) throws JSONException {
if (mutable == true) {
logger.debug("Setting mutable content");
put("mutable-content", 1, this.apsDictionary, false);
} else {
logger.debug("Removing mutable content");
remove("mutable-content", this.apsDictionary);
}
} | java | public void setMutableContent(boolean mutable) throws JSONException {
if (mutable == true) {
logger.debug("Setting mutable content");
put("mutable-content", 1, this.apsDictionary, false);
} else {
logger.debug("Removing mutable content");
remove("mutable-content", this.apsDictionary);
}
} | [
"public",
"void",
"setMutableContent",
"(",
"boolean",
"mutable",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"mutable",
"==",
"true",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Setting mutable content\"",
")",
";",
"put",
"(",
"\"mutable-content\"",
",",
"1",
",",
"this",
".",
"apsDictionary",
",",
"false",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Removing mutable content\"",
")",
";",
"remove",
"(",
"\"mutable-content\"",
",",
"this",
".",
"apsDictionary",
")",
";",
"}",
"}"
] | Sets the mutable content.
@param mutable
@throws JSONException | [
"Sets",
"the",
"mutable",
"content",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L424-L432 |
2,120 | fernandospr/javapns-jdk16 | src/main/java/javapns/notification/ResponsePacket.java | ResponsePacket.getMessage | public String getMessage() {
if (command == 8) {
String prefix = "APNS: [" + identifier + "] "; //APNS ERROR FOR MESSAGE ID #" + identifier + ": ";
if (status == 0) return prefix + "No errors encountered";
if (status == 1) return prefix + "Processing error";
if (status == 2) return prefix + "Missing device token";
if (status == 3) return prefix + "Missing topic";
if (status == 4) return prefix + "Missing payload";
if (status == 5) return prefix + "Invalid token size";
if (status == 6) return prefix + "Invalid topic size";
if (status == 7) return prefix + "Invalid payload size";
if (status == 8) return prefix + "Invalid token";
if (status == 255) return prefix + "None (unknown)";
return prefix + "Undocumented status code: " + status;
}
return "APNS: Undocumented response command: " + command;
} | java | public String getMessage() {
if (command == 8) {
String prefix = "APNS: [" + identifier + "] "; //APNS ERROR FOR MESSAGE ID #" + identifier + ": ";
if (status == 0) return prefix + "No errors encountered";
if (status == 1) return prefix + "Processing error";
if (status == 2) return prefix + "Missing device token";
if (status == 3) return prefix + "Missing topic";
if (status == 4) return prefix + "Missing payload";
if (status == 5) return prefix + "Invalid token size";
if (status == 6) return prefix + "Invalid topic size";
if (status == 7) return prefix + "Invalid payload size";
if (status == 8) return prefix + "Invalid token";
if (status == 255) return prefix + "None (unknown)";
return prefix + "Undocumented status code: " + status;
}
return "APNS: Undocumented response command: " + command;
} | [
"public",
"String",
"getMessage",
"(",
")",
"{",
"if",
"(",
"command",
"==",
"8",
")",
"{",
"String",
"prefix",
"=",
"\"APNS: [\"",
"+",
"identifier",
"+",
"\"] \"",
";",
"//APNS ERROR FOR MESSAGE ID #\" + identifier + \": \";",
"if",
"(",
"status",
"==",
"0",
")",
"return",
"prefix",
"+",
"\"No errors encountered\"",
";",
"if",
"(",
"status",
"==",
"1",
")",
"return",
"prefix",
"+",
"\"Processing error\"",
";",
"if",
"(",
"status",
"==",
"2",
")",
"return",
"prefix",
"+",
"\"Missing device token\"",
";",
"if",
"(",
"status",
"==",
"3",
")",
"return",
"prefix",
"+",
"\"Missing topic\"",
";",
"if",
"(",
"status",
"==",
"4",
")",
"return",
"prefix",
"+",
"\"Missing payload\"",
";",
"if",
"(",
"status",
"==",
"5",
")",
"return",
"prefix",
"+",
"\"Invalid token size\"",
";",
"if",
"(",
"status",
"==",
"6",
")",
"return",
"prefix",
"+",
"\"Invalid topic size\"",
";",
"if",
"(",
"status",
"==",
"7",
")",
"return",
"prefix",
"+",
"\"Invalid payload size\"",
";",
"if",
"(",
"status",
"==",
"8",
")",
"return",
"prefix",
"+",
"\"Invalid token\"",
";",
"if",
"(",
"status",
"==",
"255",
")",
"return",
"prefix",
"+",
"\"None (unknown)\"",
";",
"return",
"prefix",
"+",
"\"Undocumented status code: \"",
"+",
"status",
";",
"}",
"return",
"\"APNS: Undocumented response command: \"",
"+",
"command",
";",
"}"
] | Returns a humand-friendly error message, as documented by Apple.
@return a humand-friendly error message | [
"Returns",
"a",
"humand",
"-",
"friendly",
"error",
"message",
"as",
"documented",
"by",
"Apple",
"."
] | 84de6d9328ab01af92f77cc60c4554de02420909 | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/ResponsePacket.java#L107-L123 |
2,121 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java | SwipeViewGroup.addBackground | public SwipeViewGroup addBackground(View background, SwipeDirection direction){
if(mBackgroundMap.get(direction) != null) removeView(mBackgroundMap.get(direction));
background.setVisibility(View.INVISIBLE);
mBackgroundMap.put(direction, background);
addView(background);
return this;
} | java | public SwipeViewGroup addBackground(View background, SwipeDirection direction){
if(mBackgroundMap.get(direction) != null) removeView(mBackgroundMap.get(direction));
background.setVisibility(View.INVISIBLE);
mBackgroundMap.put(direction, background);
addView(background);
return this;
} | [
"public",
"SwipeViewGroup",
"addBackground",
"(",
"View",
"background",
",",
"SwipeDirection",
"direction",
")",
"{",
"if",
"(",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
"!=",
"null",
")",
"removeView",
"(",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
")",
";",
"background",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"mBackgroundMap",
".",
"put",
"(",
"direction",
",",
"background",
")",
";",
"addView",
"(",
"background",
")",
";",
"return",
"this",
";",
"}"
] | Add a View to the background of the Layout. The background should have the same height
as the contentView
@param background The View to be added to the Layout
@param direction The key to be used to find it again
@return A reference to the a layout so commands can be chained | [
"Add",
"a",
"View",
"to",
"the",
"background",
"of",
"the",
"Layout",
".",
"The",
"background",
"should",
"have",
"the",
"same",
"height",
"as",
"the",
"contentView"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java#L76-L83 |
2,122 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java | SwipeViewGroup.showBackground | public void showBackground(SwipeDirection direction, boolean dimBackground){
if(SwipeDirection.DIRECTION_NEUTRAL != direction && mBackgroundMap.get(direction) == null) return;
if(SwipeDirection.DIRECTION_NEUTRAL != visibleView)
mBackgroundMap.get(visibleView).setVisibility(View.INVISIBLE);
if(SwipeDirection.DIRECTION_NEUTRAL != direction) {
mBackgroundMap.get(direction).setVisibility(View.VISIBLE);
mBackgroundMap.get(direction).setAlpha(dimBackground ? 0.4f : 1);
}
visibleView = direction;
} | java | public void showBackground(SwipeDirection direction, boolean dimBackground){
if(SwipeDirection.DIRECTION_NEUTRAL != direction && mBackgroundMap.get(direction) == null) return;
if(SwipeDirection.DIRECTION_NEUTRAL != visibleView)
mBackgroundMap.get(visibleView).setVisibility(View.INVISIBLE);
if(SwipeDirection.DIRECTION_NEUTRAL != direction) {
mBackgroundMap.get(direction).setVisibility(View.VISIBLE);
mBackgroundMap.get(direction).setAlpha(dimBackground ? 0.4f : 1);
}
visibleView = direction;
} | [
"public",
"void",
"showBackground",
"(",
"SwipeDirection",
"direction",
",",
"boolean",
"dimBackground",
")",
"{",
"if",
"(",
"SwipeDirection",
".",
"DIRECTION_NEUTRAL",
"!=",
"direction",
"&&",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
"==",
"null",
")",
"return",
";",
"if",
"(",
"SwipeDirection",
".",
"DIRECTION_NEUTRAL",
"!=",
"visibleView",
")",
"mBackgroundMap",
".",
"get",
"(",
"visibleView",
")",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"if",
"(",
"SwipeDirection",
".",
"DIRECTION_NEUTRAL",
"!=",
"direction",
")",
"{",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
".",
"setAlpha",
"(",
"dimBackground",
"?",
"0.4f",
":",
"1",
")",
";",
"}",
"visibleView",
"=",
"direction",
";",
"}"
] | Show the View linked to a key. Don't do anything if the key is not found
@param direction The key of the View to be shown
@param dimBackground Indicates whether the background should be dimmed | [
"Show",
"the",
"View",
"linked",
"to",
"a",
"key",
".",
"Don",
"t",
"do",
"anything",
"if",
"the",
"key",
"is",
"not",
"found"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java#L91-L102 |
2,123 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java | SwipeViewGroup.setContentView | public SwipeViewGroup setContentView(View contentView){
if(this.contentView != null) removeView(contentView);
addView(contentView);
this.contentView = contentView;
return this;
} | java | public SwipeViewGroup setContentView(View contentView){
if(this.contentView != null) removeView(contentView);
addView(contentView);
this.contentView = contentView;
return this;
} | [
"public",
"SwipeViewGroup",
"setContentView",
"(",
"View",
"contentView",
")",
"{",
"if",
"(",
"this",
".",
"contentView",
"!=",
"null",
")",
"removeView",
"(",
"contentView",
")",
";",
"addView",
"(",
"contentView",
")",
";",
"this",
".",
"contentView",
"=",
"contentView",
";",
"return",
"this",
";",
"}"
] | Add a contentView to the Layout
@param contentView The View to be added
@return A reference to the layout so commands can be chained | [
"Add",
"a",
"contentView",
"to",
"the",
"Layout"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java#L110-L116 |
2,124 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java | SwipeViewGroup.translateBackgrounds | public void translateBackgrounds(){
this.setClipChildren(false);
for(Map.Entry<SwipeDirection, View> entry : mBackgroundMap.entrySet()) {
int signum = entry.getKey().isLeft() ? 1 : -1;
entry.getValue().setTranslationX(signum*entry.getValue().getWidth());
}
} | java | public void translateBackgrounds(){
this.setClipChildren(false);
for(Map.Entry<SwipeDirection, View> entry : mBackgroundMap.entrySet()) {
int signum = entry.getKey().isLeft() ? 1 : -1;
entry.getValue().setTranslationX(signum*entry.getValue().getWidth());
}
} | [
"public",
"void",
"translateBackgrounds",
"(",
")",
"{",
"this",
".",
"setClipChildren",
"(",
"false",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"SwipeDirection",
",",
"View",
">",
"entry",
":",
"mBackgroundMap",
".",
"entrySet",
"(",
")",
")",
"{",
"int",
"signum",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"isLeft",
"(",
")",
"?",
"1",
":",
"-",
"1",
";",
"entry",
".",
"getValue",
"(",
")",
".",
"setTranslationX",
"(",
"signum",
"*",
"entry",
".",
"getValue",
"(",
")",
".",
"getWidth",
"(",
")",
")",
";",
"}",
"}"
] | Move all backgrounds to the edge of the Layout so they can be swiped in | [
"Move",
"all",
"backgrounds",
"to",
"the",
"edge",
"of",
"the",
"Layout",
"so",
"they",
"can",
"be",
"swiped",
"in"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java#L130-L136 |
2,125 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.onSwipeStarted | @Override
public void onSwipeStarted(ListView listView, int position, SwipeDirection direction) {
if(mSwipeActionListener != null) mSwipeActionListener.onSwipeStarted(listView, position, direction);
} | java | @Override
public void onSwipeStarted(ListView listView, int position, SwipeDirection direction) {
if(mSwipeActionListener != null) mSwipeActionListener.onSwipeStarted(listView, position, direction);
} | [
"@",
"Override",
"public",
"void",
"onSwipeStarted",
"(",
"ListView",
"listView",
",",
"int",
"position",
",",
"SwipeDirection",
"direction",
")",
"{",
"if",
"(",
"mSwipeActionListener",
"!=",
"null",
")",
"mSwipeActionListener",
".",
"onSwipeStarted",
"(",
"listView",
",",
"position",
",",
"direction",
")",
";",
"}"
] | Called once the user touches the screen and starts swiping in any direction
@param listView The originating {@link ListView}.
@param position The position to perform the action on, sorted in descending order
for convenience.
@param direction The type of swipe that triggered the action | [
"Called",
"once",
"the",
"user",
"touches",
"the",
"screen",
"and",
"starts",
"swiping",
"in",
"any",
"direction"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L118-L121 |
2,126 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.setFadeOut | @SuppressWarnings("unused")
public SwipeActionAdapter setFadeOut(boolean mFadeOut){
this.mFadeOut = mFadeOut;
if(mListView != null) mTouchListener.setFadeOut(mFadeOut);
return this;
} | java | @SuppressWarnings("unused")
public SwipeActionAdapter setFadeOut(boolean mFadeOut){
this.mFadeOut = mFadeOut;
if(mListView != null) mTouchListener.setFadeOut(mFadeOut);
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"SwipeActionAdapter",
"setFadeOut",
"(",
"boolean",
"mFadeOut",
")",
"{",
"this",
".",
"mFadeOut",
"=",
"mFadeOut",
";",
"if",
"(",
"mListView",
"!=",
"null",
")",
"mTouchListener",
".",
"setFadeOut",
"(",
"mFadeOut",
")",
";",
"return",
"this",
";",
"}"
] | Set whether items should have a fadeOut animation
@param mFadeOut true makes items fade out with a swipe (opacity to 0)
@return A reference to the current instance so that commands can be chained | [
"Set",
"whether",
"items",
"should",
"have",
"a",
"fadeOut",
"animation"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L142-L147 |
2,127 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.setFarSwipeFraction | @SuppressWarnings("unused")
public SwipeActionAdapter setFarSwipeFraction(float farSwipeFraction) {
if(farSwipeFraction < 0 || farSwipeFraction > 1) {
throw new IllegalArgumentException("Must be a float between 0 and 1");
}
this.mFarSwipeFraction = farSwipeFraction;
if(mListView != null) mTouchListener.setFarSwipeFraction(farSwipeFraction);
return this;
} | java | @SuppressWarnings("unused")
public SwipeActionAdapter setFarSwipeFraction(float farSwipeFraction) {
if(farSwipeFraction < 0 || farSwipeFraction > 1) {
throw new IllegalArgumentException("Must be a float between 0 and 1");
}
this.mFarSwipeFraction = farSwipeFraction;
if(mListView != null) mTouchListener.setFarSwipeFraction(farSwipeFraction);
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"SwipeActionAdapter",
"setFarSwipeFraction",
"(",
"float",
"farSwipeFraction",
")",
"{",
"if",
"(",
"farSwipeFraction",
"<",
"0",
"||",
"farSwipeFraction",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must be a float between 0 and 1\"",
")",
";",
"}",
"this",
".",
"mFarSwipeFraction",
"=",
"farSwipeFraction",
";",
"if",
"(",
"mListView",
"!=",
"null",
")",
"mTouchListener",
".",
"setFarSwipeFraction",
"(",
"farSwipeFraction",
")",
";",
"return",
"this",
";",
"}"
] | Set the fraction of the View Width that needs to be swiped before it is counted as a far swipe
@param farSwipeFraction float between 0 and 1 | [
"Set",
"the",
"fraction",
"of",
"the",
"View",
"Width",
"that",
"needs",
"to",
"be",
"swiped",
"before",
"it",
"is",
"counted",
"as",
"a",
"far",
"swipe"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L180-L188 |
2,128 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.setNormalSwipeFraction | @SuppressWarnings("unused")
public SwipeActionAdapter setNormalSwipeFraction(float normalSwipeFraction) {
if(normalSwipeFraction < 0 || normalSwipeFraction > 1) {
throw new IllegalArgumentException("Must be a float between 0 and 1");
}
this.mNormalSwipeFraction = normalSwipeFraction;
if(mListView != null) mTouchListener.setNormalSwipeFraction(normalSwipeFraction);
return this;
} | java | @SuppressWarnings("unused")
public SwipeActionAdapter setNormalSwipeFraction(float normalSwipeFraction) {
if(normalSwipeFraction < 0 || normalSwipeFraction > 1) {
throw new IllegalArgumentException("Must be a float between 0 and 1");
}
this.mNormalSwipeFraction = normalSwipeFraction;
if(mListView != null) mTouchListener.setNormalSwipeFraction(normalSwipeFraction);
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"SwipeActionAdapter",
"setNormalSwipeFraction",
"(",
"float",
"normalSwipeFraction",
")",
"{",
"if",
"(",
"normalSwipeFraction",
"<",
"0",
"||",
"normalSwipeFraction",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must be a float between 0 and 1\"",
")",
";",
"}",
"this",
".",
"mNormalSwipeFraction",
"=",
"normalSwipeFraction",
";",
"if",
"(",
"mListView",
"!=",
"null",
")",
"mTouchListener",
".",
"setNormalSwipeFraction",
"(",
"normalSwipeFraction",
")",
";",
"return",
"this",
";",
"}"
] | Set the fraction of the View Width that needs to be swiped before it is counted as a normal swipe
@param normalSwipeFraction float between 0 and 1 | [
"Set",
"the",
"fraction",
"of",
"the",
"View",
"Width",
"that",
"needs",
"to",
"be",
"swiped",
"before",
"it",
"is",
"counted",
"as",
"a",
"normal",
"swipe"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L195-L203 |
2,129 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.setListView | public SwipeActionAdapter setListView(ListView listView){
this.mListView = listView;
mTouchListener = new SwipeActionTouchListener(listView,this);
this.mListView.setOnTouchListener(mTouchListener);
this.mListView.setOnScrollListener(mTouchListener.makeScrollListener());
this.mListView.setClipChildren(false);
mTouchListener.setFadeOut(mFadeOut);
mTouchListener.setDimBackgrounds(mDimBackgrounds);
mTouchListener.setFixedBackgrounds(mFixedBackgrounds);
mTouchListener.setNormalSwipeFraction(mNormalSwipeFraction);
mTouchListener.setFarSwipeFraction(mFarSwipeFraction);
return this;
} | java | public SwipeActionAdapter setListView(ListView listView){
this.mListView = listView;
mTouchListener = new SwipeActionTouchListener(listView,this);
this.mListView.setOnTouchListener(mTouchListener);
this.mListView.setOnScrollListener(mTouchListener.makeScrollListener());
this.mListView.setClipChildren(false);
mTouchListener.setFadeOut(mFadeOut);
mTouchListener.setDimBackgrounds(mDimBackgrounds);
mTouchListener.setFixedBackgrounds(mFixedBackgrounds);
mTouchListener.setNormalSwipeFraction(mNormalSwipeFraction);
mTouchListener.setFarSwipeFraction(mFarSwipeFraction);
return this;
} | [
"public",
"SwipeActionAdapter",
"setListView",
"(",
"ListView",
"listView",
")",
"{",
"this",
".",
"mListView",
"=",
"listView",
";",
"mTouchListener",
"=",
"new",
"SwipeActionTouchListener",
"(",
"listView",
",",
"this",
")",
";",
"this",
".",
"mListView",
".",
"setOnTouchListener",
"(",
"mTouchListener",
")",
";",
"this",
".",
"mListView",
".",
"setOnScrollListener",
"(",
"mTouchListener",
".",
"makeScrollListener",
"(",
")",
")",
";",
"this",
".",
"mListView",
".",
"setClipChildren",
"(",
"false",
")",
";",
"mTouchListener",
".",
"setFadeOut",
"(",
"mFadeOut",
")",
";",
"mTouchListener",
".",
"setDimBackgrounds",
"(",
"mDimBackgrounds",
")",
";",
"mTouchListener",
".",
"setFixedBackgrounds",
"(",
"mFixedBackgrounds",
")",
";",
"mTouchListener",
".",
"setNormalSwipeFraction",
"(",
"mNormalSwipeFraction",
")",
";",
"mTouchListener",
".",
"setFarSwipeFraction",
"(",
"mFarSwipeFraction",
")",
";",
"return",
"this",
";",
"}"
] | We need the ListView to be able to modify it's OnTouchListener
@param listView the ListView to which the adapter will be attached
@return A reference to the current instance so that commands can be chained | [
"We",
"need",
"the",
"ListView",
"to",
"be",
"able",
"to",
"modify",
"it",
"s",
"OnTouchListener"
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L211-L223 |
2,130 | wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java | SwipeActionAdapter.addBackground | public SwipeActionAdapter addBackground(SwipeDirection key, int resId){
if(SwipeDirection.getAllDirections().contains(key)) mBackgroundResIds.put(key,resId);
return this;
} | java | public SwipeActionAdapter addBackground(SwipeDirection key, int resId){
if(SwipeDirection.getAllDirections().contains(key)) mBackgroundResIds.put(key,resId);
return this;
} | [
"public",
"SwipeActionAdapter",
"addBackground",
"(",
"SwipeDirection",
"key",
",",
"int",
"resId",
")",
"{",
"if",
"(",
"SwipeDirection",
".",
"getAllDirections",
"(",
")",
".",
"contains",
"(",
"key",
")",
")",
"mBackgroundResIds",
".",
"put",
"(",
"key",
",",
"resId",
")",
";",
"return",
"this",
";",
"}"
] | Add a background image for a certain callback. The key for the background must be one of the
directions from the SwipeDirections class.
@param key the identifier of the callback for which this resource should be shown
@param resId the resource Id of the background to add
@return A reference to the current instance so that commands can be chained | [
"Add",
"a",
"background",
"image",
"for",
"a",
"certain",
"callback",
".",
"The",
"key",
"for",
"the",
"background",
"must",
"be",
"one",
"of",
"the",
"directions",
"from",
"the",
"SwipeDirections",
"class",
"."
] | 24a7e2ed953ac11ea0d8875d375bba571ffeba55 | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L243-L246 |
2,131 | captain-miao/OptionRoundCardview | optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java | OptRoundCardView.setShadowPadding | @Override
public void setShadowPadding(int left, int top, int right, int bottom) {
mShadowBounds.set(left, top, right, bottom);
super.setPadding(left + mContentPadding.left, top + mContentPadding.top,
right + mContentPadding.right, bottom + mContentPadding.bottom);
} | java | @Override
public void setShadowPadding(int left, int top, int right, int bottom) {
mShadowBounds.set(left, top, right, bottom);
super.setPadding(left + mContentPadding.left, top + mContentPadding.top,
right + mContentPadding.right, bottom + mContentPadding.bottom);
} | [
"@",
"Override",
"public",
"void",
"setShadowPadding",
"(",
"int",
"left",
",",
"int",
"top",
",",
"int",
"right",
",",
"int",
"bottom",
")",
"{",
"mShadowBounds",
".",
"set",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"super",
".",
"setPadding",
"(",
"left",
"+",
"mContentPadding",
".",
"left",
",",
"top",
"+",
"mContentPadding",
".",
"top",
",",
"right",
"+",
"mContentPadding",
".",
"right",
",",
"bottom",
"+",
"mContentPadding",
".",
"bottom",
")",
";",
"}"
] | Internal method used by CardView implementations to update the padding.
@hide | [
"Internal",
"method",
"used",
"by",
"CardView",
"implementations",
"to",
"update",
"the",
"padding",
"."
] | aefad1e42351958724b916b8003a24f10634b3d8 | https://github.com/captain-miao/OptionRoundCardview/blob/aefad1e42351958724b916b8003a24f10634b3d8/optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java#L347-L352 |
2,132 | captain-miao/OptionRoundCardview | optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java | OptRoundCardView.showCorner | public void showCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
if (SDK_LOLLIPOP) {
((OptRoundRectDrawable) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
} else {
((OptRoundRectDrawableWithShadow) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
}
} | java | public void showCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
if (SDK_LOLLIPOP) {
((OptRoundRectDrawable) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
} else {
((OptRoundRectDrawableWithShadow) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
}
} | [
"public",
"void",
"showCorner",
"(",
"boolean",
"leftTop",
",",
"boolean",
"rightTop",
",",
"boolean",
"leftBottom",
",",
"boolean",
"rightBottom",
")",
"{",
"if",
"(",
"SDK_LOLLIPOP",
")",
"{",
"(",
"(",
"OptRoundRectDrawable",
")",
"getBackground",
"(",
")",
")",
".",
"showCorner",
"(",
"leftTop",
",",
"rightTop",
",",
"leftBottom",
",",
"rightBottom",
")",
";",
"}",
"else",
"{",
"(",
"(",
"OptRoundRectDrawableWithShadow",
")",
"getBackground",
"(",
")",
")",
".",
"showCorner",
"(",
"leftTop",
",",
"rightTop",
",",
"leftBottom",
",",
"rightBottom",
")",
";",
"}",
"}"
] | show corner or rect | [
"show",
"corner",
"or",
"rect"
] | aefad1e42351958724b916b8003a24f10634b3d8 | https://github.com/captain-miao/OptionRoundCardview/blob/aefad1e42351958724b916b8003a24f10634b3d8/optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java#L441-L447 |
2,133 | captain-miao/OptionRoundCardview | optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java | OptRoundCardView.showEdgeShadow | public void showEdgeShadow(boolean left, boolean top, boolean right, boolean bottom) {
if (SDK_LOLLIPOP) {
//((OptRoundRectDrawable) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
} else {
((OptRoundRectDrawableWithShadow) getBackground()).showEdgeShadow(left, top, right, bottom);
}
} | java | public void showEdgeShadow(boolean left, boolean top, boolean right, boolean bottom) {
if (SDK_LOLLIPOP) {
//((OptRoundRectDrawable) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);
} else {
((OptRoundRectDrawableWithShadow) getBackground()).showEdgeShadow(left, top, right, bottom);
}
} | [
"public",
"void",
"showEdgeShadow",
"(",
"boolean",
"left",
",",
"boolean",
"top",
",",
"boolean",
"right",
",",
"boolean",
"bottom",
")",
"{",
"if",
"(",
"SDK_LOLLIPOP",
")",
"{",
"//((OptRoundRectDrawable) getBackground()).showCorner(leftTop, rightTop, leftBottom, rightBottom);",
"}",
"else",
"{",
"(",
"(",
"OptRoundRectDrawableWithShadow",
")",
"getBackground",
"(",
")",
")",
".",
"showEdgeShadow",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"}",
"}"
] | show Edge Shadow | [
"show",
"Edge",
"Shadow"
] | aefad1e42351958724b916b8003a24f10634b3d8 | https://github.com/captain-miao/OptionRoundCardview/blob/aefad1e42351958724b916b8003a24f10634b3d8/optroundcardview/src/main/java/com/github/captain_miao/optroundcardview/OptRoundCardView.java#L484-L490 |
2,134 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/Candidate.java | Candidate.addObjectFactoryForClass | public boolean addObjectFactoryForClass(JDefinedClass clazz) {
JDefinedClass valueObjectFactoryClass = clazz._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClasses.containsKey(valueObjectFactoryClass.fullName())) {
return false;
}
objectFactoryClasses.put(valueObjectFactoryClass.fullName(), valueObjectFactoryClass);
JDefinedClass objectFactoryClass = null;
// If class has a non-hidden interface, then there is object factory in another package.
for (Iterator<JClass> iter = clazz._implements(); iter.hasNext();) {
JClass interfaceClass = iter.next();
if (!isHiddenClass(interfaceClass)) {
objectFactoryClass = interfaceClass._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClass != null) {
objectFactoryClasses.put(objectFactoryClass.fullName(), objectFactoryClass);
}
}
}
return objectFactoryClass != null;
} | java | public boolean addObjectFactoryForClass(JDefinedClass clazz) {
JDefinedClass valueObjectFactoryClass = clazz._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClasses.containsKey(valueObjectFactoryClass.fullName())) {
return false;
}
objectFactoryClasses.put(valueObjectFactoryClass.fullName(), valueObjectFactoryClass);
JDefinedClass objectFactoryClass = null;
// If class has a non-hidden interface, then there is object factory in another package.
for (Iterator<JClass> iter = clazz._implements(); iter.hasNext();) {
JClass interfaceClass = iter.next();
if (!isHiddenClass(interfaceClass)) {
objectFactoryClass = interfaceClass._package()._getClass(FACTORY_CLASS_NAME);
if (objectFactoryClass != null) {
objectFactoryClasses.put(objectFactoryClass.fullName(), objectFactoryClass);
}
}
}
return objectFactoryClass != null;
} | [
"public",
"boolean",
"addObjectFactoryForClass",
"(",
"JDefinedClass",
"clazz",
")",
"{",
"JDefinedClass",
"valueObjectFactoryClass",
"=",
"clazz",
".",
"_package",
"(",
")",
".",
"_getClass",
"(",
"FACTORY_CLASS_NAME",
")",
";",
"if",
"(",
"objectFactoryClasses",
".",
"containsKey",
"(",
"valueObjectFactoryClass",
".",
"fullName",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"objectFactoryClasses",
".",
"put",
"(",
"valueObjectFactoryClass",
".",
"fullName",
"(",
")",
",",
"valueObjectFactoryClass",
")",
";",
"JDefinedClass",
"objectFactoryClass",
"=",
"null",
";",
"// If class has a non-hidden interface, then there is object factory in another package.\r",
"for",
"(",
"Iterator",
"<",
"JClass",
">",
"iter",
"=",
"clazz",
".",
"_implements",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"JClass",
"interfaceClass",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"isHiddenClass",
"(",
"interfaceClass",
")",
")",
"{",
"objectFactoryClass",
"=",
"interfaceClass",
".",
"_package",
"(",
")",
".",
"_getClass",
"(",
"FACTORY_CLASS_NAME",
")",
";",
"if",
"(",
"objectFactoryClass",
"!=",
"null",
")",
"{",
"objectFactoryClasses",
".",
"put",
"(",
"objectFactoryClass",
".",
"fullName",
"(",
")",
",",
"objectFactoryClass",
")",
";",
"}",
"}",
"}",
"return",
"objectFactoryClass",
"!=",
"null",
";",
"}"
] | For the given class locate and add Object Factory classes to the map.
@return {@code true} if value class generation is enabled | [
"For",
"the",
"given",
"class",
"locate",
"and",
"add",
"Object",
"Factory",
"classes",
"to",
"the",
"map",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/Candidate.java#L201-L226 |
2,135 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/config/AbstractConfigurablePlugin.java | AbstractConfigurablePlugin.parseArgument | @Override
public int parseArgument(Options opts, String[] args, int i) throws BadCommandLineException {
initLoggerIfNecessary(opts);
int recognized = 0;
String arg = args[i];
logger.trace("Argument[" + i + "] = " + arg);
if (arg.equals(getArgumentName(ConfigurationOption.APPLY_PLURAL_FORM.optionName()))) {
globalConfiguration.setApplyPluralForm(true);
return 1;
}
else if ((recognized = parseArgument(args, i, ConfigurationOption.CONTROL)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.SUMMARY)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.COLLECTION_INTERFACE)) == 0 // longer option name comes first
&& (recognized = parseArgument(args, i, ConfigurationOption.COLLECTION_IMPLEMENTATION)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.INSTANTIATION_MODE)) == 0) {
if (arg.startsWith(getArgumentName(""))) {
throw new BadCommandLineException("Invalid argument " + arg);
}
}
return recognized;
} | java | @Override
public int parseArgument(Options opts, String[] args, int i) throws BadCommandLineException {
initLoggerIfNecessary(opts);
int recognized = 0;
String arg = args[i];
logger.trace("Argument[" + i + "] = " + arg);
if (arg.equals(getArgumentName(ConfigurationOption.APPLY_PLURAL_FORM.optionName()))) {
globalConfiguration.setApplyPluralForm(true);
return 1;
}
else if ((recognized = parseArgument(args, i, ConfigurationOption.CONTROL)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.SUMMARY)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.COLLECTION_INTERFACE)) == 0 // longer option name comes first
&& (recognized = parseArgument(args, i, ConfigurationOption.COLLECTION_IMPLEMENTATION)) == 0
&& (recognized = parseArgument(args, i, ConfigurationOption.INSTANTIATION_MODE)) == 0) {
if (arg.startsWith(getArgumentName(""))) {
throw new BadCommandLineException("Invalid argument " + arg);
}
}
return recognized;
} | [
"@",
"Override",
"public",
"int",
"parseArgument",
"(",
"Options",
"opts",
",",
"String",
"[",
"]",
"args",
",",
"int",
"i",
")",
"throws",
"BadCommandLineException",
"{",
"initLoggerIfNecessary",
"(",
"opts",
")",
";",
"int",
"recognized",
"=",
"0",
";",
"String",
"arg",
"=",
"args",
"[",
"i",
"]",
";",
"logger",
".",
"trace",
"(",
"\"Argument[\"",
"+",
"i",
"+",
"\"] = \"",
"+",
"arg",
")",
";",
"if",
"(",
"arg",
".",
"equals",
"(",
"getArgumentName",
"(",
"ConfigurationOption",
".",
"APPLY_PLURAL_FORM",
".",
"optionName",
"(",
")",
")",
")",
")",
"{",
"globalConfiguration",
".",
"setApplyPluralForm",
"(",
"true",
")",
";",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"(",
"recognized",
"=",
"parseArgument",
"(",
"args",
",",
"i",
",",
"ConfigurationOption",
".",
"CONTROL",
")",
")",
"==",
"0",
"&&",
"(",
"recognized",
"=",
"parseArgument",
"(",
"args",
",",
"i",
",",
"ConfigurationOption",
".",
"SUMMARY",
")",
")",
"==",
"0",
"&&",
"(",
"recognized",
"=",
"parseArgument",
"(",
"args",
",",
"i",
",",
"ConfigurationOption",
".",
"COLLECTION_INTERFACE",
")",
")",
"==",
"0",
"// longer option name comes first\r",
"&&",
"(",
"recognized",
"=",
"parseArgument",
"(",
"args",
",",
"i",
",",
"ConfigurationOption",
".",
"COLLECTION_IMPLEMENTATION",
")",
")",
"==",
"0",
"&&",
"(",
"recognized",
"=",
"parseArgument",
"(",
"args",
",",
"i",
",",
"ConfigurationOption",
".",
"INSTANTIATION_MODE",
")",
")",
"==",
"0",
")",
"{",
"if",
"(",
"arg",
".",
"startsWith",
"(",
"getArgumentName",
"(",
"\"\"",
")",
")",
")",
"{",
"throw",
"new",
"BadCommandLineException",
"(",
"\"Invalid argument \"",
"+",
"arg",
")",
";",
"}",
"}",
"return",
"recognized",
";",
"}"
] | Parse and apply plugin configuration options.
@return number of consumed argument options | [
"Parse",
"and",
"apply",
"plugin",
"configuration",
"options",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/config/AbstractConfigurablePlugin.java#L150-L174 |
2,136 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/config/AbstractConfigurablePlugin.java | AbstractConfigurablePlugin.run | @Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) throws SAXException {
try {
runInternal(outline);
return true;
}
catch (IOException e) {
logger.error("Failed to read the file", e);
throw new SAXException(e);
}
catch (ClassNotFoundException e) {
logger.error("Invalid class", e);
throw new SAXException(e);
}
} | java | @Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) throws SAXException {
try {
runInternal(outline);
return true;
}
catch (IOException e) {
logger.error("Failed to read the file", e);
throw new SAXException(e);
}
catch (ClassNotFoundException e) {
logger.error("Invalid class", e);
throw new SAXException(e);
}
} | [
"@",
"Override",
"public",
"boolean",
"run",
"(",
"Outline",
"outline",
",",
"Options",
"opt",
",",
"ErrorHandler",
"errorHandler",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"runInternal",
"(",
"outline",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to read the file\"",
",",
"e",
")",
";",
"throw",
"new",
"SAXException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Invalid class\"",
",",
"e",
")",
";",
"throw",
"new",
"SAXException",
"(",
"e",
")",
";",
"}",
"}"
] | Implements exception handling. | [
"Implements",
"exception",
"handling",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/config/AbstractConfigurablePlugin.java#L260-L275 |
2,137 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/CommonUtils.java | CommonUtils.generableToString | public static final String generableToString(JGenerable generable) {
// There is hardly any clean universal way to get the value from e.g. JExpression except of serializing it.
// Compare JStringLiteral and JExp#dotclass().
Writer w = new StringWriter();
generable.generate(new JFormatter(w));
// FIXME: Hopefully nobody will put quotes into annotation member value.
return w.toString().replace("\"", "");
} | java | public static final String generableToString(JGenerable generable) {
// There is hardly any clean universal way to get the value from e.g. JExpression except of serializing it.
// Compare JStringLiteral and JExp#dotclass().
Writer w = new StringWriter();
generable.generate(new JFormatter(w));
// FIXME: Hopefully nobody will put quotes into annotation member value.
return w.toString().replace("\"", "");
} | [
"public",
"static",
"final",
"String",
"generableToString",
"(",
"JGenerable",
"generable",
")",
"{",
"// There is hardly any clean universal way to get the value from e.g. JExpression except of serializing it.",
"// Compare JStringLiteral and JExp#dotclass().",
"Writer",
"w",
"=",
"new",
"StringWriter",
"(",
")",
";",
"generable",
".",
"generate",
"(",
"new",
"JFormatter",
"(",
"w",
")",
")",
";",
"// FIXME: Hopefully nobody will put quotes into annotation member value.",
"return",
"w",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"\\\"\"",
",",
"\"\"",
")",
";",
"}"
] | Returns the string value of passed argument. | [
"Returns",
"the",
"string",
"value",
"of",
"passed",
"argument",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/CommonUtils.java#L159-L168 |
2,138 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/CommonUtils.java | CommonUtils.getXsdDeclaration | public static XSDeclaration getXsdDeclaration(CPropertyInfo propertyInfo) {
XSComponent schemaComponent = propertyInfo.getSchemaComponent();
if (!(schemaComponent instanceof XSParticle)) {
// XSComplexType for example:
return null;
}
XSTerm term = ((XSParticle) schemaComponent).getTerm();
if (!(term instanceof XSDeclaration)) {
// XSModelGroup for example:
return null;
}
return (XSDeclaration) term;
} | java | public static XSDeclaration getXsdDeclaration(CPropertyInfo propertyInfo) {
XSComponent schemaComponent = propertyInfo.getSchemaComponent();
if (!(schemaComponent instanceof XSParticle)) {
// XSComplexType for example:
return null;
}
XSTerm term = ((XSParticle) schemaComponent).getTerm();
if (!(term instanceof XSDeclaration)) {
// XSModelGroup for example:
return null;
}
return (XSDeclaration) term;
} | [
"public",
"static",
"XSDeclaration",
"getXsdDeclaration",
"(",
"CPropertyInfo",
"propertyInfo",
")",
"{",
"XSComponent",
"schemaComponent",
"=",
"propertyInfo",
".",
"getSchemaComponent",
"(",
")",
";",
"if",
"(",
"!",
"(",
"schemaComponent",
"instanceof",
"XSParticle",
")",
")",
"{",
"// XSComplexType for example:",
"return",
"null",
";",
"}",
"XSTerm",
"term",
"=",
"(",
"(",
"XSParticle",
")",
"schemaComponent",
")",
".",
"getTerm",
"(",
")",
";",
"if",
"(",
"!",
"(",
"term",
"instanceof",
"XSDeclaration",
")",
")",
"{",
"// XSModelGroup for example:",
"return",
"null",
";",
"}",
"return",
"(",
"XSDeclaration",
")",
"term",
";",
"}"
] | Returns XSD declaration of given property. | [
"Returns",
"XSD",
"declaration",
"of",
"given",
"property",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/CommonUtils.java#L241-L257 |
2,139 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/config/GlobalConfiguration.java | GlobalConfiguration.readControlFile | void readControlFile(String fileName) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
try {
controlList.clear();
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
int separatorIndex = line.indexOf('=');
if (separatorIndex <= 0) {
logger.warn("Control file line \"" + line + "\" is invalid as does not have '=' separator.");
continue;
}
String className = line.substring(0, separatorIndex);
ControlMode controlMode;
try {
controlMode = ControlMode.valueOf(line.substring(separatorIndex + 1).trim().toUpperCase());
}
catch (IllegalArgumentException e) {
logger.warn("Control file line \"" + line + "\" is invalid as control mode is unknown.");
continue;
}
controlList.add(new ControlEntry(
className.startsWith("/") && className.endsWith("/") && className.length() > 2
? Pattern.compile(className.substring(1, className.length() - 1))
: Pattern.compile(className, Pattern.LITERAL),
controlMode));
}
configurationValues.put(ConfigurationOption.CONTROL, fileName);
}
finally {
reader.close();
}
} | java | void readControlFile(String fileName) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
try {
controlList.clear();
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
int separatorIndex = line.indexOf('=');
if (separatorIndex <= 0) {
logger.warn("Control file line \"" + line + "\" is invalid as does not have '=' separator.");
continue;
}
String className = line.substring(0, separatorIndex);
ControlMode controlMode;
try {
controlMode = ControlMode.valueOf(line.substring(separatorIndex + 1).trim().toUpperCase());
}
catch (IllegalArgumentException e) {
logger.warn("Control file line \"" + line + "\" is invalid as control mode is unknown.");
continue;
}
controlList.add(new ControlEntry(
className.startsWith("/") && className.endsWith("/") && className.length() > 2
? Pattern.compile(className.substring(1, className.length() - 1))
: Pattern.compile(className, Pattern.LITERAL),
controlMode));
}
configurationValues.put(ConfigurationOption.CONTROL, fileName);
}
finally {
reader.close();
}
} | [
"void",
"readControlFile",
"(",
"String",
"fileName",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"fileName",
")",
")",
";",
"try",
"{",
"controlList",
".",
"clear",
"(",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"if",
"(",
"line",
".",
"isEmpty",
"(",
")",
"||",
"line",
".",
"startsWith",
"(",
"\"#\"",
")",
")",
"{",
"continue",
";",
"}",
"int",
"separatorIndex",
"=",
"line",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"separatorIndex",
"<=",
"0",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Control file line \\\"\"",
"+",
"line",
"+",
"\"\\\" is invalid as does not have '=' separator.\"",
")",
";",
"continue",
";",
"}",
"String",
"className",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"separatorIndex",
")",
";",
"ControlMode",
"controlMode",
";",
"try",
"{",
"controlMode",
"=",
"ControlMode",
".",
"valueOf",
"(",
"line",
".",
"substring",
"(",
"separatorIndex",
"+",
"1",
")",
".",
"trim",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Control file line \\\"\"",
"+",
"line",
"+",
"\"\\\" is invalid as control mode is unknown.\"",
")",
";",
"continue",
";",
"}",
"controlList",
".",
"add",
"(",
"new",
"ControlEntry",
"(",
"className",
".",
"startsWith",
"(",
"\"/\"",
")",
"&&",
"className",
".",
"endsWith",
"(",
"\"/\"",
")",
"&&",
"className",
".",
"length",
"(",
")",
">",
"2",
"?",
"Pattern",
".",
"compile",
"(",
"className",
".",
"substring",
"(",
"1",
",",
"className",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
":",
"Pattern",
".",
"compile",
"(",
"className",
",",
"Pattern",
".",
"LITERAL",
")",
",",
"controlMode",
")",
")",
";",
"}",
"configurationValues",
".",
"put",
"(",
"ConfigurationOption",
".",
"CONTROL",
",",
"fileName",
")",
";",
"}",
"finally",
"{",
"reader",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Parse the given control file and initialize this config appropriately. | [
"Parse",
"the",
"given",
"control",
"file",
"and",
"initialize",
"this",
"config",
"appropriately",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/config/GlobalConfiguration.java#L43-L84 |
2,140 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java | XmlElementWrapperPlugin.createScopedFactoryMethods | private int createScopedFactoryMethods(JCodeModel codeModel, JDefinedClass factoryClass,
Collection<ScopedElementInfo> scopedElementInfos, JDefinedClass targetClass,
JClass xmlElementDeclModelClass, JClass jaxbElementModelClass, JClass qNameModelClass) {
int createdMethods = 0;
NEXT: for (ScopedElementInfo info : scopedElementInfos) {
String dotClazz = targetClass.fullName() + ".class";
// First check that such factory method has not yet been created. It can be the case if target class
// is substituted with e.g. two candidates, each candidate having a field with the same name.
// FIXME: Could it be the case that these two fields have different namespaces?
for (JMethod method : factoryClass.methods()) {
JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);
JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");
JExpression name = getAnnotationMemberExpression(xmlElementDeclAnnotation, "name");
if (scope != null && dotClazz.equals(generableToString(scope))
&& generableToString(info.name).equals(generableToString(name))) {
continue NEXT;
}
}
// Generate the scoped factory method:
// @XmlElementDecl(..., scope = T.class)
// public JAXBElement<X> createT...(X value) { return new JAXBElement<...>(QNAME, X.class, T.class, value); }
StringBuilder methodName = new StringBuilder();
JDefinedClass container = targetClass;
// To avoid potential name conflicts method name starts with scope class name:
while (true) {
methodName.insert(0, container.name());
if (container.parentContainer().isClass()) {
container = (JDefinedClass) container.parentContainer();
}
else {
break;
}
}
methodName.insert(0, "create").append(NameConverter.standard.toPropertyName(generableToString(info.name)));
JClass jaxbElementType = jaxbElementModelClass.narrow(info.type);
JMethod method = factoryClass.method(JMod.PUBLIC, jaxbElementType, methodName.toString());
method.annotate(xmlElementDeclModelClass).param("namespace", info.namespace).param("name", info.name)
.param("scope", targetClass);
JInvocation qname = JExpr._new(qNameModelClass).arg(info.namespace).arg(info.name);
// The primitive type get boxed and cannot be a narrowed class. However in general case if this type
// is a collection (i.e. is narrowed), then it should be additionally casted to Class (e.g. "(Class) List.class").
JClass declaredType = info.type.boxify();
method.body()
._return(JExpr._new(jaxbElementType).arg(qname)
.arg(declaredType.erasure() == declaredType ? declaredType.dotclass()
: JExpr.cast(codeModel.ref(Class.class), declaredType.dotclass()))
.arg(targetClass.dotclass()).arg(method.param(info.type, "value")));
createdMethods++;
}
return createdMethods;
} | java | private int createScopedFactoryMethods(JCodeModel codeModel, JDefinedClass factoryClass,
Collection<ScopedElementInfo> scopedElementInfos, JDefinedClass targetClass,
JClass xmlElementDeclModelClass, JClass jaxbElementModelClass, JClass qNameModelClass) {
int createdMethods = 0;
NEXT: for (ScopedElementInfo info : scopedElementInfos) {
String dotClazz = targetClass.fullName() + ".class";
// First check that such factory method has not yet been created. It can be the case if target class
// is substituted with e.g. two candidates, each candidate having a field with the same name.
// FIXME: Could it be the case that these two fields have different namespaces?
for (JMethod method : factoryClass.methods()) {
JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);
JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");
JExpression name = getAnnotationMemberExpression(xmlElementDeclAnnotation, "name");
if (scope != null && dotClazz.equals(generableToString(scope))
&& generableToString(info.name).equals(generableToString(name))) {
continue NEXT;
}
}
// Generate the scoped factory method:
// @XmlElementDecl(..., scope = T.class)
// public JAXBElement<X> createT...(X value) { return new JAXBElement<...>(QNAME, X.class, T.class, value); }
StringBuilder methodName = new StringBuilder();
JDefinedClass container = targetClass;
// To avoid potential name conflicts method name starts with scope class name:
while (true) {
methodName.insert(0, container.name());
if (container.parentContainer().isClass()) {
container = (JDefinedClass) container.parentContainer();
}
else {
break;
}
}
methodName.insert(0, "create").append(NameConverter.standard.toPropertyName(generableToString(info.name)));
JClass jaxbElementType = jaxbElementModelClass.narrow(info.type);
JMethod method = factoryClass.method(JMod.PUBLIC, jaxbElementType, methodName.toString());
method.annotate(xmlElementDeclModelClass).param("namespace", info.namespace).param("name", info.name)
.param("scope", targetClass);
JInvocation qname = JExpr._new(qNameModelClass).arg(info.namespace).arg(info.name);
// The primitive type get boxed and cannot be a narrowed class. However in general case if this type
// is a collection (i.e. is narrowed), then it should be additionally casted to Class (e.g. "(Class) List.class").
JClass declaredType = info.type.boxify();
method.body()
._return(JExpr._new(jaxbElementType).arg(qname)
.arg(declaredType.erasure() == declaredType ? declaredType.dotclass()
: JExpr.cast(codeModel.ref(Class.class), declaredType.dotclass()))
.arg(targetClass.dotclass()).arg(method.param(info.type, "value")));
createdMethods++;
}
return createdMethods;
} | [
"private",
"int",
"createScopedFactoryMethods",
"(",
"JCodeModel",
"codeModel",
",",
"JDefinedClass",
"factoryClass",
",",
"Collection",
"<",
"ScopedElementInfo",
">",
"scopedElementInfos",
",",
"JDefinedClass",
"targetClass",
",",
"JClass",
"xmlElementDeclModelClass",
",",
"JClass",
"jaxbElementModelClass",
",",
"JClass",
"qNameModelClass",
")",
"{",
"int",
"createdMethods",
"=",
"0",
";",
"NEXT",
":",
"for",
"(",
"ScopedElementInfo",
"info",
":",
"scopedElementInfos",
")",
"{",
"String",
"dotClazz",
"=",
"targetClass",
".",
"fullName",
"(",
")",
"+",
"\".class\"",
";",
"// First check that such factory method has not yet been created. It can be the case if target class",
"// is substituted with e.g. two candidates, each candidate having a field with the same name.",
"// FIXME: Could it be the case that these two fields have different namespaces?",
"for",
"(",
"JMethod",
"method",
":",
"factoryClass",
".",
"methods",
"(",
")",
")",
"{",
"JAnnotationUse",
"xmlElementDeclAnnotation",
"=",
"getAnnotation",
"(",
"method",
",",
"xmlElementDeclModelClass",
")",
";",
"JExpression",
"scope",
"=",
"getAnnotationMemberExpression",
"(",
"xmlElementDeclAnnotation",
",",
"\"scope\"",
")",
";",
"JExpression",
"name",
"=",
"getAnnotationMemberExpression",
"(",
"xmlElementDeclAnnotation",
",",
"\"name\"",
")",
";",
"if",
"(",
"scope",
"!=",
"null",
"&&",
"dotClazz",
".",
"equals",
"(",
"generableToString",
"(",
"scope",
")",
")",
"&&",
"generableToString",
"(",
"info",
".",
"name",
")",
".",
"equals",
"(",
"generableToString",
"(",
"name",
")",
")",
")",
"{",
"continue",
"NEXT",
";",
"}",
"}",
"// Generate the scoped factory method:",
"// @XmlElementDecl(..., scope = T.class)",
"// public JAXBElement<X> createT...(X value) { return new JAXBElement<...>(QNAME, X.class, T.class, value); }",
"StringBuilder",
"methodName",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"JDefinedClass",
"container",
"=",
"targetClass",
";",
"// To avoid potential name conflicts method name starts with scope class name:",
"while",
"(",
"true",
")",
"{",
"methodName",
".",
"insert",
"(",
"0",
",",
"container",
".",
"name",
"(",
")",
")",
";",
"if",
"(",
"container",
".",
"parentContainer",
"(",
")",
".",
"isClass",
"(",
")",
")",
"{",
"container",
"=",
"(",
"JDefinedClass",
")",
"container",
".",
"parentContainer",
"(",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"methodName",
".",
"insert",
"(",
"0",
",",
"\"create\"",
")",
".",
"append",
"(",
"NameConverter",
".",
"standard",
".",
"toPropertyName",
"(",
"generableToString",
"(",
"info",
".",
"name",
")",
")",
")",
";",
"JClass",
"jaxbElementType",
"=",
"jaxbElementModelClass",
".",
"narrow",
"(",
"info",
".",
"type",
")",
";",
"JMethod",
"method",
"=",
"factoryClass",
".",
"method",
"(",
"JMod",
".",
"PUBLIC",
",",
"jaxbElementType",
",",
"methodName",
".",
"toString",
"(",
")",
")",
";",
"method",
".",
"annotate",
"(",
"xmlElementDeclModelClass",
")",
".",
"param",
"(",
"\"namespace\"",
",",
"info",
".",
"namespace",
")",
".",
"param",
"(",
"\"name\"",
",",
"info",
".",
"name",
")",
".",
"param",
"(",
"\"scope\"",
",",
"targetClass",
")",
";",
"JInvocation",
"qname",
"=",
"JExpr",
".",
"_new",
"(",
"qNameModelClass",
")",
".",
"arg",
"(",
"info",
".",
"namespace",
")",
".",
"arg",
"(",
"info",
".",
"name",
")",
";",
"// The primitive type get boxed and cannot be a narrowed class. However in general case if this type",
"// is a collection (i.e. is narrowed), then it should be additionally casted to Class (e.g. \"(Class) List.class\").",
"JClass",
"declaredType",
"=",
"info",
".",
"type",
".",
"boxify",
"(",
")",
";",
"method",
".",
"body",
"(",
")",
".",
"_return",
"(",
"JExpr",
".",
"_new",
"(",
"jaxbElementType",
")",
".",
"arg",
"(",
"qname",
")",
".",
"arg",
"(",
"declaredType",
".",
"erasure",
"(",
")",
"==",
"declaredType",
"?",
"declaredType",
".",
"dotclass",
"(",
")",
":",
"JExpr",
".",
"cast",
"(",
"codeModel",
".",
"ref",
"(",
"Class",
".",
"class",
")",
",",
"declaredType",
".",
"dotclass",
"(",
")",
")",
")",
".",
"arg",
"(",
"targetClass",
".",
"dotclass",
"(",
")",
")",
".",
"arg",
"(",
"method",
".",
"param",
"(",
"info",
".",
"type",
",",
"\"value\"",
")",
")",
")",
";",
"createdMethods",
"++",
";",
"}",
"return",
"createdMethods",
";",
"}"
] | Create additional factory methods with a new scope for elements that should be scoped.
@param targetClass
the class that is applied the transformation of properties
@param jaxbElementModelClass
TODO
@param qNameModelClass
TODO
@return number of created methods
@see com.sun.tools.xjc.generator.bean.ObjectFactoryGenerator | [
"Create",
"additional",
"factory",
"methods",
"with",
"a",
"new",
"scope",
"for",
"elements",
"that",
"should",
"be",
"scoped",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java#L584-L651 |
2,141 | dmak/jaxb-xew-plugin | src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java | XmlElementWrapperPlugin.deleteClass | private void deleteClass(Outline outline, JDefinedClass clazz) {
if (clazz.parentContainer().isClass()) {
// The candidate class is an inner class. Remove the class from its parent class.
JDefinedClass parentClass = (JDefinedClass) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from class " + parentClass.fullName());
for (Iterator<JDefinedClass> iter = parentClass.classes(); iter.hasNext();) {
if (iter.next().equals(clazz)) {
iter.remove();
break;
}
}
}
else {
// The candidate class is in a package. Remove the class from the package.
JPackage parentPackage = (JPackage) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from package " + parentPackage.name());
parentPackage.remove(clazz);
// And also remove the class from model.
for (Iterator<? extends ClassOutline> iter = outline.getClasses().iterator(); iter.hasNext();) {
ClassOutline classOutline = iter.next();
if (classOutline.implClass == clazz) {
outline.getModel().beans().remove(classOutline.target);
Set<Object> packageClasses = getPrivateField(classOutline._package(), "classes");
packageClasses.remove(classOutline);
iter.remove();
break;
}
}
}
} | java | private void deleteClass(Outline outline, JDefinedClass clazz) {
if (clazz.parentContainer().isClass()) {
// The candidate class is an inner class. Remove the class from its parent class.
JDefinedClass parentClass = (JDefinedClass) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from class " + parentClass.fullName());
for (Iterator<JDefinedClass> iter = parentClass.classes(); iter.hasNext();) {
if (iter.next().equals(clazz)) {
iter.remove();
break;
}
}
}
else {
// The candidate class is in a package. Remove the class from the package.
JPackage parentPackage = (JPackage) clazz.parentContainer();
writeSummary("\tRemoving class " + clazz.fullName() + " from package " + parentPackage.name());
parentPackage.remove(clazz);
// And also remove the class from model.
for (Iterator<? extends ClassOutline> iter = outline.getClasses().iterator(); iter.hasNext();) {
ClassOutline classOutline = iter.next();
if (classOutline.implClass == clazz) {
outline.getModel().beans().remove(classOutline.target);
Set<Object> packageClasses = getPrivateField(classOutline._package(), "classes");
packageClasses.remove(classOutline);
iter.remove();
break;
}
}
}
} | [
"private",
"void",
"deleteClass",
"(",
"Outline",
"outline",
",",
"JDefinedClass",
"clazz",
")",
"{",
"if",
"(",
"clazz",
".",
"parentContainer",
"(",
")",
".",
"isClass",
"(",
")",
")",
"{",
"// The candidate class is an inner class. Remove the class from its parent class.",
"JDefinedClass",
"parentClass",
"=",
"(",
"JDefinedClass",
")",
"clazz",
".",
"parentContainer",
"(",
")",
";",
"writeSummary",
"(",
"\"\\tRemoving class \"",
"+",
"clazz",
".",
"fullName",
"(",
")",
"+",
"\" from class \"",
"+",
"parentClass",
".",
"fullName",
"(",
")",
")",
";",
"for",
"(",
"Iterator",
"<",
"JDefinedClass",
">",
"iter",
"=",
"parentClass",
".",
"classes",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"if",
"(",
"iter",
".",
"next",
"(",
")",
".",
"equals",
"(",
"clazz",
")",
")",
"{",
"iter",
".",
"remove",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"// The candidate class is in a package. Remove the class from the package.",
"JPackage",
"parentPackage",
"=",
"(",
"JPackage",
")",
"clazz",
".",
"parentContainer",
"(",
")",
";",
"writeSummary",
"(",
"\"\\tRemoving class \"",
"+",
"clazz",
".",
"fullName",
"(",
")",
"+",
"\" from package \"",
"+",
"parentPackage",
".",
"name",
"(",
")",
")",
";",
"parentPackage",
".",
"remove",
"(",
"clazz",
")",
";",
"// And also remove the class from model.",
"for",
"(",
"Iterator",
"<",
"?",
"extends",
"ClassOutline",
">",
"iter",
"=",
"outline",
".",
"getClasses",
"(",
")",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ClassOutline",
"classOutline",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"classOutline",
".",
"implClass",
"==",
"clazz",
")",
"{",
"outline",
".",
"getModel",
"(",
")",
".",
"beans",
"(",
")",
".",
"remove",
"(",
"classOutline",
".",
"target",
")",
";",
"Set",
"<",
"Object",
">",
"packageClasses",
"=",
"getPrivateField",
"(",
"classOutline",
".",
"_package",
"(",
")",
",",
"\"classes\"",
")",
";",
"packageClasses",
".",
"remove",
"(",
"classOutline",
")",
";",
"iter",
".",
"remove",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Remove the given class from it's parent class or package it is defined in. | [
"Remove",
"the",
"given",
"class",
"from",
"it",
"s",
"parent",
"class",
"or",
"package",
"it",
"is",
"defined",
"in",
"."
] | d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3 | https://github.com/dmak/jaxb-xew-plugin/blob/d564d6bf8e50c46b056cdb4b46d1d4bee4adfbe3/src/main/java/com/sun/tools/xjc/addon/xew/XmlElementWrapperPlugin.java#L928-L962 |
2,142 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/deployment/EarDescriptorBuilder.java | EarDescriptorBuilder.render | public String render() {
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// root elements
doc = docBuilder.newDocument();
rootElement = doc.createElement("application");
Element element;
rootElement.setAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
rootElement.setAttribute("xsi:schemaLocation",
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd");
rootElement.setAttribute("version", "6");
doc.appendChild(rootElement);
element = doc.createElement("description");
element.setTextContent("Autogenerated deployment for " + basename);
rootElement.appendChild(element);
element = doc.createElement("display-name");
element.setTextContent(basename + "-full");
rootElement.appendChild(element);
for (String filename : ejbs) {
writeEjbModule(filename);
}
for (Map.Entry<String, String> entry : webs) {
writeWebModule(entry.getKey(), entry.getValue());
}
element = doc.createElement("library-directory");
element.setTextContent("lib");
rootElement.appendChild(element);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
StreamResult result = new StreamResult(bytes);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(source, result);
return bytes.toString();
} catch (TransformerException ex) {
throw new IllegalStateException(ex);
} catch (ParserConfigurationException ex) {
throw new IllegalStateException(ex);
}
} | java | public String render() {
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// root elements
doc = docBuilder.newDocument();
rootElement = doc.createElement("application");
Element element;
rootElement.setAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
rootElement.setAttribute("xsi:schemaLocation",
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd");
rootElement.setAttribute("version", "6");
doc.appendChild(rootElement);
element = doc.createElement("description");
element.setTextContent("Autogenerated deployment for " + basename);
rootElement.appendChild(element);
element = doc.createElement("display-name");
element.setTextContent(basename + "-full");
rootElement.appendChild(element);
for (String filename : ejbs) {
writeEjbModule(filename);
}
for (Map.Entry<String, String> entry : webs) {
writeWebModule(entry.getKey(), entry.getValue());
}
element = doc.createElement("library-directory");
element.setTextContent("lib");
rootElement.appendChild(element);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
StreamResult result = new StreamResult(bytes);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(source, result);
return bytes.toString();
} catch (TransformerException ex) {
throw new IllegalStateException(ex);
} catch (ParserConfigurationException ex) {
throw new IllegalStateException(ex);
}
} | [
"public",
"String",
"render",
"(",
")",
"{",
"try",
"{",
"DocumentBuilderFactory",
"docFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"docBuilder",
"=",
"docFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"// root elements",
"doc",
"=",
"docBuilder",
".",
"newDocument",
"(",
")",
";",
"rootElement",
"=",
"doc",
".",
"createElement",
"(",
"\"application\"",
")",
";",
"Element",
"element",
";",
"rootElement",
".",
"setAttribute",
"(",
"\"xmlns\"",
",",
"\"http://java.sun.com/xml/ns/javaee\"",
")",
";",
"rootElement",
".",
"setAttribute",
"(",
"\"xmlns:xsi\"",
",",
"\"http://www.w3.org/2001/XMLSchema-instance\"",
")",
";",
"rootElement",
".",
"setAttribute",
"(",
"\"xsi:schemaLocation\"",
",",
"\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\"",
")",
";",
"rootElement",
".",
"setAttribute",
"(",
"\"version\"",
",",
"\"6\"",
")",
";",
"doc",
".",
"appendChild",
"(",
"rootElement",
")",
";",
"element",
"=",
"doc",
".",
"createElement",
"(",
"\"description\"",
")",
";",
"element",
".",
"setTextContent",
"(",
"\"Autogenerated deployment for \"",
"+",
"basename",
")",
";",
"rootElement",
".",
"appendChild",
"(",
"element",
")",
";",
"element",
"=",
"doc",
".",
"createElement",
"(",
"\"display-name\"",
")",
";",
"element",
".",
"setTextContent",
"(",
"basename",
"+",
"\"-full\"",
")",
";",
"rootElement",
".",
"appendChild",
"(",
"element",
")",
";",
"for",
"(",
"String",
"filename",
":",
"ejbs",
")",
"{",
"writeEjbModule",
"(",
"filename",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"webs",
")",
"{",
"writeWebModule",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"element",
"=",
"doc",
".",
"createElement",
"(",
"\"library-directory\"",
")",
";",
"element",
".",
"setTextContent",
"(",
"\"lib\"",
")",
";",
"rootElement",
".",
"appendChild",
"(",
"element",
")",
";",
"TransformerFactory",
"transformerFactory",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"Transformer",
"transformer",
"=",
"transformerFactory",
".",
"newTransformer",
"(",
")",
";",
"DOMSource",
"source",
"=",
"new",
"DOMSource",
"(",
"doc",
")",
";",
"ByteArrayOutputStream",
"bytes",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"StreamResult",
"result",
"=",
"new",
"StreamResult",
"(",
"bytes",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"INDENT",
",",
"\"yes\"",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"\"{http://xml.apache.org/xslt}indent-amount\"",
",",
"\"4\"",
")",
";",
"transformer",
".",
"transform",
"(",
"source",
",",
"result",
")",
";",
"return",
"bytes",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"TransformerException",
"ex",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"ex",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"ex",
")",
";",
"}",
"}"
] | Renders application.xml filr for application.
@return aplication.xml as string | [
"Renders",
"application",
".",
"xml",
"filr",
"for",
"application",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/deployment/EarDescriptorBuilder.java#L132-L183 |
2,143 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/DeploymentClassFinder.java | DeploymentClassFinder.getDeploymentClass | static Class<?> getDeploymentClass(ArquillianDescriptor descriptor) {
Class<?> deploymentClass = getDeploymentClassFromConfig(descriptor);
if (deploymentClass == null) {
deploymentClass = getDeploymentClassFromAnnotation();
}
if (deploymentClass == null) {
log.warning("arquillian-suite-deployment: Cannot find configuration in arquillian.xml, nor class annotated with @ArquillianSuiteDeployment, will try standard way..");
}
return deploymentClass;
} | java | static Class<?> getDeploymentClass(ArquillianDescriptor descriptor) {
Class<?> deploymentClass = getDeploymentClassFromConfig(descriptor);
if (deploymentClass == null) {
deploymentClass = getDeploymentClassFromAnnotation();
}
if (deploymentClass == null) {
log.warning("arquillian-suite-deployment: Cannot find configuration in arquillian.xml, nor class annotated with @ArquillianSuiteDeployment, will try standard way..");
}
return deploymentClass;
} | [
"static",
"Class",
"<",
"?",
">",
"getDeploymentClass",
"(",
"ArquillianDescriptor",
"descriptor",
")",
"{",
"Class",
"<",
"?",
">",
"deploymentClass",
"=",
"getDeploymentClassFromConfig",
"(",
"descriptor",
")",
";",
"if",
"(",
"deploymentClass",
"==",
"null",
")",
"{",
"deploymentClass",
"=",
"getDeploymentClassFromAnnotation",
"(",
")",
";",
"}",
"if",
"(",
"deploymentClass",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"arquillian-suite-deployment: Cannot find configuration in arquillian.xml, nor class annotated with @ArquillianSuiteDeployment, will try standard way..\"",
")",
";",
"}",
"return",
"deploymentClass",
";",
"}"
] | Finds class to be used as global deployment.
@param descriptor ArquillianDescriptor
@return class to be used as global deployment. | [
"Finds",
"class",
"to",
"be",
"used",
"as",
"global",
"deployment",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/DeploymentClassFinder.java#L43-L52 |
2,144 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java | SuiteDeployer.startup | public void startup(@Observes(precedence = -100) final BeforeSuite event) {
if (extensionEnabled()) {
debug("Catching BeforeSuite event {0}", event.toString());
executeInClassScope(new Callable<Void>() {
@Override
public Void call() {
generateDeploymentEvent.fire(new GenerateDeployment(new TestClass(deploymentClass)));
suiteDeploymentScenario = classDeploymentScenario.get();
return null;
}
});
deployDeployments = true;
extendedSuiteContext.get().activate();
suiteDeploymentScenarioInstanceProducer.set(suiteDeploymentScenario);
}
} | java | public void startup(@Observes(precedence = -100) final BeforeSuite event) {
if (extensionEnabled()) {
debug("Catching BeforeSuite event {0}", event.toString());
executeInClassScope(new Callable<Void>() {
@Override
public Void call() {
generateDeploymentEvent.fire(new GenerateDeployment(new TestClass(deploymentClass)));
suiteDeploymentScenario = classDeploymentScenario.get();
return null;
}
});
deployDeployments = true;
extendedSuiteContext.get().activate();
suiteDeploymentScenarioInstanceProducer.set(suiteDeploymentScenario);
}
} | [
"public",
"void",
"startup",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"-",
"100",
")",
"final",
"BeforeSuite",
"event",
")",
"{",
"if",
"(",
"extensionEnabled",
"(",
")",
")",
"{",
"debug",
"(",
"\"Catching BeforeSuite event {0}\"",
",",
"event",
".",
"toString",
"(",
")",
")",
";",
"executeInClassScope",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"generateDeploymentEvent",
".",
"fire",
"(",
"new",
"GenerateDeployment",
"(",
"new",
"TestClass",
"(",
"deploymentClass",
")",
")",
")",
";",
"suiteDeploymentScenario",
"=",
"classDeploymentScenario",
".",
"get",
"(",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"deployDeployments",
"=",
"true",
";",
"extendedSuiteContext",
".",
"get",
"(",
")",
".",
"activate",
"(",
")",
";",
"suiteDeploymentScenarioInstanceProducer",
".",
"set",
"(",
"suiteDeploymentScenario",
")",
";",
"}",
"}"
] | Startup event.
@param event AfterStart event to catch | [
"Startup",
"event",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java#L147-L162 |
2,145 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java | SuiteDeployer.undeploy | public void undeploy(@Observes final BeforeStop event) {
if (extensionEnabled()) {
debug("Catching BeforeStop event {0}", event.toString());
undeployDeployments = true;
undeployEvent.fire(new UnDeployManagedDeployments());
}
} | java | public void undeploy(@Observes final BeforeStop event) {
if (extensionEnabled()) {
debug("Catching BeforeStop event {0}", event.toString());
undeployDeployments = true;
undeployEvent.fire(new UnDeployManagedDeployments());
}
} | [
"public",
"void",
"undeploy",
"(",
"@",
"Observes",
"final",
"BeforeStop",
"event",
")",
"{",
"if",
"(",
"extensionEnabled",
"(",
")",
")",
"{",
"debug",
"(",
"\"Catching BeforeStop event {0}\"",
",",
"event",
".",
"toString",
"(",
")",
")",
";",
"undeployDeployments",
"=",
"true",
";",
"undeployEvent",
".",
"fire",
"(",
"new",
"UnDeployManagedDeployments",
"(",
")",
")",
";",
"}",
"}"
] | Undeploy event.
@param event event to observe | [
"Undeploy",
"event",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java#L169-L175 |
2,146 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java | SuiteDeployer.executeInClassScope | private void executeInClassScope(Callable<Void> call) {
try {
classContext.get().activate(deploymentClass);
call.call();
} catch (Exception e) {
throw new RuntimeException("Could not invoke operation", e); // NOPMD
} finally {
classContext.get().deactivate();
}
} | java | private void executeInClassScope(Callable<Void> call) {
try {
classContext.get().activate(deploymentClass);
call.call();
} catch (Exception e) {
throw new RuntimeException("Could not invoke operation", e); // NOPMD
} finally {
classContext.get().deactivate();
}
} | [
"private",
"void",
"executeInClassScope",
"(",
"Callable",
"<",
"Void",
">",
"call",
")",
"{",
"try",
"{",
"classContext",
".",
"get",
"(",
")",
".",
"activate",
"(",
"deploymentClass",
")",
";",
"call",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not invoke operation\"",
",",
"e",
")",
";",
"// NOPMD",
"}",
"finally",
"{",
"classContext",
".",
"get",
"(",
")",
".",
"deactivate",
"(",
")",
";",
"}",
"}"
] | Calls operation in deployment class scope.
@param call Callable to call | [
"Calls",
"operation",
"in",
"deployment",
"class",
"scope",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java#L182-L191 |
2,147 | ingwarsw/arquillian-suite-extension | src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java | SuiteDeployer.debug | private void debug(String format, Object... message) {
Boolean DEBUG = Boolean.valueOf(System.getProperty("arquillian.debug"));
if (DEBUG) {
log.log(Level.WARNING, format, message);
}
} | java | private void debug(String format, Object... message) {
Boolean DEBUG = Boolean.valueOf(System.getProperty("arquillian.debug"));
if (DEBUG) {
log.log(Level.WARNING, format, message);
}
} | [
"private",
"void",
"debug",
"(",
"String",
"format",
",",
"Object",
"...",
"message",
")",
"{",
"Boolean",
"DEBUG",
"=",
"Boolean",
".",
"valueOf",
"(",
"System",
".",
"getProperty",
"(",
"\"arquillian.debug\"",
")",
")",
";",
"if",
"(",
"DEBUG",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"format",
",",
"message",
")",
";",
"}",
"}"
] | Prints debug message.
If arquillian.debug flag is set.
@param format format of message
@param message message objects to format | [
"Prints",
"debug",
"message",
"."
] | 93c9e542ead1d52f45e87b0632bb02ac11f693c8 | https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/SuiteDeployer.java#L201-L206 |
2,148 | gkopff/gson-javatime-serialisers | src/main/java/com/fatboyindustrial/gsonjavatime/Converters.java | Converters.registerAll | public static GsonBuilder registerAll(GsonBuilder builder)
{
if (builder == null) { throw new NullPointerException("builder cannot be null"); }
registerLocalDate(builder);
registerLocalDateTime(builder);
registerLocalTime(builder);
registerOffsetDateTime(builder);
registerOffsetTime(builder);
registerZonedDateTime(builder);
registerInstant(builder);
return builder;
} | java | public static GsonBuilder registerAll(GsonBuilder builder)
{
if (builder == null) { throw new NullPointerException("builder cannot be null"); }
registerLocalDate(builder);
registerLocalDateTime(builder);
registerLocalTime(builder);
registerOffsetDateTime(builder);
registerOffsetTime(builder);
registerZonedDateTime(builder);
registerInstant(builder);
return builder;
} | [
"public",
"static",
"GsonBuilder",
"registerAll",
"(",
"GsonBuilder",
"builder",
")",
"{",
"if",
"(",
"builder",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"builder cannot be null\"",
")",
";",
"}",
"registerLocalDate",
"(",
"builder",
")",
";",
"registerLocalDateTime",
"(",
"builder",
")",
";",
"registerLocalTime",
"(",
"builder",
")",
";",
"registerOffsetDateTime",
"(",
"builder",
")",
";",
"registerOffsetTime",
"(",
"builder",
")",
";",
"registerZonedDateTime",
"(",
"builder",
")",
";",
"registerInstant",
"(",
"builder",
")",
";",
"return",
"builder",
";",
"}"
] | Registers all the Java Time converters.
@param builder The GSON builder to register the converters with.
@return A reference to {@code builder}. | [
"Registers",
"all",
"the",
"Java",
"Time",
"converters",
"."
] | 273d706fa32df31821177375d837b83151cfc67e | https://github.com/gkopff/gson-javatime-serialisers/blob/273d706fa32df31821177375d837b83151cfc67e/src/main/java/com/fatboyindustrial/gsonjavatime/Converters.java#L70-L83 |
2,149 | ReactiveX/RxJavaReactiveStreams | rxjava-reactive-streams/src/main/java/rx/RxReactiveStreams.java | RxReactiveStreams.toPublisher | public static <T> Publisher<T> toPublisher(Completable completable) {
if (completable == null) {
throw new NullPointerException("completable");
}
return new CompletableAsPublisher<T>(completable);
} | java | public static <T> Publisher<T> toPublisher(Completable completable) {
if (completable == null) {
throw new NullPointerException("completable");
}
return new CompletableAsPublisher<T>(completable);
} | [
"public",
"static",
"<",
"T",
">",
"Publisher",
"<",
"T",
">",
"toPublisher",
"(",
"Completable",
"completable",
")",
"{",
"if",
"(",
"completable",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"completable\"",
")",
";",
"}",
"return",
"new",
"CompletableAsPublisher",
"<",
"T",
">",
"(",
"completable",
")",
";",
"}"
] | Converts an RxJava Completable into a Publisher that emits only onError or onComplete.
@param <T> the target value type
@param completable the Completable instance to convert
@return the new Publisher instance
@since 1.1
@throws NullPointerException if completable is null | [
"Converts",
"an",
"RxJava",
"Completable",
"into",
"a",
"Publisher",
"that",
"emits",
"only",
"onError",
"or",
"onComplete",
"."
] | 1c6a64de2c9f5c8bd6c798bd1f53513d214aea30 | https://github.com/ReactiveX/RxJavaReactiveStreams/blob/1c6a64de2c9f5c8bd6c798bd1f53513d214aea30/rxjava-reactive-streams/src/main/java/rx/RxReactiveStreams.java#L84-L89 |
2,150 | ReactiveX/RxJavaReactiveStreams | rxjava-reactive-streams/src/main/java/rx/RxReactiveStreams.java | RxReactiveStreams.toCompletable | public static Completable toCompletable(Publisher<?> publisher) {
if (publisher == null) {
throw new NullPointerException("publisher");
}
return Completable.create(new PublisherAsCompletable(publisher));
} | java | public static Completable toCompletable(Publisher<?> publisher) {
if (publisher == null) {
throw new NullPointerException("publisher");
}
return Completable.create(new PublisherAsCompletable(publisher));
} | [
"public",
"static",
"Completable",
"toCompletable",
"(",
"Publisher",
"<",
"?",
">",
"publisher",
")",
"{",
"if",
"(",
"publisher",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"publisher\"",
")",
";",
"}",
"return",
"Completable",
".",
"create",
"(",
"new",
"PublisherAsCompletable",
"(",
"publisher",
")",
")",
";",
"}"
] | Converst a Publisher into a Completable by ignoring all onNext values and emitting
onError or onComplete only.
@param publisher the Publisher instance to convert
@return the Completable instance
@since 1.1
@throws NullPointerException if publisher is null | [
"Converst",
"a",
"Publisher",
"into",
"a",
"Completable",
"by",
"ignoring",
"all",
"onNext",
"values",
"and",
"emitting",
"onError",
"or",
"onComplete",
"only",
"."
] | 1c6a64de2c9f5c8bd6c798bd1f53513d214aea30 | https://github.com/ReactiveX/RxJavaReactiveStreams/blob/1c6a64de2c9f5c8bd6c798bd1f53513d214aea30/rxjava-reactive-streams/src/main/java/rx/RxReactiveStreams.java#L99-L104 |
2,151 | hudomju/android-swipe-to-dismiss-undo | library/src/main/java/com/hudomju/swipe/SwipeToDismissTouchListener.java | SwipeToDismissTouchListener.undoPendingDismiss | public boolean undoPendingDismiss() {
boolean existPendingDismisses = existPendingDismisses();
if (existPendingDismisses) {
mPendingDismiss.rowContainer.undoContainer.setVisibility(View.GONE);
mPendingDismiss.rowContainer.dataContainer
.animate()
.translationX(0)
.alpha(1)
.setDuration(mAnimationTime)
.setListener(null);
mPendingDismiss = null;
}
return existPendingDismisses;
} | java | public boolean undoPendingDismiss() {
boolean existPendingDismisses = existPendingDismisses();
if (existPendingDismisses) {
mPendingDismiss.rowContainer.undoContainer.setVisibility(View.GONE);
mPendingDismiss.rowContainer.dataContainer
.animate()
.translationX(0)
.alpha(1)
.setDuration(mAnimationTime)
.setListener(null);
mPendingDismiss = null;
}
return existPendingDismisses;
} | [
"public",
"boolean",
"undoPendingDismiss",
"(",
")",
"{",
"boolean",
"existPendingDismisses",
"=",
"existPendingDismisses",
"(",
")",
";",
"if",
"(",
"existPendingDismisses",
")",
"{",
"mPendingDismiss",
".",
"rowContainer",
".",
"undoContainer",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"mPendingDismiss",
".",
"rowContainer",
".",
"dataContainer",
".",
"animate",
"(",
")",
".",
"translationX",
"(",
"0",
")",
".",
"alpha",
"(",
"1",
")",
".",
"setDuration",
"(",
"mAnimationTime",
")",
".",
"setListener",
"(",
"null",
")",
";",
"mPendingDismiss",
"=",
"null",
";",
"}",
"return",
"existPendingDismisses",
";",
"}"
] | If a view was dismissed and the undo container is showing it will undo and make the data
container reappear.
@return whether there were any pending rows to be dismissed. | [
"If",
"a",
"view",
"was",
"dismissed",
"and",
"the",
"undo",
"container",
"is",
"showing",
"it",
"will",
"undo",
"and",
"make",
"the",
"data",
"container",
"reappear",
"."
] | e9995ec797d77de9986a7d184a4c0a2a814612e1 | https://github.com/hudomju/android-swipe-to-dismiss-undo/blob/e9995ec797d77de9986a7d184a4c0a2a814612e1/library/src/main/java/com/hudomju/swipe/SwipeToDismissTouchListener.java#L450-L463 |
2,152 | mklemm/jaxb2-rich-contract-plugin | src/main/java/com/kscs/util/plugins/xjc/GroupInterfacePlugin.java | GroupInterfacePlugin.generateDummyGroupUsages | private void generateDummyGroupUsages(final Options opts) throws BadCommandLineException {
try {
final Transformer transformer = GroupInterfacePlugin.TRANSFORMER_FACTORY.newTransformer();
final XPath xPath = GroupInterfacePlugin.X_PATH_FACTORY.newXPath();
final MappingNamespaceContext namespaceContext = new MappingNamespaceContext()
.add("xs", Namespaces.XS_NS)
.add("kscs", Namespaces.KSCS_BINDINGS_NS)
.add("jxb", Namespaces.JAXB_NS);
xPath.setNamespaceContext(namespaceContext);
final XPathExpression attGroupExpression = xPath.compile("/xs:schema/xs:attributeGroup");
final XPathExpression modelGroupExpression = xPath.compile("/xs:schema/xs:group");
final XPathExpression targetNamespaceExpression = xPath.compile("/xs:schema/@targetNamespace");
final Map<String, List<String>> includeMappings = findIncludeMappings(xPath, opts.getGrammars());
final List<InputSource> newGrammars = new ArrayList<>();
for (final InputSource grammarSource : opts.getGrammars()) {
final Document grammar = copyInputSource(grammarSource);
final String declaredTargetNamespaceUri = targetNamespaceExpression.evaluate(grammar);
for (final String targetNamespaceUri : declaredTargetNamespaceUri == null ? includeMappings.get(grammarSource.getSystemId()) : Collections.singletonList(declaredTargetNamespaceUri)) {
final NodeList attGroupNodes = (NodeList)attGroupExpression.evaluate(grammar, XPathConstants.NODESET);
final NodeList modelGroupNodes = (NodeList)modelGroupExpression.evaluate(grammar, XPathConstants.NODESET);
final Groups currentGroups = new Groups(targetNamespaceUri);
for (int i = 0; i < attGroupNodes.getLength(); i++) {
final Element node = (Element)attGroupNodes.item(i);
currentGroups.attGroupNames.add(node.getAttribute("name"));
}
for (int i = 0; i < modelGroupNodes.getLength(); i++) {
final Element node = (Element)modelGroupNodes.item(i);
currentGroups.modelGroupNames.add(node.getAttribute("name"));
}
final InputSource newSchema = generateImplementationSchema(opts, transformer, currentGroups, grammarSource.getSystemId());
if (newSchema != null) {
newGrammars.add(newSchema);
}
}
}
for (final InputSource newGrammar : newGrammars) {
opts.addGrammar(newGrammar);
}
} catch (final Exception e) {
throw new BadCommandLineException(getMessage("error.plugin-setup", e));
}
} | java | private void generateDummyGroupUsages(final Options opts) throws BadCommandLineException {
try {
final Transformer transformer = GroupInterfacePlugin.TRANSFORMER_FACTORY.newTransformer();
final XPath xPath = GroupInterfacePlugin.X_PATH_FACTORY.newXPath();
final MappingNamespaceContext namespaceContext = new MappingNamespaceContext()
.add("xs", Namespaces.XS_NS)
.add("kscs", Namespaces.KSCS_BINDINGS_NS)
.add("jxb", Namespaces.JAXB_NS);
xPath.setNamespaceContext(namespaceContext);
final XPathExpression attGroupExpression = xPath.compile("/xs:schema/xs:attributeGroup");
final XPathExpression modelGroupExpression = xPath.compile("/xs:schema/xs:group");
final XPathExpression targetNamespaceExpression = xPath.compile("/xs:schema/@targetNamespace");
final Map<String, List<String>> includeMappings = findIncludeMappings(xPath, opts.getGrammars());
final List<InputSource> newGrammars = new ArrayList<>();
for (final InputSource grammarSource : opts.getGrammars()) {
final Document grammar = copyInputSource(grammarSource);
final String declaredTargetNamespaceUri = targetNamespaceExpression.evaluate(grammar);
for (final String targetNamespaceUri : declaredTargetNamespaceUri == null ? includeMappings.get(grammarSource.getSystemId()) : Collections.singletonList(declaredTargetNamespaceUri)) {
final NodeList attGroupNodes = (NodeList)attGroupExpression.evaluate(grammar, XPathConstants.NODESET);
final NodeList modelGroupNodes = (NodeList)modelGroupExpression.evaluate(grammar, XPathConstants.NODESET);
final Groups currentGroups = new Groups(targetNamespaceUri);
for (int i = 0; i < attGroupNodes.getLength(); i++) {
final Element node = (Element)attGroupNodes.item(i);
currentGroups.attGroupNames.add(node.getAttribute("name"));
}
for (int i = 0; i < modelGroupNodes.getLength(); i++) {
final Element node = (Element)modelGroupNodes.item(i);
currentGroups.modelGroupNames.add(node.getAttribute("name"));
}
final InputSource newSchema = generateImplementationSchema(opts, transformer, currentGroups, grammarSource.getSystemId());
if (newSchema != null) {
newGrammars.add(newSchema);
}
}
}
for (final InputSource newGrammar : newGrammars) {
opts.addGrammar(newGrammar);
}
} catch (final Exception e) {
throw new BadCommandLineException(getMessage("error.plugin-setup", e));
}
} | [
"private",
"void",
"generateDummyGroupUsages",
"(",
"final",
"Options",
"opts",
")",
"throws",
"BadCommandLineException",
"{",
"try",
"{",
"final",
"Transformer",
"transformer",
"=",
"GroupInterfacePlugin",
".",
"TRANSFORMER_FACTORY",
".",
"newTransformer",
"(",
")",
";",
"final",
"XPath",
"xPath",
"=",
"GroupInterfacePlugin",
".",
"X_PATH_FACTORY",
".",
"newXPath",
"(",
")",
";",
"final",
"MappingNamespaceContext",
"namespaceContext",
"=",
"new",
"MappingNamespaceContext",
"(",
")",
".",
"add",
"(",
"\"xs\"",
",",
"Namespaces",
".",
"XS_NS",
")",
".",
"add",
"(",
"\"kscs\"",
",",
"Namespaces",
".",
"KSCS_BINDINGS_NS",
")",
".",
"add",
"(",
"\"jxb\"",
",",
"Namespaces",
".",
"JAXB_NS",
")",
";",
"xPath",
".",
"setNamespaceContext",
"(",
"namespaceContext",
")",
";",
"final",
"XPathExpression",
"attGroupExpression",
"=",
"xPath",
".",
"compile",
"(",
"\"/xs:schema/xs:attributeGroup\"",
")",
";",
"final",
"XPathExpression",
"modelGroupExpression",
"=",
"xPath",
".",
"compile",
"(",
"\"/xs:schema/xs:group\"",
")",
";",
"final",
"XPathExpression",
"targetNamespaceExpression",
"=",
"xPath",
".",
"compile",
"(",
"\"/xs:schema/@targetNamespace\"",
")",
";",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"includeMappings",
"=",
"findIncludeMappings",
"(",
"xPath",
",",
"opts",
".",
"getGrammars",
"(",
")",
")",
";",
"final",
"List",
"<",
"InputSource",
">",
"newGrammars",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"InputSource",
"grammarSource",
":",
"opts",
".",
"getGrammars",
"(",
")",
")",
"{",
"final",
"Document",
"grammar",
"=",
"copyInputSource",
"(",
"grammarSource",
")",
";",
"final",
"String",
"declaredTargetNamespaceUri",
"=",
"targetNamespaceExpression",
".",
"evaluate",
"(",
"grammar",
")",
";",
"for",
"(",
"final",
"String",
"targetNamespaceUri",
":",
"declaredTargetNamespaceUri",
"==",
"null",
"?",
"includeMappings",
".",
"get",
"(",
"grammarSource",
".",
"getSystemId",
"(",
")",
")",
":",
"Collections",
".",
"singletonList",
"(",
"declaredTargetNamespaceUri",
")",
")",
"{",
"final",
"NodeList",
"attGroupNodes",
"=",
"(",
"NodeList",
")",
"attGroupExpression",
".",
"evaluate",
"(",
"grammar",
",",
"XPathConstants",
".",
"NODESET",
")",
";",
"final",
"NodeList",
"modelGroupNodes",
"=",
"(",
"NodeList",
")",
"modelGroupExpression",
".",
"evaluate",
"(",
"grammar",
",",
"XPathConstants",
".",
"NODESET",
")",
";",
"final",
"Groups",
"currentGroups",
"=",
"new",
"Groups",
"(",
"targetNamespaceUri",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attGroupNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Element",
"node",
"=",
"(",
"Element",
")",
"attGroupNodes",
".",
"item",
"(",
"i",
")",
";",
"currentGroups",
".",
"attGroupNames",
".",
"add",
"(",
"node",
".",
"getAttribute",
"(",
"\"name\"",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"modelGroupNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Element",
"node",
"=",
"(",
"Element",
")",
"modelGroupNodes",
".",
"item",
"(",
"i",
")",
";",
"currentGroups",
".",
"modelGroupNames",
".",
"add",
"(",
"node",
".",
"getAttribute",
"(",
"\"name\"",
")",
")",
";",
"}",
"final",
"InputSource",
"newSchema",
"=",
"generateImplementationSchema",
"(",
"opts",
",",
"transformer",
",",
"currentGroups",
",",
"grammarSource",
".",
"getSystemId",
"(",
")",
")",
";",
"if",
"(",
"newSchema",
"!=",
"null",
")",
"{",
"newGrammars",
".",
"add",
"(",
"newSchema",
")",
";",
"}",
"}",
"}",
"for",
"(",
"final",
"InputSource",
"newGrammar",
":",
"newGrammars",
")",
"{",
"opts",
".",
"addGrammar",
"(",
"newGrammar",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BadCommandLineException",
"(",
"getMessage",
"(",
"\"error.plugin-setup\"",
",",
"e",
")",
")",
";",
"}",
"}"
] | Generates dummy complexTypes that implement the interface generated from group decls.
These complexTypes will be transformed into classes by the default code generator.
Later, this plugin will transform the classes into interface declarations.
This approach avoids tedious re-implementation of the property generation code,
with all the effects of settings, options, and customizations, in this plugin.
@param opts Options given to XJC
@throws BadCommandLineException | [
"Generates",
"dummy",
"complexTypes",
"that",
"implement",
"the",
"interface",
"generated",
"from",
"group",
"decls",
".",
"These",
"complexTypes",
"will",
"be",
"transformed",
"into",
"classes",
"by",
"the",
"default",
"code",
"generator",
".",
"Later",
"this",
"plugin",
"will",
"transform",
"the",
"classes",
"into",
"interface",
"declarations",
".",
"This",
"approach",
"avoids",
"tedious",
"re",
"-",
"implementation",
"of",
"the",
"property",
"generation",
"code",
"with",
"all",
"the",
"effects",
"of",
"settings",
"options",
"and",
"customizations",
"in",
"this",
"plugin",
"."
] | 359d20abcc4913a598f6d8df3dd2c4078a11c731 | https://github.com/mklemm/jaxb2-rich-contract-plugin/blob/359d20abcc4913a598f6d8df3dd2c4078a11c731/src/main/java/com/kscs/util/plugins/xjc/GroupInterfacePlugin.java#L179-L220 |
2,153 | cketti/EmailIntentBuilder | library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java | EmailIntentBuilder.start | public boolean start() {
Intent emailIntent = build();
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
return false;
}
return true;
} | java | public boolean start() {
Intent emailIntent = build();
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
return false;
}
return true;
} | [
"public",
"boolean",
"start",
"(",
")",
"{",
"Intent",
"emailIntent",
"=",
"build",
"(",
")",
";",
"try",
"{",
"startActivity",
"(",
"emailIntent",
")",
";",
"}",
"catch",
"(",
"ActivityNotFoundException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Launch the email intent.
@return {@code false} if no activity to handle the email intent could be found; {@code true} otherwise | [
"Launch",
"the",
"email",
"intent",
"."
] | 81660eebd415a1a8f16824cba2d37f019034223e | https://github.com/cketti/EmailIntentBuilder/blob/81660eebd415a1a8f16824cba2d37f019034223e/library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java#L220-L229 |
2,154 | benjamin-bader/droptools | dropwizard-jooq/src/main/java/com/bendb/dropwizard/jooq/PostgresSupport.java | PostgresSupport.stringAgg | @Support({SQLDialect.POSTGRES})
public static Field<String> stringAgg(Field<String> field, String delimiter) {
return DSL.field("string_agg({0}, {1})", field.getDataType(), field, DSL.val(delimiter));
} | java | @Support({SQLDialect.POSTGRES})
public static Field<String> stringAgg(Field<String> field, String delimiter) {
return DSL.field("string_agg({0}, {1})", field.getDataType(), field, DSL.val(delimiter));
} | [
"@",
"Support",
"(",
"{",
"SQLDialect",
".",
"POSTGRES",
"}",
")",
"public",
"static",
"Field",
"<",
"String",
">",
"stringAgg",
"(",
"Field",
"<",
"String",
">",
"field",
",",
"String",
"delimiter",
")",
"{",
"return",
"DSL",
".",
"field",
"(",
"\"string_agg({0}, {1})\"",
",",
"field",
".",
"getDataType",
"(",
")",
",",
"field",
",",
"DSL",
".",
"val",
"(",
"delimiter",
")",
")",
";",
"}"
] | Joins a set of string values using the given delimiter.
@param field the field to be concatenated
@param delimiter the separating delimiter
@return a {@link Field} representing the joined string | [
"Joins",
"a",
"set",
"of",
"string",
"values",
"using",
"the",
"given",
"delimiter",
"."
] | f1964465d725dfb07a5b6eb16f7bbe794896d1e0 | https://github.com/benjamin-bader/droptools/blob/f1964465d725dfb07a5b6eb16f7bbe794896d1e0/dropwizard-jooq/src/main/java/com/bendb/dropwizard/jooq/PostgresSupport.java#L53-L56 |
2,155 | kamon-io/sigar-loader | core/src/main/java/kamon/sigar/SigarAgent.java | SigarAgent.configure | public static synchronized void configure(final String options,
final Instrumentation instrumentation) throws Exception {
if (SigarAgent.instrumentation != null) {
logger.severe("Duplicate agent setup attempt.");
return;
}
SigarAgent.options = options;
SigarAgent.instrumentation = instrumentation;
logger.info("Sigar loader options: " + options);
final File folder = new File(SigarProvisioner.discoverLocation(options));
SigarProvisioner.provision(folder);
} | java | public static synchronized void configure(final String options,
final Instrumentation instrumentation) throws Exception {
if (SigarAgent.instrumentation != null) {
logger.severe("Duplicate agent setup attempt.");
return;
}
SigarAgent.options = options;
SigarAgent.instrumentation = instrumentation;
logger.info("Sigar loader options: " + options);
final File folder = new File(SigarProvisioner.discoverLocation(options));
SigarProvisioner.provision(folder);
} | [
"public",
"static",
"synchronized",
"void",
"configure",
"(",
"final",
"String",
"options",
",",
"final",
"Instrumentation",
"instrumentation",
")",
"throws",
"Exception",
"{",
"if",
"(",
"SigarAgent",
".",
"instrumentation",
"!=",
"null",
")",
"{",
"logger",
".",
"severe",
"(",
"\"Duplicate agent setup attempt.\"",
")",
";",
"return",
";",
"}",
"SigarAgent",
".",
"options",
"=",
"options",
";",
"SigarAgent",
".",
"instrumentation",
"=",
"instrumentation",
";",
"logger",
".",
"info",
"(",
"\"Sigar loader options: \"",
"+",
"options",
")",
";",
"final",
"File",
"folder",
"=",
"new",
"File",
"(",
"SigarProvisioner",
".",
"discoverLocation",
"(",
"options",
")",
")",
";",
"SigarProvisioner",
".",
"provision",
"(",
"folder",
")",
";",
"}"
] | Agent mode configuration.
@param options
Agent command line options.
@param instrumentation
Injected JVM instrumentation instance.
@throws Exception
the exception | [
"Agent",
"mode",
"configuration",
"."
] | 83146fe9fd7581dea469b561a0226038af568477 | https://github.com/kamon-io/sigar-loader/blob/83146fe9fd7581dea469b561a0226038af568477/core/src/main/java/kamon/sigar/SigarAgent.java#L85-L102 |
2,156 | kamon-io/sigar-loader | core/src/main/java/kamon/sigar/SigarProvisioner.java | SigarProvisioner.isNativeLoaded | public static synchronized boolean isNativeLoaded() {
try {
return isSigarAlreadyLoaded();
} catch (final Throwable e) {
try {
final Sigar sigar = new Sigar();
sigar.getPid();
sigar.close();
return true;
} catch (final Throwable ex) {
return false;
}
}
} | java | public static synchronized boolean isNativeLoaded() {
try {
return isSigarAlreadyLoaded();
} catch (final Throwable e) {
try {
final Sigar sigar = new Sigar();
sigar.getPid();
sigar.close();
return true;
} catch (final Throwable ex) {
return false;
}
}
} | [
"public",
"static",
"synchronized",
"boolean",
"isNativeLoaded",
"(",
")",
"{",
"try",
"{",
"return",
"isSigarAlreadyLoaded",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"e",
")",
"{",
"try",
"{",
"final",
"Sigar",
"sigar",
"=",
"new",
"Sigar",
"(",
")",
";",
"sigar",
".",
"getPid",
"(",
")",
";",
"sigar",
".",
"close",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] | Verify if sigar native library is loaded and operational.
@return true, if is native library loaded. | [
"Verify",
"if",
"sigar",
"native",
"library",
"is",
"loaded",
"and",
"operational",
"."
] | 83146fe9fd7581dea469b561a0226038af568477 | https://github.com/kamon-io/sigar-loader/blob/83146fe9fd7581dea469b561a0226038af568477/core/src/main/java/kamon/sigar/SigarProvisioner.java#L113-L126 |
2,157 | kamon-io/sigar-loader | core/src/main/java/kamon/sigar/SigarProvisioner.java | SigarProvisioner.provision | public static synchronized void provision(final File folder)
throws Exception {
if (isNativeLoaded()) {
logger.warning("Sigar library is already provisioned.");
return;
}
if (!folder.exists()) {
folder.mkdirs();
}
final SigarLoader sigarLoader = new SigarLoader(Sigar.class);
/** Library name for given architecture. */
final String libraryName = sigarLoader.getLibraryName();
/** Library location embedded in the jar class path. */
final String sourcePath = "/" + LIB_DIR + "/" + libraryName;
/** Absolute path to the extracted library the on file system. */
final File targetPath = new File(folder, libraryName).getAbsoluteFile();
/** Extract library form the jar to the local file system. */
final InputStream sourceStream = SigarProvisioner.class
.getResourceAsStream(sourcePath);
final OutputStream targetStream = new FileOutputStream(targetPath);
transfer(sourceStream, targetStream);
sourceStream.close();
targetStream.close();
/** Load library via absolute path. */
final String libraryPath = targetPath.getAbsolutePath();
System.load(libraryPath);
/** Tell sigar loader that the library is already loaded. */
System.setProperty("org.hyperic.sigar.path", "-");
sigarLoader.load();
logger.info("Sigar library provisioned: " + libraryPath);
} | java | public static synchronized void provision(final File folder)
throws Exception {
if (isNativeLoaded()) {
logger.warning("Sigar library is already provisioned.");
return;
}
if (!folder.exists()) {
folder.mkdirs();
}
final SigarLoader sigarLoader = new SigarLoader(Sigar.class);
/** Library name for given architecture. */
final String libraryName = sigarLoader.getLibraryName();
/** Library location embedded in the jar class path. */
final String sourcePath = "/" + LIB_DIR + "/" + libraryName;
/** Absolute path to the extracted library the on file system. */
final File targetPath = new File(folder, libraryName).getAbsoluteFile();
/** Extract library form the jar to the local file system. */
final InputStream sourceStream = SigarProvisioner.class
.getResourceAsStream(sourcePath);
final OutputStream targetStream = new FileOutputStream(targetPath);
transfer(sourceStream, targetStream);
sourceStream.close();
targetStream.close();
/** Load library via absolute path. */
final String libraryPath = targetPath.getAbsolutePath();
System.load(libraryPath);
/** Tell sigar loader that the library is already loaded. */
System.setProperty("org.hyperic.sigar.path", "-");
sigarLoader.load();
logger.info("Sigar library provisioned: " + libraryPath);
} | [
"public",
"static",
"synchronized",
"void",
"provision",
"(",
"final",
"File",
"folder",
")",
"throws",
"Exception",
"{",
"if",
"(",
"isNativeLoaded",
"(",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"\"Sigar library is already provisioned.\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"folder",
".",
"exists",
"(",
")",
")",
"{",
"folder",
".",
"mkdirs",
"(",
")",
";",
"}",
"final",
"SigarLoader",
"sigarLoader",
"=",
"new",
"SigarLoader",
"(",
"Sigar",
".",
"class",
")",
";",
"/** Library name for given architecture. */",
"final",
"String",
"libraryName",
"=",
"sigarLoader",
".",
"getLibraryName",
"(",
")",
";",
"/** Library location embedded in the jar class path. */",
"final",
"String",
"sourcePath",
"=",
"\"/\"",
"+",
"LIB_DIR",
"+",
"\"/\"",
"+",
"libraryName",
";",
"/** Absolute path to the extracted library the on file system. */",
"final",
"File",
"targetPath",
"=",
"new",
"File",
"(",
"folder",
",",
"libraryName",
")",
".",
"getAbsoluteFile",
"(",
")",
";",
"/** Extract library form the jar to the local file system. */",
"final",
"InputStream",
"sourceStream",
"=",
"SigarProvisioner",
".",
"class",
".",
"getResourceAsStream",
"(",
"sourcePath",
")",
";",
"final",
"OutputStream",
"targetStream",
"=",
"new",
"FileOutputStream",
"(",
"targetPath",
")",
";",
"transfer",
"(",
"sourceStream",
",",
"targetStream",
")",
";",
"sourceStream",
".",
"close",
"(",
")",
";",
"targetStream",
".",
"close",
"(",
")",
";",
"/** Load library via absolute path. */",
"final",
"String",
"libraryPath",
"=",
"targetPath",
".",
"getAbsolutePath",
"(",
")",
";",
"System",
".",
"load",
"(",
"libraryPath",
")",
";",
"/** Tell sigar loader that the library is already loaded. */",
"System",
".",
"setProperty",
"(",
"\"org.hyperic.sigar.path\"",
",",
"\"-\"",
")",
";",
"sigarLoader",
".",
"load",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Sigar library provisioned: \"",
"+",
"libraryPath",
")",
";",
"}"
] | Extract and load native sigar library in the provided folder.
@param folder
Library extraction folder.
@throws Exception
The provisioning failure exception. | [
"Extract",
"and",
"load",
"native",
"sigar",
"library",
"in",
"the",
"provided",
"folder",
"."
] | 83146fe9fd7581dea469b561a0226038af568477 | https://github.com/kamon-io/sigar-loader/blob/83146fe9fd7581dea469b561a0226038af568477/core/src/main/java/kamon/sigar/SigarProvisioner.java#L146-L187 |
2,158 | kamon-io/sigar-loader | core/src/main/java/kamon/sigar/SigarProvisioner.java | SigarProvisioner.transfer | public static void transfer(final InputStream input,
final OutputStream output) throws Exception {
final byte[] data = new byte[SIZE];
while (true) {
final int count = input.read(data, 0, SIZE);
if (count == EOF) {
break;
}
output.write(data, 0, count);
}
} | java | public static void transfer(final InputStream input,
final OutputStream output) throws Exception {
final byte[] data = new byte[SIZE];
while (true) {
final int count = input.read(data, 0, SIZE);
if (count == EOF) {
break;
}
output.write(data, 0, count);
}
} | [
"public",
"static",
"void",
"transfer",
"(",
"final",
"InputStream",
"input",
",",
"final",
"OutputStream",
"output",
")",
"throws",
"Exception",
"{",
"final",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"SIZE",
"]",
";",
"while",
"(",
"true",
")",
"{",
"final",
"int",
"count",
"=",
"input",
".",
"read",
"(",
"data",
",",
"0",
",",
"SIZE",
")",
";",
"if",
"(",
"count",
"==",
"EOF",
")",
"{",
"break",
";",
"}",
"output",
".",
"write",
"(",
"data",
",",
"0",
",",
"count",
")",
";",
"}",
"}"
] | Perform stream copy.
@param input
The input stream.
@param output
The output stream.
@throws Exception
The stream copy failure exception. | [
"Perform",
"stream",
"copy",
"."
] | 83146fe9fd7581dea469b561a0226038af568477 | https://github.com/kamon-io/sigar-loader/blob/83146fe9fd7581dea469b561a0226038af568477/core/src/main/java/kamon/sigar/SigarProvisioner.java#L205-L215 |
2,159 | kefirfromperm/kefirbb | src/org/kefirsf/bb/conf/Code.java | Code.addPattern | public void addPattern(Pattern pattern) {
if (patterns == null) {
patterns = new ArrayList<Pattern>();
}
patterns.add(pattern);
} | java | public void addPattern(Pattern pattern) {
if (patterns == null) {
patterns = new ArrayList<Pattern>();
}
patterns.add(pattern);
} | [
"public",
"void",
"addPattern",
"(",
"Pattern",
"pattern",
")",
"{",
"if",
"(",
"patterns",
"==",
"null",
")",
"{",
"patterns",
"=",
"new",
"ArrayList",
"<",
"Pattern",
">",
"(",
")",
";",
"}",
"patterns",
".",
"add",
"(",
"pattern",
")",
";",
"}"
] | Add a pattern to the list of patterns.
@param pattern a pattern | [
"Add",
"a",
"pattern",
"to",
"the",
"list",
"of",
"patterns",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/conf/Code.java#L128-L134 |
2,160 | kefirfromperm/kefirbb | src/org/kefirsf/bb/conf/Code.java | Code.getPattern | @Deprecated
public Pattern getPattern() {
if (patterns != null && !patterns.isEmpty()) {
return patterns.get(0);
} else {
return null;
}
} | java | @Deprecated
public Pattern getPattern() {
if (patterns != null && !patterns.isEmpty()) {
return patterns.get(0);
} else {
return null;
}
} | [
"@",
"Deprecated",
"public",
"Pattern",
"getPattern",
"(",
")",
"{",
"if",
"(",
"patterns",
"!=",
"null",
"&&",
"!",
"patterns",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"patterns",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get pattern for text parsing
@return pattern definition object | [
"Get",
"pattern",
"for",
"text",
"parsing"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/conf/Code.java#L150-L157 |
2,161 | kefirfromperm/kefirbb | src/org/kefirsf/bb/conf/Code.java | Code.setPattern | @Deprecated
public void setPattern(Pattern pattern) {
patterns = new ArrayList<Pattern>(1);
patterns.add(pattern);
} | java | @Deprecated
public void setPattern(Pattern pattern) {
patterns = new ArrayList<Pattern>(1);
patterns.add(pattern);
} | [
"@",
"Deprecated",
"public",
"void",
"setPattern",
"(",
"Pattern",
"pattern",
")",
"{",
"patterns",
"=",
"new",
"ArrayList",
"<",
"Pattern",
">",
"(",
"1",
")",
";",
"patterns",
".",
"add",
"(",
"pattern",
")",
";",
"}"
] | Set pattern for text parsing
@param pattern pattern definition object | [
"Set",
"pattern",
"for",
"text",
"parsing"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/conf/Code.java#L164-L168 |
2,162 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcBol.java | ProcBol.findIn | public int findIn(Source source) {
if (source.hasNext()) {
// maybe we are on the beginning of line already?
if (onBol(source)) {
return source.getOffset();
}
// If no find next line break
int index = findLineBreak(source);
if (index < 0) {
return -1;
}
// Skip line break 1 or 2 characters
index = skipLineBreak(source, index);
// If index is not on the end of text return it otherwise it's not a beginning of line.
if (index < source.length()) {
return index;
} else {
return -1;
}
} else {
return -1;
}
} | java | public int findIn(Source source) {
if (source.hasNext()) {
// maybe we are on the beginning of line already?
if (onBol(source)) {
return source.getOffset();
}
// If no find next line break
int index = findLineBreak(source);
if (index < 0) {
return -1;
}
// Skip line break 1 or 2 characters
index = skipLineBreak(source, index);
// If index is not on the end of text return it otherwise it's not a beginning of line.
if (index < source.length()) {
return index;
} else {
return -1;
}
} else {
return -1;
}
} | [
"public",
"int",
"findIn",
"(",
"Source",
"source",
")",
"{",
"if",
"(",
"source",
".",
"hasNext",
"(",
")",
")",
"{",
"// maybe we are on the beginning of line already?",
"if",
"(",
"onBol",
"(",
"source",
")",
")",
"{",
"return",
"source",
".",
"getOffset",
"(",
")",
";",
"}",
"// If no find next line break",
"int",
"index",
"=",
"findLineBreak",
"(",
"source",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"// Skip line break 1 or 2 characters",
"index",
"=",
"skipLineBreak",
"(",
"source",
",",
"index",
")",
";",
"// If index is not on the end of text return it otherwise it's not a beginning of line.",
"if",
"(",
"index",
"<",
"source",
".",
"length",
"(",
")",
")",
"{",
"return",
"index",
";",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}"
] | I strongly don't recommend to use tag bol as a terminator. | [
"I",
"strongly",
"don",
"t",
"recommend",
"to",
"use",
"tag",
"bol",
"as",
"a",
"terminator",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcBol.java#L21-L47 |
2,163 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcBol.java | ProcBol.onBol | private boolean onBol(Source source) {
int offset = source.getOffset();
if (offset == 0) {
return true;
} else {
char c = source.charAt(offset);
char p = source.charAt(offset - 1);
return c != '\n' && c != '\r' && (p == '\n' || p == '\r');
}
} | java | private boolean onBol(Source source) {
int offset = source.getOffset();
if (offset == 0) {
return true;
} else {
char c = source.charAt(offset);
char p = source.charAt(offset - 1);
return c != '\n' && c != '\r' && (p == '\n' || p == '\r');
}
} | [
"private",
"boolean",
"onBol",
"(",
"Source",
"source",
")",
"{",
"int",
"offset",
"=",
"source",
".",
"getOffset",
"(",
")",
";",
"if",
"(",
"offset",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"char",
"c",
"=",
"source",
".",
"charAt",
"(",
"offset",
")",
";",
"char",
"p",
"=",
"source",
".",
"charAt",
"(",
"offset",
"-",
"1",
")",
";",
"return",
"c",
"!=",
"'",
"'",
"&&",
"c",
"!=",
"'",
"'",
"&&",
"(",
"p",
"==",
"'",
"'",
"||",
"p",
"==",
"'",
"'",
")",
";",
"}",
"}"
] | Check we are on the beginning of line
@param source the text source
@return true if we are on the beginning of line | [
"Check",
"we",
"are",
"on",
"the",
"beginning",
"of",
"line"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcBol.java#L55-L64 |
2,164 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcBol.java | ProcBol.findLineBreak | private int findLineBreak(Source source) {
int index;
int n = source.find(AbstractEol.AN, false);
int r = source.find(AbstractEol.AR, false);
if (n >= 0 && r >= 0) {
index = Math.min(n, r);
} else if (n >= 0) {
index = n;
} else if (r >= 0) {
index = r;
} else {
index = -1;
}
return index;
} | java | private int findLineBreak(Source source) {
int index;
int n = source.find(AbstractEol.AN, false);
int r = source.find(AbstractEol.AR, false);
if (n >= 0 && r >= 0) {
index = Math.min(n, r);
} else if (n >= 0) {
index = n;
} else if (r >= 0) {
index = r;
} else {
index = -1;
}
return index;
} | [
"private",
"int",
"findLineBreak",
"(",
"Source",
"source",
")",
"{",
"int",
"index",
";",
"int",
"n",
"=",
"source",
".",
"find",
"(",
"AbstractEol",
".",
"AN",
",",
"false",
")",
";",
"int",
"r",
"=",
"source",
".",
"find",
"(",
"AbstractEol",
".",
"AR",
",",
"false",
")",
";",
"if",
"(",
"n",
">=",
"0",
"&&",
"r",
">=",
"0",
")",
"{",
"index",
"=",
"Math",
".",
"min",
"(",
"n",
",",
"r",
")",
";",
"}",
"else",
"if",
"(",
"n",
">=",
"0",
")",
"{",
"index",
"=",
"n",
";",
"}",
"else",
"if",
"(",
"r",
">=",
"0",
")",
"{",
"index",
"=",
"r",
";",
"}",
"else",
"{",
"index",
"=",
"-",
"1",
";",
"}",
"return",
"index",
";",
"}"
] | Find first input of line break
@param source the text source | [
"Find",
"first",
"input",
"of",
"line",
"break"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcBol.java#L71-L85 |
2,165 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcBol.java | ProcBol.skipLineBreak | private int skipLineBreak(Source source, final int offset) {
char p;
char c;
int index = offset;
p = source.charAt(index);
index++;
if (index < source.length()) {
c = source.charAt(index);
if ((c == '\n' || c == '\r') && c != p) {
index++;
}
}
return index;
} | java | private int skipLineBreak(Source source, final int offset) {
char p;
char c;
int index = offset;
p = source.charAt(index);
index++;
if (index < source.length()) {
c = source.charAt(index);
if ((c == '\n' || c == '\r') && c != p) {
index++;
}
}
return index;
} | [
"private",
"int",
"skipLineBreak",
"(",
"Source",
"source",
",",
"final",
"int",
"offset",
")",
"{",
"char",
"p",
";",
"char",
"c",
";",
"int",
"index",
"=",
"offset",
";",
"p",
"=",
"source",
".",
"charAt",
"(",
"index",
")",
";",
"index",
"++",
";",
"if",
"(",
"index",
"<",
"source",
".",
"length",
"(",
")",
")",
"{",
"c",
"=",
"source",
".",
"charAt",
"(",
"index",
")",
";",
"if",
"(",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"&&",
"c",
"!=",
"p",
")",
"{",
"index",
"++",
";",
"}",
"}",
"return",
"index",
";",
"}"
] | Skip line break characters. '\r\n' for example
@param source text source
@param offset current index
@return new index | [
"Skip",
"line",
"break",
"characters",
".",
"\\",
"r",
"\\",
"n",
"for",
"example"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcBol.java#L94-L107 |
2,166 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/Context.java | Context.getAttribute | public Object getAttribute(String name) {
Object value = getLocalAttribute(name);
if (value == null && parent != null) {
value = parent.getAttribute(name);
}
return value;
} | java | public Object getAttribute(String name) {
Object value = getLocalAttribute(name);
if (value == null && parent != null) {
value = parent.getAttribute(name);
}
return value;
} | [
"public",
"Object",
"getAttribute",
"(",
"String",
"name",
")",
"{",
"Object",
"value",
"=",
"getLocalAttribute",
"(",
"name",
")",
";",
"if",
"(",
"value",
"==",
"null",
"&&",
"parent",
"!=",
"null",
")",
"{",
"value",
"=",
"parent",
".",
"getAttribute",
"(",
"name",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Get the context attribute. If attribute not exists in current context,
then context search the sttribute in parent context
@param name attribute name
@return attribute value | [
"Get",
"the",
"context",
"attribute",
".",
"If",
"attribute",
"not",
"exists",
"in",
"current",
"context",
"then",
"context",
"search",
"the",
"sttribute",
"in",
"parent",
"context"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/Context.java#L133-L139 |
2,167 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/Context.java | Context.setScope | public void setScope(ProcScope scope) {
this.scope = scope;
// Scope false memo
scopeFalseMemo = falseMemo.get(scope);
if (scopeFalseMemo == null) {
scopeFalseMemo = new IntSet();
falseMemo.put(scope, scopeFalseMemo);
}
} | java | public void setScope(ProcScope scope) {
this.scope = scope;
// Scope false memo
scopeFalseMemo = falseMemo.get(scope);
if (scopeFalseMemo == null) {
scopeFalseMemo = new IntSet();
falseMemo.put(scope, scopeFalseMemo);
}
} | [
"public",
"void",
"setScope",
"(",
"ProcScope",
"scope",
")",
"{",
"this",
".",
"scope",
"=",
"scope",
";",
"// Scope false memo",
"scopeFalseMemo",
"=",
"falseMemo",
".",
"get",
"(",
"scope",
")",
";",
"if",
"(",
"scopeFalseMemo",
"==",
"null",
")",
"{",
"scopeFalseMemo",
"=",
"new",
"IntSet",
"(",
")",
";",
"falseMemo",
".",
"put",
"(",
"scope",
",",
"scopeFalseMemo",
")",
";",
"}",
"}"
] | Set list of codes in current context
@param scope code scope | [
"Set",
"list",
"of",
"codes",
"in",
"current",
"context"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/Context.java#L156-L165 |
2,168 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcUrl.java | ProcUrl.preparePrefixes | private List<String> preparePrefixes() {
// Prepare prefixes for all schemas
List<String> prefixes = new ArrayList<String>(Schema.values().length + (local ? 3 : 0));
for (Schema schema : Schema.values()) {
prefixes.add(schema.getPrefix());
}
// For local URls prefixes are "./", "../", "/"
if (local) {
Collections.addAll(prefixes, LOCAL_PREFIXES);
}
return prefixes;
} | java | private List<String> preparePrefixes() {
// Prepare prefixes for all schemas
List<String> prefixes = new ArrayList<String>(Schema.values().length + (local ? 3 : 0));
for (Schema schema : Schema.values()) {
prefixes.add(schema.getPrefix());
}
// For local URls prefixes are "./", "../", "/"
if (local) {
Collections.addAll(prefixes, LOCAL_PREFIXES);
}
return prefixes;
} | [
"private",
"List",
"<",
"String",
">",
"preparePrefixes",
"(",
")",
"{",
"// Prepare prefixes for all schemas",
"List",
"<",
"String",
">",
"prefixes",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"Schema",
".",
"values",
"(",
")",
".",
"length",
"+",
"(",
"local",
"?",
"3",
":",
"0",
")",
")",
";",
"for",
"(",
"Schema",
"schema",
":",
"Schema",
".",
"values",
"(",
")",
")",
"{",
"prefixes",
".",
"add",
"(",
"schema",
".",
"getPrefix",
"(",
")",
")",
";",
"}",
"// For local URls prefixes are \"./\", \"../\", \"/\"",
"if",
"(",
"local",
")",
"{",
"Collections",
".",
"addAll",
"(",
"prefixes",
",",
"LOCAL_PREFIXES",
")",
";",
"}",
"return",
"prefixes",
";",
"}"
] | Prepare URL's prefixes.
@return list of schema prefixes and local prefixes if local URL are allowed. | [
"Prepare",
"URL",
"s",
"prefixes",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcUrl.java#L99-L111 |
2,169 | kefirfromperm/kefirbb | src/org/kefirsf/bb/conf/Scope.java | Scope.setCodes | public void setCodes(Set<Code> codes) {
Exceptions.nullArgument("codes", codes);
this.codes.clear();
this.codes.addAll(codes);
} | java | public void setCodes(Set<Code> codes) {
Exceptions.nullArgument("codes", codes);
this.codes.clear();
this.codes.addAll(codes);
} | [
"public",
"void",
"setCodes",
"(",
"Set",
"<",
"Code",
">",
"codes",
")",
"{",
"Exceptions",
".",
"nullArgument",
"(",
"\"codes\"",
",",
"codes",
")",
";",
"this",
".",
"codes",
".",
"clear",
"(",
")",
";",
"this",
".",
"codes",
".",
"addAll",
"(",
"codes",
")",
";",
"}"
] | Set codes.
@param codes set of codes | [
"Set",
"codes",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/conf/Scope.java#L200-L205 |
2,170 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcScope.java | ProcScope.cacheCodes | private void cacheCodes() {
Set<ProcCode> set = new HashSet<ProcCode>();
if (parent != null) {
set.addAll(Arrays.asList(parent.getCodes()));
}
if (scopeCodes != null) {
set.addAll(scopeCodes);
}
cachedCodes = set.toArray(new ProcCode[set.size()]);
Arrays.sort(
cachedCodes,
new Comparator<ProcCode>() {
public int compare(ProcCode code1, ProcCode code2) {
return code2.compareTo(code1);
}
}
);
for (ProcCode code : cachedCodes) {
hasCrazyCode = hasCrazyCode || !code.startsWithConstant();
hasCheck = hasCheck || code.containsCheck();
}
} | java | private void cacheCodes() {
Set<ProcCode> set = new HashSet<ProcCode>();
if (parent != null) {
set.addAll(Arrays.asList(parent.getCodes()));
}
if (scopeCodes != null) {
set.addAll(scopeCodes);
}
cachedCodes = set.toArray(new ProcCode[set.size()]);
Arrays.sort(
cachedCodes,
new Comparator<ProcCode>() {
public int compare(ProcCode code1, ProcCode code2) {
return code2.compareTo(code1);
}
}
);
for (ProcCode code : cachedCodes) {
hasCrazyCode = hasCrazyCode || !code.startsWithConstant();
hasCheck = hasCheck || code.containsCheck();
}
} | [
"private",
"void",
"cacheCodes",
"(",
")",
"{",
"Set",
"<",
"ProcCode",
">",
"set",
"=",
"new",
"HashSet",
"<",
"ProcCode",
">",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"set",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"parent",
".",
"getCodes",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"scopeCodes",
"!=",
"null",
")",
"{",
"set",
".",
"addAll",
"(",
"scopeCodes",
")",
";",
"}",
"cachedCodes",
"=",
"set",
".",
"toArray",
"(",
"new",
"ProcCode",
"[",
"set",
".",
"size",
"(",
")",
"]",
")",
";",
"Arrays",
".",
"sort",
"(",
"cachedCodes",
",",
"new",
"Comparator",
"<",
"ProcCode",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"ProcCode",
"code1",
",",
"ProcCode",
"code2",
")",
"{",
"return",
"code2",
".",
"compareTo",
"(",
"code1",
")",
";",
"}",
"}",
")",
";",
"for",
"(",
"ProcCode",
"code",
":",
"cachedCodes",
")",
"{",
"hasCrazyCode",
"=",
"hasCrazyCode",
"||",
"!",
"code",
".",
"startsWithConstant",
"(",
")",
";",
"hasCheck",
"=",
"hasCheck",
"||",
"code",
".",
"containsCheck",
"(",
")",
";",
"}",
"}"
] | Cache scope codes. Join scope codes with parent scope codes. | [
"Cache",
"scope",
"codes",
".",
"Join",
"scope",
"codes",
"with",
"parent",
"scope",
"codes",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcScope.java#L188-L213 |
2,171 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ProcessorBuilder.java | ProcessorBuilder.build | public BBProcessor build() {
this.scopes = new HashMap<Scope, ProcScope>();
this.codes = new HashMap<Code, ProcCode>();
patternElementFactory.cleanConstants();
BBProcessor processor = new BBProcessor();
processor.setScope(createScope(conf.getRootScope()));
processor.setPrefix(createTemplate(conf.getPrefix()));
processor.setSuffix(createTemplate(conf.getSuffix()));
processor.setParams(conf.getParams());
processor.setConstants(patternElementFactory.getConstants());
processor.setNestingLimit(conf.getNestingLimit());
processor.setPropagateNestingException(conf.isPropagateNestingException());
// Init scopes
for (ProcScope scope : scopes.values()) {
scope.init();
}
return processor;
} | java | public BBProcessor build() {
this.scopes = new HashMap<Scope, ProcScope>();
this.codes = new HashMap<Code, ProcCode>();
patternElementFactory.cleanConstants();
BBProcessor processor = new BBProcessor();
processor.setScope(createScope(conf.getRootScope()));
processor.setPrefix(createTemplate(conf.getPrefix()));
processor.setSuffix(createTemplate(conf.getSuffix()));
processor.setParams(conf.getParams());
processor.setConstants(patternElementFactory.getConstants());
processor.setNestingLimit(conf.getNestingLimit());
processor.setPropagateNestingException(conf.isPropagateNestingException());
// Init scopes
for (ProcScope scope : scopes.values()) {
scope.init();
}
return processor;
} | [
"public",
"BBProcessor",
"build",
"(",
")",
"{",
"this",
".",
"scopes",
"=",
"new",
"HashMap",
"<",
"Scope",
",",
"ProcScope",
">",
"(",
")",
";",
"this",
".",
"codes",
"=",
"new",
"HashMap",
"<",
"Code",
",",
"ProcCode",
">",
"(",
")",
";",
"patternElementFactory",
".",
"cleanConstants",
"(",
")",
";",
"BBProcessor",
"processor",
"=",
"new",
"BBProcessor",
"(",
")",
";",
"processor",
".",
"setScope",
"(",
"createScope",
"(",
"conf",
".",
"getRootScope",
"(",
")",
")",
")",
";",
"processor",
".",
"setPrefix",
"(",
"createTemplate",
"(",
"conf",
".",
"getPrefix",
"(",
")",
")",
")",
";",
"processor",
".",
"setSuffix",
"(",
"createTemplate",
"(",
"conf",
".",
"getSuffix",
"(",
")",
")",
")",
";",
"processor",
".",
"setParams",
"(",
"conf",
".",
"getParams",
"(",
")",
")",
";",
"processor",
".",
"setConstants",
"(",
"patternElementFactory",
".",
"getConstants",
"(",
")",
")",
";",
"processor",
".",
"setNestingLimit",
"(",
"conf",
".",
"getNestingLimit",
"(",
")",
")",
";",
"processor",
".",
"setPropagateNestingException",
"(",
"conf",
".",
"isPropagateNestingException",
"(",
")",
")",
";",
"// Init scopes",
"for",
"(",
"ProcScope",
"scope",
":",
"scopes",
".",
"values",
"(",
")",
")",
"{",
"scope",
".",
"init",
"(",
")",
";",
"}",
"return",
"processor",
";",
"}"
] | Build an processor. | [
"Build",
"an",
"processor",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ProcessorBuilder.java#L27-L47 |
2,172 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ProcessorBuilder.java | ProcessorBuilder.createScope | ProcScope createScope(Scope scope) {
ProcScope created = scopes.get(scope);
if (created == null) {
created = new ProcScope(scope.getName());
scopes.put(scope, created);
created.setStrong(scope.isStrong());
created.setIgnoreText(scope.isIgnoreText());
if (scope.getParent() != null) {
created.setParent(createScope(scope.getParent()));
}
Set<ProcCode> scopeCodes = new HashSet<ProcCode>();
for (Code code : scope.getCodes()) {
scopeCodes.add(createCode(code));
}
created.setScopeCodes(scopeCodes);
created.setMin(scope.getMin());
created.setMax(scope.getMax());
}
return created;
} | java | ProcScope createScope(Scope scope) {
ProcScope created = scopes.get(scope);
if (created == null) {
created = new ProcScope(scope.getName());
scopes.put(scope, created);
created.setStrong(scope.isStrong());
created.setIgnoreText(scope.isIgnoreText());
if (scope.getParent() != null) {
created.setParent(createScope(scope.getParent()));
}
Set<ProcCode> scopeCodes = new HashSet<ProcCode>();
for (Code code : scope.getCodes()) {
scopeCodes.add(createCode(code));
}
created.setScopeCodes(scopeCodes);
created.setMin(scope.getMin());
created.setMax(scope.getMax());
}
return created;
} | [
"ProcScope",
"createScope",
"(",
"Scope",
"scope",
")",
"{",
"ProcScope",
"created",
"=",
"scopes",
".",
"get",
"(",
"scope",
")",
";",
"if",
"(",
"created",
"==",
"null",
")",
"{",
"created",
"=",
"new",
"ProcScope",
"(",
"scope",
".",
"getName",
"(",
")",
")",
";",
"scopes",
".",
"put",
"(",
"scope",
",",
"created",
")",
";",
"created",
".",
"setStrong",
"(",
"scope",
".",
"isStrong",
"(",
")",
")",
";",
"created",
".",
"setIgnoreText",
"(",
"scope",
".",
"isIgnoreText",
"(",
")",
")",
";",
"if",
"(",
"scope",
".",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"created",
".",
"setParent",
"(",
"createScope",
"(",
"scope",
".",
"getParent",
"(",
")",
")",
")",
";",
"}",
"Set",
"<",
"ProcCode",
">",
"scopeCodes",
"=",
"new",
"HashSet",
"<",
"ProcCode",
">",
"(",
")",
";",
"for",
"(",
"Code",
"code",
":",
"scope",
".",
"getCodes",
"(",
")",
")",
"{",
"scopeCodes",
".",
"add",
"(",
"createCode",
"(",
"code",
")",
")",
";",
"}",
"created",
".",
"setScopeCodes",
"(",
"scopeCodes",
")",
";",
"created",
".",
"setMin",
"(",
"scope",
".",
"getMin",
"(",
")",
")",
";",
"created",
".",
"setMax",
"(",
"scope",
".",
"getMax",
"(",
")",
")",
";",
"}",
"return",
"created",
";",
"}"
] | Find or create the scope.
@param scope the scope configuration
@return scope scope | [
"Find",
"or",
"create",
"the",
"scope",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ProcessorBuilder.java#L55-L74 |
2,173 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ProcessorBuilder.java | ProcessorBuilder.createCode | private ProcCode createCode(Code defCode) {
if (!defCode.hasPatterns()) {
throw new IllegalStateException("Field pattern can't be null.");
}
if (defCode.getTemplate() == null) {
throw new IllegalStateException("Field template can't be null.");
}
ProcCode code = codes.get(defCode);
if (code == null) {
List<Pattern> confPatterns = defCode.getPatterns();
List<ProcPattern> procPatterns = new ArrayList<ProcPattern>(confPatterns.size());
for (Pattern confPattern : confPatterns) {
procPatterns.add(createPattern(confPattern));
}
code = new ProcCode(
procPatterns,
createTemplate(defCode.getTemplate()),
defCode.getName(),
defCode.getPriority(),
defCode.isTransparent()
);
codes.put(defCode, code);
}
return code;
} | java | private ProcCode createCode(Code defCode) {
if (!defCode.hasPatterns()) {
throw new IllegalStateException("Field pattern can't be null.");
}
if (defCode.getTemplate() == null) {
throw new IllegalStateException("Field template can't be null.");
}
ProcCode code = codes.get(defCode);
if (code == null) {
List<Pattern> confPatterns = defCode.getPatterns();
List<ProcPattern> procPatterns = new ArrayList<ProcPattern>(confPatterns.size());
for (Pattern confPattern : confPatterns) {
procPatterns.add(createPattern(confPattern));
}
code = new ProcCode(
procPatterns,
createTemplate(defCode.getTemplate()),
defCode.getName(),
defCode.getPriority(),
defCode.isTransparent()
);
codes.put(defCode, code);
}
return code;
} | [
"private",
"ProcCode",
"createCode",
"(",
"Code",
"defCode",
")",
"{",
"if",
"(",
"!",
"defCode",
".",
"hasPatterns",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Field pattern can't be null.\"",
")",
";",
"}",
"if",
"(",
"defCode",
".",
"getTemplate",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Field template can't be null.\"",
")",
";",
"}",
"ProcCode",
"code",
"=",
"codes",
".",
"get",
"(",
"defCode",
")",
";",
"if",
"(",
"code",
"==",
"null",
")",
"{",
"List",
"<",
"Pattern",
">",
"confPatterns",
"=",
"defCode",
".",
"getPatterns",
"(",
")",
";",
"List",
"<",
"ProcPattern",
">",
"procPatterns",
"=",
"new",
"ArrayList",
"<",
"ProcPattern",
">",
"(",
"confPatterns",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Pattern",
"confPattern",
":",
"confPatterns",
")",
"{",
"procPatterns",
".",
"add",
"(",
"createPattern",
"(",
"confPattern",
")",
")",
";",
"}",
"code",
"=",
"new",
"ProcCode",
"(",
"procPatterns",
",",
"createTemplate",
"(",
"defCode",
".",
"getTemplate",
"(",
")",
")",
",",
"defCode",
".",
"getName",
"(",
")",
",",
"defCode",
".",
"getPriority",
"(",
")",
",",
"defCode",
".",
"isTransparent",
"(",
")",
")",
";",
"codes",
".",
"put",
"(",
"defCode",
",",
"code",
")",
";",
"}",
"return",
"code",
";",
"}"
] | Create code from this definition
@param defCode code definition
@return code object | [
"Create",
"code",
"from",
"this",
"definition"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ProcessorBuilder.java#L82-L110 |
2,174 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ProcessorBuilder.java | ProcessorBuilder.createTemplate | private ProcTemplate createTemplate(Template template) {
if (!template.isEmpty()) {
return new ProcTemplate(templateElementFactory.createTemplateList(template.getElements()));
} else {
return ProcTemplate.EMPTY;
}
} | java | private ProcTemplate createTemplate(Template template) {
if (!template.isEmpty()) {
return new ProcTemplate(templateElementFactory.createTemplateList(template.getElements()));
} else {
return ProcTemplate.EMPTY;
}
} | [
"private",
"ProcTemplate",
"createTemplate",
"(",
"Template",
"template",
")",
"{",
"if",
"(",
"!",
"template",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"ProcTemplate",
"(",
"templateElementFactory",
".",
"createTemplateList",
"(",
"template",
".",
"getElements",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"ProcTemplate",
".",
"EMPTY",
";",
"}",
"}"
] | Create a template from definition
@param template the template definition
@return template | [
"Create",
"a",
"template",
"from",
"definition"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ProcessorBuilder.java#L118-L124 |
2,175 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ProcessorBuilder.java | ProcessorBuilder.createPattern | private ProcPattern createPattern(Pattern pattern) {
if (pattern.isEmpty()) {
throw new IllegalStateException("Pattern elements list can't be empty.");
}
List<ProcPatternElement> elements = new ArrayList<ProcPatternElement>();
for (PatternElement element : pattern.getElements()) {
elements.add(patternElementFactory.create(element));
}
return new ProcPattern(elements);
} | java | private ProcPattern createPattern(Pattern pattern) {
if (pattern.isEmpty()) {
throw new IllegalStateException("Pattern elements list can't be empty.");
}
List<ProcPatternElement> elements = new ArrayList<ProcPatternElement>();
for (PatternElement element : pattern.getElements()) {
elements.add(patternElementFactory.create(element));
}
return new ProcPattern(elements);
} | [
"private",
"ProcPattern",
"createPattern",
"(",
"Pattern",
"pattern",
")",
"{",
"if",
"(",
"pattern",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Pattern elements list can't be empty.\"",
")",
";",
"}",
"List",
"<",
"ProcPatternElement",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"ProcPatternElement",
">",
"(",
")",
";",
"for",
"(",
"PatternElement",
"element",
":",
"pattern",
".",
"getElements",
"(",
")",
")",
"{",
"elements",
".",
"add",
"(",
"patternElementFactory",
".",
"create",
"(",
"element",
")",
")",
";",
"}",
"return",
"new",
"ProcPattern",
"(",
"elements",
")",
";",
"}"
] | Create a pattern for text parsing
@param pattern pattern definition
@return pattern pattern | [
"Create",
"a",
"pattern",
"for",
"text",
"parsing"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ProcessorBuilder.java#L132-L142 |
2,176 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/ProcVariable.java | ProcVariable.findIn | public int findIn(Source source) {
if (regex != null) {
Matcher matcher = regex.matcher(source.subToEnd());
if (matcher.find()) {
return source.getOffset() + matcher.start();
} else {
return -1;
}
} else {
return -1;
}
} | java | public int findIn(Source source) {
if (regex != null) {
Matcher matcher = regex.matcher(source.subToEnd());
if (matcher.find()) {
return source.getOffset() + matcher.start();
} else {
return -1;
}
} else {
return -1;
}
} | [
"public",
"int",
"findIn",
"(",
"Source",
"source",
")",
"{",
"if",
"(",
"regex",
"!=",
"null",
")",
"{",
"Matcher",
"matcher",
"=",
"regex",
".",
"matcher",
"(",
"source",
".",
"subToEnd",
"(",
")",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"return",
"source",
".",
"getOffset",
"(",
")",
"+",
"matcher",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}"
] | Find this element
@param source text source
@return start offset | [
"Find",
"this",
"element"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/ProcVariable.java#L118-L129 |
2,177 | kefirfromperm/kefirbb | src/org/kefirsf/bb/util/IntSet.java | IntSet.binarySearch | private static int binarySearch(int[] array, int toIndex, int key) {
int low = 0;
int high = toIndex - 1;
while (low <= high) {
int mid = (low + high) >>> 1;
int midVal = array[mid];
if (midVal < key) {
low = mid + 1;
} else if (midVal > key) {
high = mid - 1;
} else {
return mid; // key found
}
}
return -(low + 1); // key not found.
} | java | private static int binarySearch(int[] array, int toIndex, int key) {
int low = 0;
int high = toIndex - 1;
while (low <= high) {
int mid = (low + high) >>> 1;
int midVal = array[mid];
if (midVal < key) {
low = mid + 1;
} else if (midVal > key) {
high = mid - 1;
} else {
return mid; // key found
}
}
return -(low + 1); // key not found.
} | [
"private",
"static",
"int",
"binarySearch",
"(",
"int",
"[",
"]",
"array",
",",
"int",
"toIndex",
",",
"int",
"key",
")",
"{",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"toIndex",
"-",
"1",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"int",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
">>>",
"1",
";",
"int",
"midVal",
"=",
"array",
"[",
"mid",
"]",
";",
"if",
"(",
"midVal",
"<",
"key",
")",
"{",
"low",
"=",
"mid",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"midVal",
">",
"key",
")",
"{",
"high",
"=",
"mid",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"mid",
";",
"// key found",
"}",
"}",
"return",
"-",
"(",
"low",
"+",
"1",
")",
";",
"// key not found.",
"}"
] | Realisation of binary search algorithm. It is in JDK 1.6.0 but for
JDK 1.5.0 compatibility I added it there.
@param array array of integers values ordered by ascending
@param toIndex top break of array
@param key searched value
@return value index or -(index of position) | [
"Realisation",
"of",
"binary",
"search",
"algorithm",
".",
"It",
"is",
"in",
"JDK",
"1",
".",
"6",
".",
"0",
"but",
"for",
"JDK",
"1",
".",
"5",
".",
"0",
"compatibility",
"I",
"added",
"it",
"there",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/util/IntSet.java#L66-L83 |
2,178 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ConfigurationFactory.java | ConfigurationFactory.create | public Configuration create() {
Configuration configuration;
try {
InputStream stream = null;
try {
// Search the user configuration
stream = Utils.openResourceStream(DEFAULT_USER_CONFIGURATION_FILE);
// If user configuration not found then use default
if (stream == null) {
stream = Utils.openResourceStream(DEFAULT_CONFIGURATION_FILE);
}
if (stream != null) {
configuration = create(stream);
} else {
throw new TextProcessorFactoryException("Can't find or open default configuration resource.");
}
} finally {
if (stream != null) {
stream.close();
}
}
Properties properties = new Properties();
// Load properties from .property file
InputStream propertiesStream = null;
try {
propertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_FILE);
if (propertiesStream != null) {
properties.load(propertiesStream);
}
} finally {
if (propertiesStream != null) {
propertiesStream.close();
}
}
// Load properties from xml file
InputStream xmlPropertiesStream = null;
try {
xmlPropertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_XML_FILE);
if (xmlPropertiesStream != null) {
properties.loadFromXML(xmlPropertiesStream);
}
} finally {
if (xmlPropertiesStream != null) {
xmlPropertiesStream.close();
}
}
if (!properties.isEmpty()) {
Map<String, CharSequence> params = new HashMap<String, CharSequence>();
params.putAll(configuration.getParams());
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
Object key = entry.getKey();
if (key != null) {
params.put(key.toString(), entry.getValue().toString());
}
}
configuration.setParams(params);
}
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
return configuration;
} | java | public Configuration create() {
Configuration configuration;
try {
InputStream stream = null;
try {
// Search the user configuration
stream = Utils.openResourceStream(DEFAULT_USER_CONFIGURATION_FILE);
// If user configuration not found then use default
if (stream == null) {
stream = Utils.openResourceStream(DEFAULT_CONFIGURATION_FILE);
}
if (stream != null) {
configuration = create(stream);
} else {
throw new TextProcessorFactoryException("Can't find or open default configuration resource.");
}
} finally {
if (stream != null) {
stream.close();
}
}
Properties properties = new Properties();
// Load properties from .property file
InputStream propertiesStream = null;
try {
propertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_FILE);
if (propertiesStream != null) {
properties.load(propertiesStream);
}
} finally {
if (propertiesStream != null) {
propertiesStream.close();
}
}
// Load properties from xml file
InputStream xmlPropertiesStream = null;
try {
xmlPropertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_XML_FILE);
if (xmlPropertiesStream != null) {
properties.loadFromXML(xmlPropertiesStream);
}
} finally {
if (xmlPropertiesStream != null) {
xmlPropertiesStream.close();
}
}
if (!properties.isEmpty()) {
Map<String, CharSequence> params = new HashMap<String, CharSequence>();
params.putAll(configuration.getParams());
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
Object key = entry.getKey();
if (key != null) {
params.put(key.toString(), entry.getValue().toString());
}
}
configuration.setParams(params);
}
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
return configuration;
} | [
"public",
"Configuration",
"create",
"(",
")",
"{",
"Configuration",
"configuration",
";",
"try",
"{",
"InputStream",
"stream",
"=",
"null",
";",
"try",
"{",
"// Search the user configuration",
"stream",
"=",
"Utils",
".",
"openResourceStream",
"(",
"DEFAULT_USER_CONFIGURATION_FILE",
")",
";",
"// If user configuration not found then use default",
"if",
"(",
"stream",
"==",
"null",
")",
"{",
"stream",
"=",
"Utils",
".",
"openResourceStream",
"(",
"DEFAULT_CONFIGURATION_FILE",
")",
";",
"}",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"configuration",
"=",
"create",
"(",
"stream",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Can't find or open default configuration resource.\"",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"}",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"// Load properties from .property file",
"InputStream",
"propertiesStream",
"=",
"null",
";",
"try",
"{",
"propertiesStream",
"=",
"Utils",
".",
"openResourceStream",
"(",
"DEFAULT_PROPERTIES_FILE",
")",
";",
"if",
"(",
"propertiesStream",
"!=",
"null",
")",
"{",
"properties",
".",
"load",
"(",
"propertiesStream",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"propertiesStream",
"!=",
"null",
")",
"{",
"propertiesStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"// Load properties from xml file",
"InputStream",
"xmlPropertiesStream",
"=",
"null",
";",
"try",
"{",
"xmlPropertiesStream",
"=",
"Utils",
".",
"openResourceStream",
"(",
"DEFAULT_PROPERTIES_XML_FILE",
")",
";",
"if",
"(",
"xmlPropertiesStream",
"!=",
"null",
")",
"{",
"properties",
".",
"loadFromXML",
"(",
"xmlPropertiesStream",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"xmlPropertiesStream",
"!=",
"null",
")",
"{",
"xmlPropertiesStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"CharSequence",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CharSequence",
">",
"(",
")",
";",
"params",
".",
"putAll",
"(",
"configuration",
".",
"getParams",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"key",
".",
"toString",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"configuration",
".",
"setParams",
"(",
"params",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"return",
"configuration",
";",
"}"
] | Create the default bb-code processor.
@return Default bb-code processor
@throws TextProcessorFactoryException when can't read the default code set resource | [
"Create",
"the",
"default",
"bb",
"-",
"code",
"processor",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ConfigurationFactory.java#L70-L138 |
2,179 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ConfigurationFactory.java | ConfigurationFactory.createFromResource | public Configuration createFromResource(String resourceName) {
Exceptions.nullArgument("resourceName", resourceName);
Configuration configuration;
try {
InputStream stream = null;
try {
stream = Utils.openResourceStream(resourceName);
if (stream != null) {
configuration = create(stream);
} else {
throw new TextProcessorFactoryException("Can't find or open resource \"" + resourceName + "\".");
}
} finally {
if (stream != null) {
stream.close();
}
}
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
return configuration;
} | java | public Configuration createFromResource(String resourceName) {
Exceptions.nullArgument("resourceName", resourceName);
Configuration configuration;
try {
InputStream stream = null;
try {
stream = Utils.openResourceStream(resourceName);
if (stream != null) {
configuration = create(stream);
} else {
throw new TextProcessorFactoryException("Can't find or open resource \"" + resourceName + "\".");
}
} finally {
if (stream != null) {
stream.close();
}
}
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
return configuration;
} | [
"public",
"Configuration",
"createFromResource",
"(",
"String",
"resourceName",
")",
"{",
"Exceptions",
".",
"nullArgument",
"(",
"\"resourceName\"",
",",
"resourceName",
")",
";",
"Configuration",
"configuration",
";",
"try",
"{",
"InputStream",
"stream",
"=",
"null",
";",
"try",
"{",
"stream",
"=",
"Utils",
".",
"openResourceStream",
"(",
"resourceName",
")",
";",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"configuration",
"=",
"create",
"(",
"stream",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Can't find or open resource \\\"\"",
"+",
"resourceName",
"+",
"\"\\\".\"",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"return",
"configuration",
";",
"}"
] | Create the bb-processor using xml-configuration resource
@param resourceName name of resource file
@return bb-code processor
@throws TextProcessorFactoryException when can't find or read the resource or illegal config file | [
"Create",
"the",
"bb",
"-",
"processor",
"using",
"xml",
"-",
"configuration",
"resource"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ConfigurationFactory.java#L147-L171 |
2,180 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ConfigurationFactory.java | ConfigurationFactory.create | public Configuration create(File file) {
try {
Configuration configuration;
InputStream stream = new BufferedInputStream(new FileInputStream(file));
try {
configuration = create(stream);
} finally {
stream.close();
}
return configuration;
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
} | java | public Configuration create(File file) {
try {
Configuration configuration;
InputStream stream = new BufferedInputStream(new FileInputStream(file));
try {
configuration = create(stream);
} finally {
stream.close();
}
return configuration;
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
}
} | [
"public",
"Configuration",
"create",
"(",
"File",
"file",
")",
"{",
"try",
"{",
"Configuration",
"configuration",
";",
"InputStream",
"stream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"try",
"{",
"configuration",
"=",
"create",
"(",
"stream",
")",
";",
"}",
"finally",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"return",
"configuration",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"}"
] | Create the bb-code processor from file with XML-configuration.
@param file file with configuration
@return bb-code processor
@throws TextProcessorFactoryException any problems | [
"Create",
"the",
"bb",
"-",
"code",
"processor",
"from",
"file",
"with",
"XML",
"-",
"configuration",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ConfigurationFactory.java#L191-L204 |
2,181 | kefirfromperm/kefirbb | src/org/kefirsf/bb/ConfigurationFactory.java | ConfigurationFactory.create | public Configuration create(InputStream stream) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringElementContentWhitespace(true);
factory.setNamespaceAware(true);
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
Document document = documentBuilder.parse(stream);
return domConfigurationFactory.create(document);
} catch (ParserConfigurationException e) {
throw new TextProcessorFactoryException(e);
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
} catch (SAXException e) {
throw new TextProcessorFactoryException(e);
}
} | java | public Configuration create(InputStream stream) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringElementContentWhitespace(true);
factory.setNamespaceAware(true);
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
Document document = documentBuilder.parse(stream);
return domConfigurationFactory.create(document);
} catch (ParserConfigurationException e) {
throw new TextProcessorFactoryException(e);
} catch (IOException e) {
throw new TextProcessorFactoryException(e);
} catch (SAXException e) {
throw new TextProcessorFactoryException(e);
}
} | [
"public",
"Configuration",
"create",
"(",
"InputStream",
"stream",
")",
"{",
"try",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setValidating",
"(",
"false",
")",
";",
"factory",
".",
"setIgnoringElementContentWhitespace",
"(",
"true",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"DocumentBuilder",
"documentBuilder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"document",
"=",
"documentBuilder",
".",
"parse",
"(",
"stream",
")",
";",
"return",
"domConfigurationFactory",
".",
"create",
"(",
"document",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"e",
")",
";",
"}",
"}"
] | Create the bb-processor from XML InputStream
@param stream the input stream with XML
@return bb-code processor
@throws TextProcessorFactoryException when can't build Document | [
"Create",
"the",
"bb",
"-",
"processor",
"from",
"XML",
"InputStream"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/ConfigurationFactory.java#L213-L229 |
2,182 | kefirfromperm/kefirbb | src/org/kefirsf/bb/proc/BBProcessor.java | BBProcessor.setParams | public void setParams(Map<String, CharSequence> params) {
if (this.params == null) {
this.params = Collections.unmodifiableMap(params);
} else {
throw new IllegalStateException("Can't change parameters.");
}
} | java | public void setParams(Map<String, CharSequence> params) {
if (this.params == null) {
this.params = Collections.unmodifiableMap(params);
} else {
throw new IllegalStateException("Can't change parameters.");
}
} | [
"public",
"void",
"setParams",
"(",
"Map",
"<",
"String",
",",
"CharSequence",
">",
"params",
")",
"{",
"if",
"(",
"this",
".",
"params",
"==",
"null",
")",
"{",
"this",
".",
"params",
"=",
"Collections",
".",
"unmodifiableMap",
"(",
"params",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Can't change parameters.\"",
")",
";",
"}",
"}"
] | Set text processor parameters map.
@param params parameters | [
"Set",
"text",
"processor",
"parameters",
"map",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/proc/BBProcessor.java#L128-L134 |
2,183 | kefirfromperm/kefirbb | src/org/kefirsf/bb/PatternElementFactory.java | PatternElementFactory.create | private PatternConstant create(Constant constant) {
if (!constants.containsKey(constant)) {
constants.put(
constant,
new PatternConstant(constant.getValue(), constant.isIgnoreCase(), constant.isGhost())
);
}
return constants.get(constant);
} | java | private PatternConstant create(Constant constant) {
if (!constants.containsKey(constant)) {
constants.put(
constant,
new PatternConstant(constant.getValue(), constant.isIgnoreCase(), constant.isGhost())
);
}
return constants.get(constant);
} | [
"private",
"PatternConstant",
"create",
"(",
"Constant",
"constant",
")",
"{",
"if",
"(",
"!",
"constants",
".",
"containsKey",
"(",
"constant",
")",
")",
"{",
"constants",
".",
"put",
"(",
"constant",
",",
"new",
"PatternConstant",
"(",
"constant",
".",
"getValue",
"(",
")",
",",
"constant",
".",
"isIgnoreCase",
"(",
")",
",",
"constant",
".",
"isGhost",
"(",
")",
")",
")",
";",
"}",
"return",
"constants",
".",
"get",
"(",
"constant",
")",
";",
"}"
] | Create a constant element for text parsing
@param constant constant definition
@return pattern element for constant | [
"Create",
"a",
"constant",
"element",
"for",
"text",
"parsing"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/PatternElementFactory.java#L73-L81 |
2,184 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.create | public Configuration create(Document dc) {
// Create configuration
Configuration configuration = new Configuration();
parseNesting(configuration, dc);
// Parse parameters
configuration.setParams(parseParams(dc));
// Parse prefix and suffix
configuration.setPrefix(parseFix(dc, TAG_PREFIX));
configuration.setSuffix(parseFix(dc, TAG_SUFFIX));
// Parse codes and scope and set this to configuration
// Parse scopes
NodeList scopeNodeList = dc.getDocumentElement().getElementsByTagNameNS(SCHEMA_LOCATION, TAG_SCOPE);
Map<String, Scope> scopes = parseScopes(scopeNodeList);
boolean fillRoot = false;
Scope root;
if (!scopes.containsKey(Scope.ROOT)) {
root = new Scope(Scope.ROOT);
scopes.put(Scope.ROOT, root);
fillRoot = true;
} else {
root = scopes.get(Scope.ROOT);
}
// Parse codes
Map<String, Code> codes = parseCodes(dc, scopes);
// include codes in scopes
fillScopeCodes(scopeNodeList, scopes, codes);
// If root scope not defined in configuration file, then root scope fills all codes
if (fillRoot) {
root.setCodes(new HashSet<Code>(codes.values()));
}
// set root scope
configuration.setRootScope(root);
// return configuration
return configuration;
} | java | public Configuration create(Document dc) {
// Create configuration
Configuration configuration = new Configuration();
parseNesting(configuration, dc);
// Parse parameters
configuration.setParams(parseParams(dc));
// Parse prefix and suffix
configuration.setPrefix(parseFix(dc, TAG_PREFIX));
configuration.setSuffix(parseFix(dc, TAG_SUFFIX));
// Parse codes and scope and set this to configuration
// Parse scopes
NodeList scopeNodeList = dc.getDocumentElement().getElementsByTagNameNS(SCHEMA_LOCATION, TAG_SCOPE);
Map<String, Scope> scopes = parseScopes(scopeNodeList);
boolean fillRoot = false;
Scope root;
if (!scopes.containsKey(Scope.ROOT)) {
root = new Scope(Scope.ROOT);
scopes.put(Scope.ROOT, root);
fillRoot = true;
} else {
root = scopes.get(Scope.ROOT);
}
// Parse codes
Map<String, Code> codes = parseCodes(dc, scopes);
// include codes in scopes
fillScopeCodes(scopeNodeList, scopes, codes);
// If root scope not defined in configuration file, then root scope fills all codes
if (fillRoot) {
root.setCodes(new HashSet<Code>(codes.values()));
}
// set root scope
configuration.setRootScope(root);
// return configuration
return configuration;
} | [
"public",
"Configuration",
"create",
"(",
"Document",
"dc",
")",
"{",
"// Create configuration",
"Configuration",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"parseNesting",
"(",
"configuration",
",",
"dc",
")",
";",
"// Parse parameters",
"configuration",
".",
"setParams",
"(",
"parseParams",
"(",
"dc",
")",
")",
";",
"// Parse prefix and suffix",
"configuration",
".",
"setPrefix",
"(",
"parseFix",
"(",
"dc",
",",
"TAG_PREFIX",
")",
")",
";",
"configuration",
".",
"setSuffix",
"(",
"parseFix",
"(",
"dc",
",",
"TAG_SUFFIX",
")",
")",
";",
"// Parse codes and scope and set this to configuration",
"// Parse scopes",
"NodeList",
"scopeNodeList",
"=",
"dc",
".",
"getDocumentElement",
"(",
")",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_SCOPE",
")",
";",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
"=",
"parseScopes",
"(",
"scopeNodeList",
")",
";",
"boolean",
"fillRoot",
"=",
"false",
";",
"Scope",
"root",
";",
"if",
"(",
"!",
"scopes",
".",
"containsKey",
"(",
"Scope",
".",
"ROOT",
")",
")",
"{",
"root",
"=",
"new",
"Scope",
"(",
"Scope",
".",
"ROOT",
")",
";",
"scopes",
".",
"put",
"(",
"Scope",
".",
"ROOT",
",",
"root",
")",
";",
"fillRoot",
"=",
"true",
";",
"}",
"else",
"{",
"root",
"=",
"scopes",
".",
"get",
"(",
"Scope",
".",
"ROOT",
")",
";",
"}",
"// Parse codes",
"Map",
"<",
"String",
",",
"Code",
">",
"codes",
"=",
"parseCodes",
"(",
"dc",
",",
"scopes",
")",
";",
"// include codes in scopes",
"fillScopeCodes",
"(",
"scopeNodeList",
",",
"scopes",
",",
"codes",
")",
";",
"// If root scope not defined in configuration file, then root scope fills all codes",
"if",
"(",
"fillRoot",
")",
"{",
"root",
".",
"setCodes",
"(",
"new",
"HashSet",
"<",
"Code",
">",
"(",
"codes",
".",
"values",
"(",
")",
")",
")",
";",
"}",
"// set root scope",
"configuration",
".",
"setRootScope",
"(",
"root",
")",
";",
"// return configuration",
"return",
"configuration",
";",
"}"
] | Create the bb-code processor from DOM Document
@param dc document
@return bb-code processor
@throws TextProcessorFactoryException If invalid Document | [
"Create",
"the",
"bb",
"-",
"code",
"processor",
"from",
"DOM",
"Document"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L100-L144 |
2,185 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseNesting | private void parseNesting(Configuration configuration, Document dc) {
NodeList list = dc.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_NESTING);
if (list.getLength() > 0) {
Node el = list.item(0);
configuration.setNestingLimit(nodeAttribute(el, TAG_NESTING_ATTR_LIMIT, Configuration.DEFAULT_NESTING_LIMIT));
configuration.setPropagateNestingException(
nodeAttribute(el, TAG_NESTING_ATTR_EXCEPTION, Configuration.DEFAULT_PROPAGATE_NESTING_EXCEPTION)
);
}
} | java | private void parseNesting(Configuration configuration, Document dc) {
NodeList list = dc.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_NESTING);
if (list.getLength() > 0) {
Node el = list.item(0);
configuration.setNestingLimit(nodeAttribute(el, TAG_NESTING_ATTR_LIMIT, Configuration.DEFAULT_NESTING_LIMIT));
configuration.setPropagateNestingException(
nodeAttribute(el, TAG_NESTING_ATTR_EXCEPTION, Configuration.DEFAULT_PROPAGATE_NESTING_EXCEPTION)
);
}
} | [
"private",
"void",
"parseNesting",
"(",
"Configuration",
"configuration",
",",
"Document",
"dc",
")",
"{",
"NodeList",
"list",
"=",
"dc",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_NESTING",
")",
";",
"if",
"(",
"list",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"Node",
"el",
"=",
"list",
".",
"item",
"(",
"0",
")",
";",
"configuration",
".",
"setNestingLimit",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_NESTING_ATTR_LIMIT",
",",
"Configuration",
".",
"DEFAULT_NESTING_LIMIT",
")",
")",
";",
"configuration",
".",
"setPropagateNestingException",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_NESTING_ATTR_EXCEPTION",
",",
"Configuration",
".",
"DEFAULT_PROPAGATE_NESTING_EXCEPTION",
")",
")",
";",
"}",
"}"
] | Parse nesting element, which describes nesting behavior.
@param configuration parser configuration
@param dc DOM-document | [
"Parse",
"nesting",
"element",
"which",
"describes",
"nesting",
"behavior",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L152-L161 |
2,186 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseParams | private Map<String, CharSequence> parseParams(Document dc) {
Map<String, CharSequence> params = new HashMap<String, CharSequence>();
NodeList paramsElements = dc.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PARAMS);
if (paramsElements.getLength() > 0) {
Element paramsElement = (Element) paramsElements.item(0);
NodeList paramElements = paramsElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PARAM);
for (int i = 0; i < paramElements.getLength(); i++) {
Node paramElement = paramElements.item(i);
String name = nodeAttribute(paramElement, TAG_PARAM_ATTR_NAME, "");
String value = nodeAttribute(paramElement, TAG_PARAM_ATTR_VALUE, "");
if (name != null && name.length() > 0) {
params.put(name, value);
}
}
}
return params;
} | java | private Map<String, CharSequence> parseParams(Document dc) {
Map<String, CharSequence> params = new HashMap<String, CharSequence>();
NodeList paramsElements = dc.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PARAMS);
if (paramsElements.getLength() > 0) {
Element paramsElement = (Element) paramsElements.item(0);
NodeList paramElements = paramsElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PARAM);
for (int i = 0; i < paramElements.getLength(); i++) {
Node paramElement = paramElements.item(i);
String name = nodeAttribute(paramElement, TAG_PARAM_ATTR_NAME, "");
String value = nodeAttribute(paramElement, TAG_PARAM_ATTR_VALUE, "");
if (name != null && name.length() > 0) {
params.put(name, value);
}
}
}
return params;
} | [
"private",
"Map",
"<",
"String",
",",
"CharSequence",
">",
"parseParams",
"(",
"Document",
"dc",
")",
"{",
"Map",
"<",
"String",
",",
"CharSequence",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CharSequence",
">",
"(",
")",
";",
"NodeList",
"paramsElements",
"=",
"dc",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_PARAMS",
")",
";",
"if",
"(",
"paramsElements",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"Element",
"paramsElement",
"=",
"(",
"Element",
")",
"paramsElements",
".",
"item",
"(",
"0",
")",
";",
"NodeList",
"paramElements",
"=",
"paramsElement",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_PARAM",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"paramElements",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"paramElement",
"=",
"paramElements",
".",
"item",
"(",
"i",
")",
";",
"String",
"name",
"=",
"nodeAttribute",
"(",
"paramElement",
",",
"TAG_PARAM_ATTR_NAME",
",",
"\"\"",
")",
";",
"String",
"value",
"=",
"nodeAttribute",
"(",
"paramElement",
",",
"TAG_PARAM_ATTR_VALUE",
",",
"\"\"",
")",
";",
"if",
"(",
"name",
"!=",
"null",
"&&",
"name",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"params",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"}",
"return",
"params",
";",
"}"
] | Parse configuration predefined parameters.
@param dc DOM-document
@return parameters | [
"Parse",
"configuration",
"predefined",
"parameters",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L169-L185 |
2,187 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseFix | private Template parseFix(Document dc, String tagname) {
Template fix;
NodeList prefixElementList = dc.getElementsByTagNameNS(SCHEMA_LOCATION, tagname);
if (prefixElementList.getLength() > 0) {
fix = parseTemplate(prefixElementList.item(0));
} else {
fix = new Template();
}
return fix;
} | java | private Template parseFix(Document dc, String tagname) {
Template fix;
NodeList prefixElementList = dc.getElementsByTagNameNS(SCHEMA_LOCATION, tagname);
if (prefixElementList.getLength() > 0) {
fix = parseTemplate(prefixElementList.item(0));
} else {
fix = new Template();
}
return fix;
} | [
"private",
"Template",
"parseFix",
"(",
"Document",
"dc",
",",
"String",
"tagname",
")",
"{",
"Template",
"fix",
";",
"NodeList",
"prefixElementList",
"=",
"dc",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"tagname",
")",
";",
"if",
"(",
"prefixElementList",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"fix",
"=",
"parseTemplate",
"(",
"prefixElementList",
".",
"item",
"(",
"0",
")",
")",
";",
"}",
"else",
"{",
"fix",
"=",
"new",
"Template",
"(",
")",
";",
"}",
"return",
"fix",
";",
"}"
] | Parse prefix or suffix.
@param dc DOM-document.
@param tagname tag name.
@return template. | [
"Parse",
"prefix",
"or",
"suffix",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L194-L203 |
2,188 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.fillScopeCodes | private void fillScopeCodes(
NodeList scopeNodeList,
Map<String, Scope> scopes,
Map<String, Code> codes
) {
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
Scope scope = scopes.get(scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME));
// Add codes to scope
Set<Code> scopeCodes = new HashSet<Code>();
// bind exists codes
NodeList coderefs = scopeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODEREF);
for (int j = 0; j < coderefs.getLength(); j++) {
Element ref = (Element) coderefs.item(j);
String codeName = ref.getAttribute(TAG_CODEREF_ATTR_NAME);
Code code = codes.get(codeName);
if (code == null) {
throw new TextProcessorFactoryException("Can't find code \"" + codeName + "\".");
}
scopeCodes.add(code);
}
// Add inline codes
NodeList inlineCodes = scopeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODE);
for (int j = 0; j < inlineCodes.getLength(); j++) {
// Inline element code
Element ice = (Element) inlineCodes.item(j);
scopeCodes.add(parseCode(ice, scopes));
}
// Set codes to scope
scope.setCodes(scopeCodes);
}
} | java | private void fillScopeCodes(
NodeList scopeNodeList,
Map<String, Scope> scopes,
Map<String, Code> codes
) {
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
Scope scope = scopes.get(scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME));
// Add codes to scope
Set<Code> scopeCodes = new HashSet<Code>();
// bind exists codes
NodeList coderefs = scopeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODEREF);
for (int j = 0; j < coderefs.getLength(); j++) {
Element ref = (Element) coderefs.item(j);
String codeName = ref.getAttribute(TAG_CODEREF_ATTR_NAME);
Code code = codes.get(codeName);
if (code == null) {
throw new TextProcessorFactoryException("Can't find code \"" + codeName + "\".");
}
scopeCodes.add(code);
}
// Add inline codes
NodeList inlineCodes = scopeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODE);
for (int j = 0; j < inlineCodes.getLength(); j++) {
// Inline element code
Element ice = (Element) inlineCodes.item(j);
scopeCodes.add(parseCode(ice, scopes));
}
// Set codes to scope
scope.setCodes(scopeCodes);
}
} | [
"private",
"void",
"fillScopeCodes",
"(",
"NodeList",
"scopeNodeList",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
",",
"Map",
"<",
"String",
",",
"Code",
">",
"codes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scopeNodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"scopeElement",
"=",
"(",
"Element",
")",
"scopeNodeList",
".",
"item",
"(",
"i",
")",
";",
"Scope",
"scope",
"=",
"scopes",
".",
"get",
"(",
"scopeElement",
".",
"getAttribute",
"(",
"TAG_SCOPE_ATTR_NAME",
")",
")",
";",
"// Add codes to scope",
"Set",
"<",
"Code",
">",
"scopeCodes",
"=",
"new",
"HashSet",
"<",
"Code",
">",
"(",
")",
";",
"// bind exists codes",
"NodeList",
"coderefs",
"=",
"scopeElement",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_CODEREF",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"coderefs",
".",
"getLength",
"(",
")",
";",
"j",
"++",
")",
"{",
"Element",
"ref",
"=",
"(",
"Element",
")",
"coderefs",
".",
"item",
"(",
"j",
")",
";",
"String",
"codeName",
"=",
"ref",
".",
"getAttribute",
"(",
"TAG_CODEREF_ATTR_NAME",
")",
";",
"Code",
"code",
"=",
"codes",
".",
"get",
"(",
"codeName",
")",
";",
"if",
"(",
"code",
"==",
"null",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Can't find code \\\"\"",
"+",
"codeName",
"+",
"\"\\\".\"",
")",
";",
"}",
"scopeCodes",
".",
"add",
"(",
"code",
")",
";",
"}",
"// Add inline codes",
"NodeList",
"inlineCodes",
"=",
"scopeElement",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_CODE",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"inlineCodes",
".",
"getLength",
"(",
")",
";",
"j",
"++",
")",
"{",
"// Inline element code",
"Element",
"ice",
"=",
"(",
"Element",
")",
"inlineCodes",
".",
"item",
"(",
"j",
")",
";",
"scopeCodes",
".",
"add",
"(",
"parseCode",
"(",
"ice",
",",
"scopes",
")",
")",
";",
"}",
"// Set codes to scope",
"scope",
".",
"setCodes",
"(",
"scopeCodes",
")",
";",
"}",
"}"
] | Fill codes of scopes.
@param scopeNodeList node list with scopes definitions
@param scopes scopes
@param codes codes
@throws TextProcessorFactoryException any problem | [
"Fill",
"codes",
"of",
"scopes",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L213-L248 |
2,189 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseScopes | private Map<String, Scope> parseScopes(NodeList scopeNodeList) {
Map<String, Scope> scopes = new HashMap<String, Scope>();
// Parse scopes
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
String name = scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME);
if (name.length() == 0) {
throw new TextProcessorFactoryException("Illegal scope name. Scope name can't be empty.");
}
Scope scope =
new Scope(
name,
nodeAttribute(scopeElement, TAG_SCOPE_ATTR_IGNORE_TEXT, Scope.DEFAULT_IGNORE_TEXT)
);
scope.setStrong(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_STRONG, Scope.DEFAULT_STRONG));
scopes.put(scope.getName(), scope);
}
// Set parents
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
String name = scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME);
Scope scope = scopes.get(name);
if (scope == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Can't find scope \"{0}\".", name)
);
}
String parentName = nodeAttribute(scopeElement, TAG_SCOPE_ATTR_PARENT);
if (parentName != null) {
Scope parent = scopes.get(parentName);
if (parent == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Can't find parent scope \"{0}\".", parentName)
);
}
scope.setParent(parent);
}
scope.setMax(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_MAX, Scope.DEFAULT_MAX_VALUE));
scope.setMin(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_MIN, Scope.DEFAULT_MIN_VALUE));
}
return scopes;
} | java | private Map<String, Scope> parseScopes(NodeList scopeNodeList) {
Map<String, Scope> scopes = new HashMap<String, Scope>();
// Parse scopes
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
String name = scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME);
if (name.length() == 0) {
throw new TextProcessorFactoryException("Illegal scope name. Scope name can't be empty.");
}
Scope scope =
new Scope(
name,
nodeAttribute(scopeElement, TAG_SCOPE_ATTR_IGNORE_TEXT, Scope.DEFAULT_IGNORE_TEXT)
);
scope.setStrong(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_STRONG, Scope.DEFAULT_STRONG));
scopes.put(scope.getName(), scope);
}
// Set parents
for (int i = 0; i < scopeNodeList.getLength(); i++) {
Element scopeElement = (Element) scopeNodeList.item(i);
String name = scopeElement.getAttribute(TAG_SCOPE_ATTR_NAME);
Scope scope = scopes.get(name);
if (scope == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Can't find scope \"{0}\".", name)
);
}
String parentName = nodeAttribute(scopeElement, TAG_SCOPE_ATTR_PARENT);
if (parentName != null) {
Scope parent = scopes.get(parentName);
if (parent == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Can't find parent scope \"{0}\".", parentName)
);
}
scope.setParent(parent);
}
scope.setMax(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_MAX, Scope.DEFAULT_MAX_VALUE));
scope.setMin(nodeAttribute(scopeElement, TAG_SCOPE_ATTR_MIN, Scope.DEFAULT_MIN_VALUE));
}
return scopes;
} | [
"private",
"Map",
"<",
"String",
",",
"Scope",
">",
"parseScopes",
"(",
"NodeList",
"scopeNodeList",
")",
"{",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Scope",
">",
"(",
")",
";",
"// Parse scopes",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scopeNodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"scopeElement",
"=",
"(",
"Element",
")",
"scopeNodeList",
".",
"item",
"(",
"i",
")",
";",
"String",
"name",
"=",
"scopeElement",
".",
"getAttribute",
"(",
"TAG_SCOPE_ATTR_NAME",
")",
";",
"if",
"(",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Illegal scope name. Scope name can't be empty.\"",
")",
";",
"}",
"Scope",
"scope",
"=",
"new",
"Scope",
"(",
"name",
",",
"nodeAttribute",
"(",
"scopeElement",
",",
"TAG_SCOPE_ATTR_IGNORE_TEXT",
",",
"Scope",
".",
"DEFAULT_IGNORE_TEXT",
")",
")",
";",
"scope",
".",
"setStrong",
"(",
"nodeAttribute",
"(",
"scopeElement",
",",
"TAG_SCOPE_ATTR_STRONG",
",",
"Scope",
".",
"DEFAULT_STRONG",
")",
")",
";",
"scopes",
".",
"put",
"(",
"scope",
".",
"getName",
"(",
")",
",",
"scope",
")",
";",
"}",
"// Set parents",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scopeNodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"scopeElement",
"=",
"(",
"Element",
")",
"scopeNodeList",
".",
"item",
"(",
"i",
")",
";",
"String",
"name",
"=",
"scopeElement",
".",
"getAttribute",
"(",
"TAG_SCOPE_ATTR_NAME",
")",
";",
"Scope",
"scope",
"=",
"scopes",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"scope",
"==",
"null",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Can't find scope \\\"{0}\\\".\"",
",",
"name",
")",
")",
";",
"}",
"String",
"parentName",
"=",
"nodeAttribute",
"(",
"scopeElement",
",",
"TAG_SCOPE_ATTR_PARENT",
")",
";",
"if",
"(",
"parentName",
"!=",
"null",
")",
"{",
"Scope",
"parent",
"=",
"scopes",
".",
"get",
"(",
"parentName",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Can't find parent scope \\\"{0}\\\".\"",
",",
"parentName",
")",
")",
";",
"}",
"scope",
".",
"setParent",
"(",
"parent",
")",
";",
"}",
"scope",
".",
"setMax",
"(",
"nodeAttribute",
"(",
"scopeElement",
",",
"TAG_SCOPE_ATTR_MAX",
",",
"Scope",
".",
"DEFAULT_MAX_VALUE",
")",
")",
";",
"scope",
".",
"setMin",
"(",
"nodeAttribute",
"(",
"scopeElement",
",",
"TAG_SCOPE_ATTR_MIN",
",",
"Scope",
".",
"DEFAULT_MIN_VALUE",
")",
")",
";",
"}",
"return",
"scopes",
";",
"}"
] | Parse scopes from XML
@param scopeNodeList list with scopes definitions
@return scopes
@throws TextProcessorFactoryException any problems | [
"Parse",
"scopes",
"from",
"XML"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L257-L303 |
2,190 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseCodes | private Map<String, Code> parseCodes(Document dc, Map<String, Scope> scopes) {
Map<String, Code> codes = new HashMap<String, Code>();
NodeList codeNodeList = dc.getDocumentElement().getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODE);
for (int i = 0; i < codeNodeList.getLength(); i++) {
Code code = parseCode((Element) codeNodeList.item(i), scopes);
codes.put(code.getName(), code);
}
return codes;
} | java | private Map<String, Code> parseCodes(Document dc, Map<String, Scope> scopes) {
Map<String, Code> codes = new HashMap<String, Code>();
NodeList codeNodeList = dc.getDocumentElement().getElementsByTagNameNS(SCHEMA_LOCATION, TAG_CODE);
for (int i = 0; i < codeNodeList.getLength(); i++) {
Code code = parseCode((Element) codeNodeList.item(i), scopes);
codes.put(code.getName(), code);
}
return codes;
} | [
"private",
"Map",
"<",
"String",
",",
"Code",
">",
"parseCodes",
"(",
"Document",
"dc",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"Map",
"<",
"String",
",",
"Code",
">",
"codes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Code",
">",
"(",
")",
";",
"NodeList",
"codeNodeList",
"=",
"dc",
".",
"getDocumentElement",
"(",
")",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_CODE",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"codeNodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Code",
"code",
"=",
"parseCode",
"(",
"(",
"Element",
")",
"codeNodeList",
".",
"item",
"(",
"i",
")",
",",
"scopes",
")",
";",
"codes",
".",
"put",
"(",
"code",
".",
"getName",
"(",
")",
",",
"code",
")",
";",
"}",
"return",
"codes",
";",
"}"
] | Parse codes from XML
@param dc DOM document with configuration
@return codes
@throws TextProcessorFactoryException any problem | [
"Parse",
"codes",
"from",
"XML"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L312-L320 |
2,191 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseCode | private Code parseCode(Element codeElement, Map<String, Scope> scopes) {
// Code name
Code code = new Code(nodeAttribute(codeElement, TAG_CODE_ATTR_NAME, Utils.generateRandomName()));
// Code priority
code.setPriority(nodeAttribute(codeElement, TAG_CODE_ATTR_PRIORITY, Code.DEFAULT_PRIORITY));
// Do show variables outside the code?
code.setTransparent(nodeAttribute(codeElement, TAG_CODE_ATTR_TRANSPARENT, true));
// Template to building
NodeList templateElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_TEMPLATE);
if (templateElements.getLength() > 0) {
code.setTemplate(parseTemplate(templateElements.item(0)));
} else {
throw new TextProcessorFactoryException("Illegal configuration. Can't find template of code.");
}
// Pattern to parsing
NodeList patternElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PATTERN);
if (patternElements.getLength() > 0) {
for (int i = 0; i < patternElements.getLength(); i++) {
code.addPattern(parsePattern(patternElements.item(i), scopes));
}
} else {
throw new TextProcessorFactoryException("Illegal configuration. Can't find pattern of code.");
}
// return code
return code;
} | java | private Code parseCode(Element codeElement, Map<String, Scope> scopes) {
// Code name
Code code = new Code(nodeAttribute(codeElement, TAG_CODE_ATTR_NAME, Utils.generateRandomName()));
// Code priority
code.setPriority(nodeAttribute(codeElement, TAG_CODE_ATTR_PRIORITY, Code.DEFAULT_PRIORITY));
// Do show variables outside the code?
code.setTransparent(nodeAttribute(codeElement, TAG_CODE_ATTR_TRANSPARENT, true));
// Template to building
NodeList templateElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_TEMPLATE);
if (templateElements.getLength() > 0) {
code.setTemplate(parseTemplate(templateElements.item(0)));
} else {
throw new TextProcessorFactoryException("Illegal configuration. Can't find template of code.");
}
// Pattern to parsing
NodeList patternElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PATTERN);
if (patternElements.getLength() > 0) {
for (int i = 0; i < patternElements.getLength(); i++) {
code.addPattern(parsePattern(patternElements.item(i), scopes));
}
} else {
throw new TextProcessorFactoryException("Illegal configuration. Can't find pattern of code.");
}
// return code
return code;
} | [
"private",
"Code",
"parseCode",
"(",
"Element",
"codeElement",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"// Code name",
"Code",
"code",
"=",
"new",
"Code",
"(",
"nodeAttribute",
"(",
"codeElement",
",",
"TAG_CODE_ATTR_NAME",
",",
"Utils",
".",
"generateRandomName",
"(",
")",
")",
")",
";",
"// Code priority",
"code",
".",
"setPriority",
"(",
"nodeAttribute",
"(",
"codeElement",
",",
"TAG_CODE_ATTR_PRIORITY",
",",
"Code",
".",
"DEFAULT_PRIORITY",
")",
")",
";",
"// Do show variables outside the code?",
"code",
".",
"setTransparent",
"(",
"nodeAttribute",
"(",
"codeElement",
",",
"TAG_CODE_ATTR_TRANSPARENT",
",",
"true",
")",
")",
";",
"// Template to building",
"NodeList",
"templateElements",
"=",
"codeElement",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_TEMPLATE",
")",
";",
"if",
"(",
"templateElements",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"code",
".",
"setTemplate",
"(",
"parseTemplate",
"(",
"templateElements",
".",
"item",
"(",
"0",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Illegal configuration. Can't find template of code.\"",
")",
";",
"}",
"// Pattern to parsing",
"NodeList",
"patternElements",
"=",
"codeElement",
".",
"getElementsByTagNameNS",
"(",
"SCHEMA_LOCATION",
",",
"TAG_PATTERN",
")",
";",
"if",
"(",
"patternElements",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"patternElements",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"code",
".",
"addPattern",
"(",
"parsePattern",
"(",
"patternElements",
".",
"item",
"(",
"i",
")",
",",
"scopes",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Illegal configuration. Can't find pattern of code.\"",
")",
";",
"}",
"// return code",
"return",
"code",
";",
"}"
] | Parse bb-code from DOM Node
@param codeElement node, represent code wich
@return bb-code
@throws TextProcessorFactoryException if error format | [
"Parse",
"bb",
"-",
"code",
"from",
"DOM",
"Node"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L329-L359 |
2,192 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parsePattern | private Pattern parsePattern(Node node, Map<String, Scope> scopes) {
List<PatternElement> elements = new ArrayList<PatternElement>();
NodeList patternList = node.getChildNodes();
int patternLength = patternList.getLength();
if (patternLength <= 0) {
throw new TextProcessorFactoryException("Invalid pattern. Pattern is empty.");
}
// Ignore case for all constants
boolean ignoreCase = nodeAttribute(node, "ignoreCase", false);
for (int k = 0; k < patternLength; k++) {
Node el = patternList.item(k);
short nodeType = el.getNodeType();
if (nodeType == Node.TEXT_NODE) {
elements.add(new Constant(el.getNodeValue(), ignoreCase));
} else if (nodeType == Node.ELEMENT_NODE) {
String tagName = el.getLocalName();
if (tagName.equals(TAG_CONSTANT)) {
elements.add(parseConstant(el, ignoreCase));
} else if (tagName.equals(TAG_VAR)) {
elements.add(parseNamedElement(el, scopes));
} else if (tagName.equals(TAG_JUNK)) {
elements.add(new Junk());
} else if (tagName.equals(TAG_EOL)) {
elements.add(parseEol(el));
} else if (tagName.equals(TAG_BOL)) {
elements.add(new Bol());
} else if (tagName.equals(TAG_BLANKLINE)) {
elements.add(new BlankLine(nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)));
} else if (tagName.equals(TAG_URL)) {
elements.add(parseUrl(el));
} else if (tagName.equals(TAG_EMAIL)){
elements.add(parseEmail(el));
} else {
throw new TextProcessorFactoryException(
MessageFormat.format("Invalid pattern. Unknown XML element [{0}].", tagName)
);
}
} else {
throw new TextProcessorFactoryException("Invalid pattern. Unsupported XML node type.");
}
}
return new Pattern(elements);
} | java | private Pattern parsePattern(Node node, Map<String, Scope> scopes) {
List<PatternElement> elements = new ArrayList<PatternElement>();
NodeList patternList = node.getChildNodes();
int patternLength = patternList.getLength();
if (patternLength <= 0) {
throw new TextProcessorFactoryException("Invalid pattern. Pattern is empty.");
}
// Ignore case for all constants
boolean ignoreCase = nodeAttribute(node, "ignoreCase", false);
for (int k = 0; k < patternLength; k++) {
Node el = patternList.item(k);
short nodeType = el.getNodeType();
if (nodeType == Node.TEXT_NODE) {
elements.add(new Constant(el.getNodeValue(), ignoreCase));
} else if (nodeType == Node.ELEMENT_NODE) {
String tagName = el.getLocalName();
if (tagName.equals(TAG_CONSTANT)) {
elements.add(parseConstant(el, ignoreCase));
} else if (tagName.equals(TAG_VAR)) {
elements.add(parseNamedElement(el, scopes));
} else if (tagName.equals(TAG_JUNK)) {
elements.add(new Junk());
} else if (tagName.equals(TAG_EOL)) {
elements.add(parseEol(el));
} else if (tagName.equals(TAG_BOL)) {
elements.add(new Bol());
} else if (tagName.equals(TAG_BLANKLINE)) {
elements.add(new BlankLine(nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)));
} else if (tagName.equals(TAG_URL)) {
elements.add(parseUrl(el));
} else if (tagName.equals(TAG_EMAIL)){
elements.add(parseEmail(el));
} else {
throw new TextProcessorFactoryException(
MessageFormat.format("Invalid pattern. Unknown XML element [{0}].", tagName)
);
}
} else {
throw new TextProcessorFactoryException("Invalid pattern. Unsupported XML node type.");
}
}
return new Pattern(elements);
} | [
"private",
"Pattern",
"parsePattern",
"(",
"Node",
"node",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"List",
"<",
"PatternElement",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"PatternElement",
">",
"(",
")",
";",
"NodeList",
"patternList",
"=",
"node",
".",
"getChildNodes",
"(",
")",
";",
"int",
"patternLength",
"=",
"patternList",
".",
"getLength",
"(",
")",
";",
"if",
"(",
"patternLength",
"<=",
"0",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Invalid pattern. Pattern is empty.\"",
")",
";",
"}",
"// Ignore case for all constants",
"boolean",
"ignoreCase",
"=",
"nodeAttribute",
"(",
"node",
",",
"\"ignoreCase\"",
",",
"false",
")",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"patternLength",
";",
"k",
"++",
")",
"{",
"Node",
"el",
"=",
"patternList",
".",
"item",
"(",
"k",
")",
";",
"short",
"nodeType",
"=",
"el",
".",
"getNodeType",
"(",
")",
";",
"if",
"(",
"nodeType",
"==",
"Node",
".",
"TEXT_NODE",
")",
"{",
"elements",
".",
"add",
"(",
"new",
"Constant",
"(",
"el",
".",
"getNodeValue",
"(",
")",
",",
"ignoreCase",
")",
")",
";",
"}",
"else",
"if",
"(",
"nodeType",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"String",
"tagName",
"=",
"el",
".",
"getLocalName",
"(",
")",
";",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_CONSTANT",
")",
")",
"{",
"elements",
".",
"add",
"(",
"parseConstant",
"(",
"el",
",",
"ignoreCase",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_VAR",
")",
")",
"{",
"elements",
".",
"add",
"(",
"parseNamedElement",
"(",
"el",
",",
"scopes",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_JUNK",
")",
")",
"{",
"elements",
".",
"add",
"(",
"new",
"Junk",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_EOL",
")",
")",
"{",
"elements",
".",
"add",
"(",
"parseEol",
"(",
"el",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_BOL",
")",
")",
"{",
"elements",
".",
"add",
"(",
"new",
"Bol",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_BLANKLINE",
")",
")",
"{",
"elements",
".",
"add",
"(",
"new",
"BlankLine",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_ATTR_GHOST",
",",
"PatternElement",
".",
"DEFAULT_GHOST_VALUE",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_URL",
")",
")",
"{",
"elements",
".",
"add",
"(",
"parseUrl",
"(",
"el",
")",
")",
";",
"}",
"else",
"if",
"(",
"tagName",
".",
"equals",
"(",
"TAG_EMAIL",
")",
")",
"{",
"elements",
".",
"add",
"(",
"parseEmail",
"(",
"el",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Invalid pattern. Unknown XML element [{0}].\"",
",",
"tagName",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"\"Invalid pattern. Unsupported XML node type.\"",
")",
";",
"}",
"}",
"return",
"new",
"Pattern",
"(",
"elements",
")",
";",
"}"
] | Parse code pattern for parse text.
@param node pattern node with pattern description
@return list of pattern elements
@throws TextProcessorFactoryException If invalid pattern format | [
"Parse",
"code",
"pattern",
"for",
"parse",
"text",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L368-L413 |
2,193 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseUrl | private Url parseUrl(Node el) {
return new Url(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Url.DEFAULT_NAME),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE),
nodeAttribute(el, TAG_URL_ATTR_LOCAL, Url.DEFAULT_LOCAL),
nodeAttribute(el, TAG_URL_ATTR_SCHEMALESS, Url.DEFAULT_SCHEMALESS)
);
} | java | private Url parseUrl(Node el) {
return new Url(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Url.DEFAULT_NAME),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE),
nodeAttribute(el, TAG_URL_ATTR_LOCAL, Url.DEFAULT_LOCAL),
nodeAttribute(el, TAG_URL_ATTR_SCHEMALESS, Url.DEFAULT_SCHEMALESS)
);
} | [
"private",
"Url",
"parseUrl",
"(",
"Node",
"el",
")",
"{",
"return",
"new",
"Url",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Url",
".",
"DEFAULT_NAME",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_ATTR_GHOST",
",",
"PatternElement",
".",
"DEFAULT_GHOST_VALUE",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_URL_ATTR_LOCAL",
",",
"Url",
".",
"DEFAULT_LOCAL",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_URL_ATTR_SCHEMALESS",
",",
"Url",
".",
"DEFAULT_SCHEMALESS",
")",
")",
";",
"}"
] | Parse an URL tag.
@param el tag element
@return Configuration URL. | [
"Parse",
"an",
"URL",
"tag",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L421-L428 |
2,194 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseEmail | private Email parseEmail(Node el){
return new Email(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Email.DEFAULT_NAME),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)
);
} | java | private Email parseEmail(Node el){
return new Email(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Email.DEFAULT_NAME),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)
);
} | [
"private",
"Email",
"parseEmail",
"(",
"Node",
"el",
")",
"{",
"return",
"new",
"Email",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Email",
".",
"DEFAULT_NAME",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_ATTR_GHOST",
",",
"PatternElement",
".",
"DEFAULT_GHOST_VALUE",
")",
")",
";",
"}"
] | Parse an email tag.
@param el tag element
@return Configuration EMAIL. | [
"Parse",
"an",
"email",
"tag",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L436-L441 |
2,195 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseConstant | private Constant parseConstant(Node el, boolean ignoreCase) {
return new Constant(
nodeAttribute(el, TAG_CONSTANT_ATTR_VALUE),
nodeAttribute(el, TAG_CONSTANT_ATTR_IGNORE_CASE, ignoreCase),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)
);
} | java | private Constant parseConstant(Node el, boolean ignoreCase) {
return new Constant(
nodeAttribute(el, TAG_CONSTANT_ATTR_VALUE),
nodeAttribute(el, TAG_CONSTANT_ATTR_IGNORE_CASE, ignoreCase),
nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)
);
} | [
"private",
"Constant",
"parseConstant",
"(",
"Node",
"el",
",",
"boolean",
"ignoreCase",
")",
"{",
"return",
"new",
"Constant",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_CONSTANT_ATTR_VALUE",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_CONSTANT_ATTR_IGNORE_CASE",
",",
"ignoreCase",
")",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_ATTR_GHOST",
",",
"PatternElement",
".",
"DEFAULT_GHOST_VALUE",
")",
")",
";",
"}"
] | Parse constant pattern element
@param el DOM element
@param ignoreCase if true the constant must ignore case
@return constant definition | [
"Parse",
"constant",
"pattern",
"element"
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L454-L460 |
2,196 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseNamedElement | private PatternElement parseNamedElement(Node el, Map<String, Scope> scopes) {
PatternElement namedElement;
if (
nodeAttribute(el, TAG_VAR_ATTR_PARSE, DEFAULT_PARSE_VALUE)
&& !nodeHasAttribute(el, TAG_VAR_ATTR_REGEX)
&& !nodeHasAttribute(el, TAG_VAR_ATTR_ACTION)
) {
namedElement = parseText(el, scopes);
} else {
namedElement = parseVariable(el);
}
return namedElement;
} | java | private PatternElement parseNamedElement(Node el, Map<String, Scope> scopes) {
PatternElement namedElement;
if (
nodeAttribute(el, TAG_VAR_ATTR_PARSE, DEFAULT_PARSE_VALUE)
&& !nodeHasAttribute(el, TAG_VAR_ATTR_REGEX)
&& !nodeHasAttribute(el, TAG_VAR_ATTR_ACTION)
) {
namedElement = parseText(el, scopes);
} else {
namedElement = parseVariable(el);
}
return namedElement;
} | [
"private",
"PatternElement",
"parseNamedElement",
"(",
"Node",
"el",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"PatternElement",
"namedElement",
";",
"if",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_PARSE",
",",
"DEFAULT_PARSE_VALUE",
")",
"&&",
"!",
"nodeHasAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_REGEX",
")",
"&&",
"!",
"nodeHasAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_ACTION",
")",
")",
"{",
"namedElement",
"=",
"parseText",
"(",
"el",
",",
"scopes",
")",
";",
"}",
"else",
"{",
"namedElement",
"=",
"parseVariable",
"(",
"el",
")",
";",
"}",
"return",
"namedElement",
";",
"}"
] | Parse a pattern named element. Text or Variable.
@param el a DOM-element
@param scopes map of scopes by name
@return Text or Variable | [
"Parse",
"a",
"pattern",
"named",
"element",
".",
"Text",
"or",
"Variable",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L469-L481 |
2,197 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseText | private Text parseText(Node el, Map<String, Scope> scopes) {
Text text;
if (nodeAttribute(el, TAG_VAR_ATTR_INHERIT, DEFAULT_INHERIT_VALUE)) {
text = new Text(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
null,
nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
);
} else {
String scopeName = nodeAttribute(el, TAG_SCOPE, Scope.ROOT);
Scope scope = scopes.get(scopeName);
if (scope == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Scope \"{0}\" not found.", scopeName)
);
}
text = new Text(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
scope,
nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
);
}
return text;
} | java | private Text parseText(Node el, Map<String, Scope> scopes) {
Text text;
if (nodeAttribute(el, TAG_VAR_ATTR_INHERIT, DEFAULT_INHERIT_VALUE)) {
text = new Text(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
null,
nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
);
} else {
String scopeName = nodeAttribute(el, TAG_SCOPE, Scope.ROOT);
Scope scope = scopes.get(scopeName);
if (scope == null) {
throw new TextProcessorFactoryException(
MessageFormat.format("Scope \"{0}\" not found.", scopeName)
);
}
text = new Text(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
scope,
nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
);
}
return text;
} | [
"private",
"Text",
"parseText",
"(",
"Node",
"el",
",",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"Text",
"text",
";",
"if",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_INHERIT",
",",
"DEFAULT_INHERIT_VALUE",
")",
")",
"{",
"text",
"=",
"new",
"Text",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Variable",
".",
"DEFAULT_NAME",
")",
",",
"null",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_TRANSPARENT",
",",
"false",
")",
")",
";",
"}",
"else",
"{",
"String",
"scopeName",
"=",
"nodeAttribute",
"(",
"el",
",",
"TAG_SCOPE",
",",
"Scope",
".",
"ROOT",
")",
";",
"Scope",
"scope",
"=",
"scopes",
".",
"get",
"(",
"scopeName",
")",
";",
"if",
"(",
"scope",
"==",
"null",
")",
"{",
"throw",
"new",
"TextProcessorFactoryException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Scope \\\"{0}\\\" not found.\"",
",",
"scopeName",
")",
")",
";",
"}",
"text",
"=",
"new",
"Text",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Variable",
".",
"DEFAULT_NAME",
")",
",",
"scope",
",",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_TRANSPARENT",
",",
"false",
")",
")",
";",
"}",
"return",
"text",
";",
"}"
] | Parse text. Text is a part of pattern.
@param el a DOM-element
@param scopes map of scopes by name
@return text | [
"Parse",
"text",
".",
"Text",
"is",
"a",
"part",
"of",
"pattern",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L490-L514 |
2,198 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseVariable | private Variable parseVariable(Node el) {
Variable variable;
if (nodeHasAttribute(el, TAG_VAR_ATTR_REGEX)) {
variable = new Variable(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
java.util.regex.Pattern.compile(
nodeAttribute(el, TAG_VAR_ATTR_REGEX)
)
);
} else {
variable = new Variable(nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME));
}
variable.setGhost(nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE));
if (nodeHasAttribute(el, TAG_VAR_ATTR_ACTION)) {
variable.setAction(Action.valueOf(nodeAttribute(el, TAG_VAR_ATTR_ACTION)));
}
return variable;
} | java | private Variable parseVariable(Node el) {
Variable variable;
if (nodeHasAttribute(el, TAG_VAR_ATTR_REGEX)) {
variable = new Variable(
nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
java.util.regex.Pattern.compile(
nodeAttribute(el, TAG_VAR_ATTR_REGEX)
)
);
} else {
variable = new Variable(nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME));
}
variable.setGhost(nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE));
if (nodeHasAttribute(el, TAG_VAR_ATTR_ACTION)) {
variable.setAction(Action.valueOf(nodeAttribute(el, TAG_VAR_ATTR_ACTION)));
}
return variable;
} | [
"private",
"Variable",
"parseVariable",
"(",
"Node",
"el",
")",
"{",
"Variable",
"variable",
";",
"if",
"(",
"nodeHasAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_REGEX",
")",
")",
"{",
"variable",
"=",
"new",
"Variable",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Variable",
".",
"DEFAULT_NAME",
")",
",",
"java",
".",
"util",
".",
"regex",
".",
"Pattern",
".",
"compile",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_REGEX",
")",
")",
")",
";",
"}",
"else",
"{",
"variable",
"=",
"new",
"Variable",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_NAME",
",",
"Variable",
".",
"DEFAULT_NAME",
")",
")",
";",
"}",
"variable",
".",
"setGhost",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_ATTR_GHOST",
",",
"PatternElement",
".",
"DEFAULT_GHOST_VALUE",
")",
")",
";",
"if",
"(",
"nodeHasAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_ACTION",
")",
")",
"{",
"variable",
".",
"setAction",
"(",
"Action",
".",
"valueOf",
"(",
"nodeAttribute",
"(",
"el",
",",
"TAG_VAR_ATTR_ACTION",
")",
")",
")",
";",
"}",
"return",
"variable",
";",
"}"
] | Parse variable. The part of pattern.
@param el DOM-element
@return variable | [
"Parse",
"variable",
".",
"The",
"part",
"of",
"pattern",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L522-L540 |
2,199 | kefirfromperm/kefirbb | src/org/kefirsf/bb/DomConfigurationFactory.java | DomConfigurationFactory.parseIf | private If parseIf(Node node) {
return new If(
nodeAttribute(node, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
parseTemplateElements(node)
);
} | java | private If parseIf(Node node) {
return new If(
nodeAttribute(node, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
parseTemplateElements(node)
);
} | [
"private",
"If",
"parseIf",
"(",
"Node",
"node",
")",
"{",
"return",
"new",
"If",
"(",
"nodeAttribute",
"(",
"node",
",",
"TAG_VAR_ATTR_NAME",
",",
"Variable",
".",
"DEFAULT_NAME",
")",
",",
"parseTemplateElements",
"(",
"node",
")",
")",
";",
"}"
] | Parse an IF expression. | [
"Parse",
"an",
"IF",
"expression",
"."
] | 8c36fc3d3dc27459b0cdc179b87582df30420856 | https://github.com/kefirfromperm/kefirbb/blob/8c36fc3d3dc27459b0cdc179b87582df30420856/src/org/kefirsf/bb/DomConfigurationFactory.java#L555-L560 |
Subsets and Splits