repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
defei/codelogger-utils | src/main/java/org/codelogger/utils/ClassUtils.java | ClassUtils.instantiateClass | public static <T> T instantiateClass(final Class<T> clazz, final Class<?>[] parameterTypes,
final Object[] parameterValues) throws BeanInstantiationException {
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, CLASS_IS_INTERFACE);
}
try {
Constructor<T> constructor = clazz.getConstructor(parameterTypes);
T newInstance = constructor.newInstance(parameterValues);
return newInstance;
} catch (Exception e) {
throw new BeanInstantiationException(clazz, NO_DEFAULT_CONSTRUCTOR_FOUND, e);
}
} | java | public static <T> T instantiateClass(final Class<T> clazz, final Class<?>[] parameterTypes,
final Object[] parameterValues) throws BeanInstantiationException {
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, CLASS_IS_INTERFACE);
}
try {
Constructor<T> constructor = clazz.getConstructor(parameterTypes);
T newInstance = constructor.newInstance(parameterValues);
return newInstance;
} catch (Exception e) {
throw new BeanInstantiationException(clazz, NO_DEFAULT_CONSTRUCTOR_FOUND, e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"instantiateClass",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
",",
"final",
"Object",
"[",
"]",
"parameterValues",
")",
"throws",
"BeanInstanti... | Create and initialize a new instance of the given class by given
parameterTypes and parameterValues.
@param clazz can not be null.
@param parameterTypes constructor parameters class type array.
@param parameterValues constructor parameters value array.
@return a newly allocated instance of the class represented by this class.
@throws BeanInstantiationException if given class no given parameter types
constructor found. | [
"Create",
"and",
"initialize",
"a",
"new",
"instance",
"of",
"the",
"given",
"class",
"by",
"given",
"parameterTypes",
"and",
"parameterValues",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/ClassUtils.java#L198-L211 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/ClassUtils.java | ClassUtils.isDataObject | public static boolean isDataObject(final Object object) {
if (object == null) {
return true;
}
Class<?> clazz = object.getClass();
return isDataClass(clazz);
} | java | public static boolean isDataObject(final Object object) {
if (object == null) {
return true;
}
Class<?> clazz = object.getClass();
return isDataClass(clazz);
} | [
"public",
"static",
"boolean",
"isDataObject",
"(",
"final",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"Class",
"<",
"?",
">",
"clazz",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"retur... | Returns true if the given object class is 8 primitive class or their
wrapper class,or String class,or null.
@param object any object.
@return true if the given object class is 8 primitive class or their
wrapper class,or String class,or null; false otherwise. | [
"Returns",
"true",
"if",
"the",
"given",
"object",
"class",
"is",
"8",
"primitive",
"class",
"or",
"their",
"wrapper",
"class",
"or",
"String",
"class",
"or",
"null",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/ClassUtils.java#L221-L228 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/ClassUtils.java | ClassUtils.isDataClass | public static boolean isDataClass(final Class<?> clazz) {
if (clazz == null || clazz.isPrimitive()) {
return true;
}
boolean isWrapperClass = contains(WRAPPER_CLASSES, clazz);
if (isWrapperClass) {
return true;
}
boolean isDataClass = contains(DATA_PRIMITIVE_CLASS, clazz);
if (isDataClass) {
return true;
}
return false;
} | java | public static boolean isDataClass(final Class<?> clazz) {
if (clazz == null || clazz.isPrimitive()) {
return true;
}
boolean isWrapperClass = contains(WRAPPER_CLASSES, clazz);
if (isWrapperClass) {
return true;
}
boolean isDataClass = contains(DATA_PRIMITIVE_CLASS, clazz);
if (isDataClass) {
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isDataClass",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
"||",
"clazz",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"boolean",
"isWrapperClass",
"="... | Returns true if the given class is 8 primitive class or their wrapper
class,or String class,or null.
@param clazz any class.
@return true if the given class is 8 primitive class or their wrapper
class,or String class,or null; false otherwise. | [
"Returns",
"true",
"if",
"the",
"given",
"class",
"is",
"8",
"primitive",
"class",
"or",
"their",
"wrapper",
"class",
"or",
"String",
"class",
"or",
"null",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/ClassUtils.java#L238-L252 | train |
jcuda/jcufft | JCufftJava/src/main/java/jcuda/jcufft/cufftType.java | cufftType.stringFor | public static String stringFor(int m)
{
switch (m)
{
case CUFFT_R2C : return "CUFFT_R2C";
case CUFFT_C2R : return "CUFFT_C2R";
case CUFFT_C2C : return "CUFFT_C2C";
case CUFFT_D2Z : return "CUFFT_D2Z";
case CUFFT_Z2D : return "CUFFT_Z2D";
case CUFFT_Z2Z : return "CUFFT_Z2Z";
}
return "INVALID cufftType: " + m;
} | java | public static String stringFor(int m)
{
switch (m)
{
case CUFFT_R2C : return "CUFFT_R2C";
case CUFFT_C2R : return "CUFFT_C2R";
case CUFFT_C2C : return "CUFFT_C2C";
case CUFFT_D2Z : return "CUFFT_D2Z";
case CUFFT_Z2D : return "CUFFT_Z2D";
case CUFFT_Z2Z : return "CUFFT_Z2Z";
}
return "INVALID cufftType: " + m;
} | [
"public",
"static",
"String",
"stringFor",
"(",
"int",
"m",
")",
"{",
"switch",
"(",
"m",
")",
"{",
"case",
"CUFFT_R2C",
":",
"return",
"\"CUFFT_R2C\"",
";",
"case",
"CUFFT_C2R",
":",
"return",
"\"CUFFT_C2R\"",
";",
"case",
"CUFFT_C2C",
":",
"return",
"\"C... | Returns the String identifying the given cufftType
@param m The cufftType
@return The String identifying the given cufftType | [
"Returns",
"the",
"String",
"identifying",
"the",
"given",
"cufftType"
] | 833c87ffb0864f7ee7270fddef8af57f48939b3a | https://github.com/jcuda/jcufft/blob/833c87ffb0864f7ee7270fddef8af57f48939b3a/JCufftJava/src/main/java/jcuda/jcufft/cufftType.java#L75-L87 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Struct.java | Struct.setContract | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Field f : fields.values()) {
f.setContract(c);
}
} | java | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Field f : fields.values()) {
f.setContract(c);
}
} | [
"@",
"Override",
"public",
"void",
"setContract",
"(",
"Contract",
"c",
")",
"{",
"super",
".",
"setContract",
"(",
"c",
")",
";",
"for",
"(",
"Field",
"f",
":",
"fields",
".",
"values",
"(",
")",
")",
"{",
"f",
".",
"setContract",
"(",
"c",
")",
... | Sets the Contract associated with this Struct. Propagates to Fields. | [
"Sets",
"the",
"Contract",
"associated",
"with",
"this",
"Struct",
".",
"Propagates",
"to",
"Fields",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Struct.java#L55-L61 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Struct.java | Struct.getFieldsPlusParents | public Map<String,Field> getFieldsPlusParents() {
Map<String,Field> tmp = new HashMap<String,Field>();
tmp.putAll(fields);
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.putAll(parent.getFieldsPlusParents());
}
return tmp;
} | java | public Map<String,Field> getFieldsPlusParents() {
Map<String,Field> tmp = new HashMap<String,Field>();
tmp.putAll(fields);
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.putAll(parent.getFieldsPlusParents());
}
return tmp;
} | [
"public",
"Map",
"<",
"String",
",",
"Field",
">",
"getFieldsPlusParents",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Field",
">",
"tmp",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Field",
">",
"(",
")",
";",
"tmp",
".",
"putAll",
"(",
"fields",
"... | Returns a Map of the Fields belonging to this Struct and all its ancestors.
Keys are the Field names. | [
"Returns",
"a",
"Map",
"of",
"the",
"Fields",
"belonging",
"to",
"this",
"Struct",
"and",
"all",
"its",
"ancestors",
".",
"Keys",
"are",
"the",
"Field",
"names",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Struct.java#L88-L96 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Struct.java | Struct.getFieldNamesPlusParents | public List<String> getFieldNamesPlusParents() {
List<String> tmp = new ArrayList<String>();
tmp.addAll(getFieldNames());
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.addAll(parent.getFieldNamesPlusParents());
}
return tmp;
} | java | public List<String> getFieldNamesPlusParents() {
List<String> tmp = new ArrayList<String>();
tmp.addAll(getFieldNames());
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.addAll(parent.getFieldNamesPlusParents());
}
return tmp;
} | [
"public",
"List",
"<",
"String",
">",
"getFieldNamesPlusParents",
"(",
")",
"{",
"List",
"<",
"String",
">",
"tmp",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"tmp",
".",
"addAll",
"(",
"getFieldNames",
"(",
")",
")",
";",
"if",
"(",... | Returns a List of the Field names belonging to this Struct and all its ancestors. | [
"Returns",
"a",
"List",
"of",
"the",
"Field",
"names",
"belonging",
"to",
"this",
"Struct",
"and",
"all",
"its",
"ancestors",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Struct.java#L101-L109 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/MobileApplicationCache.java | MobileApplicationCache.add | public void add(Collection<MobileApplication> mobileApplications)
{
for(MobileApplication mobileApplication : mobileApplications)
this.mobileApplications.put(mobileApplication.getId(), mobileApplication);
} | java | public void add(Collection<MobileApplication> mobileApplications)
{
for(MobileApplication mobileApplication : mobileApplications)
this.mobileApplications.put(mobileApplication.getId(), mobileApplication);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"MobileApplication",
">",
"mobileApplications",
")",
"{",
"for",
"(",
"MobileApplication",
"mobileApplication",
":",
"mobileApplications",
")",
"this",
".",
"mobileApplications",
".",
"put",
"(",
"mobileApplication",
... | Adds the mobile application list to the mobile applications for the account.
@param mobileApplications The mobile applications to add | [
"Adds",
"the",
"mobile",
"application",
"list",
"to",
"the",
"mobile",
"applications",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/MobileApplicationCache.java#L55-L59 | train |
pierre/serialization | hadoop/src/main/java/com/ning/metrics/serialization/hadoop/FileSystemAccess.java | FileSystemAccess.getFileSystemSafe | private FileSystem getFileSystemSafe() throws IOException
{
try {
fs.getFileStatus(new Path("/"));
return fs;
}
catch (NullPointerException e) {
throw new IOException("file system not initialized");
}
} | java | private FileSystem getFileSystemSafe() throws IOException
{
try {
fs.getFileStatus(new Path("/"));
return fs;
}
catch (NullPointerException e) {
throw new IOException("file system not initialized");
}
} | [
"private",
"FileSystem",
"getFileSystemSafe",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"fs",
".",
"getFileStatus",
"(",
"new",
"Path",
"(",
"\"/\"",
")",
")",
";",
"return",
"fs",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
... | throws an IOException if the current FileSystem isn't working | [
"throws",
"an",
"IOException",
"if",
"the",
"current",
"FileSystem",
"isn",
"t",
"working"
] | b15b7c749ba78bfe94dce8fc22f31b30b2e6830b | https://github.com/pierre/serialization/blob/b15b7c749ba78bfe94dce8fc22f31b30b2e6830b/hadoop/src/main/java/com/ning/metrics/serialization/hadoop/FileSystemAccess.java#L125-L134 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java | PostalCodeManager.isValidPostalCode | @Nonnull
public ETriState isValidPostalCode (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
if (aPostalCountry == null)
return ETriState.UNDEFINED;
return ETriState.valueOf (aPostalCountry.isValidPostalCode (sPostalCode));
} | java | @Nonnull
public ETriState isValidPostalCode (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
if (aPostalCountry == null)
return ETriState.UNDEFINED;
return ETriState.valueOf (aPostalCountry.isValidPostalCode (sPostalCode));
} | [
"@",
"Nonnull",
"public",
"ETriState",
"isValidPostalCode",
"(",
"@",
"Nullable",
"final",
"Locale",
"aCountry",
",",
"@",
"Nullable",
"final",
"String",
"sPostalCode",
")",
"{",
"final",
"IPostalCodeCountry",
"aPostalCountry",
"=",
"getPostalCountryOfCountry",
"(",
... | Check if the passed postal code is valid for the passed country.
@param aCountry
The country to check. May be <code>null</code>.
@param sPostalCode
The postal code to check. May be <code>null</code>.
@return {@link ETriState#UNDEFINED} if no information for the passed
country are present, {@link ETriState#TRUE} if the postal code is
valid or {@link ETriState#FALSE} if the passed postal code is
explicitly not valid for the passed country. | [
"Check",
"if",
"the",
"passed",
"postal",
"code",
"is",
"valid",
"for",
"the",
"passed",
"country",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java#L111-L118 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java | PostalCodeManager.isValidPostalCodeDefaultYes | public boolean isValidPostalCodeDefaultYes (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (true);
} | java | public boolean isValidPostalCodeDefaultYes (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (true);
} | [
"public",
"boolean",
"isValidPostalCodeDefaultYes",
"(",
"@",
"Nullable",
"final",
"Locale",
"aCountry",
",",
"@",
"Nullable",
"final",
"String",
"sPostalCode",
")",
"{",
"return",
"isValidPostalCode",
"(",
"aCountry",
",",
"sPostalCode",
")",
".",
"getAsBooleanValu... | Check if the passed postal code is valid for the passed country. If no
information for that specific country is defined, the postal code is
assumed valid!
@param aCountry
The country to check. May be <code>null</code>.
@param sPostalCode
The postal code to check. May be <code>null</code>.
@return <code>true</code> if the postal code is valid for the passed
country or if no information for that country are present,
<code>false</code> otherwise. | [
"Check",
"if",
"the",
"passed",
"postal",
"code",
"is",
"valid",
"for",
"the",
"passed",
"country",
".",
"If",
"no",
"information",
"for",
"that",
"specific",
"country",
"is",
"defined",
"the",
"postal",
"code",
"is",
"assumed",
"valid!"
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java#L133-L136 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java | PostalCodeManager.isValidPostalCodeDefaultNo | public boolean isValidPostalCodeDefaultNo (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (false);
} | java | public boolean isValidPostalCodeDefaultNo (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (false);
} | [
"public",
"boolean",
"isValidPostalCodeDefaultNo",
"(",
"@",
"Nullable",
"final",
"Locale",
"aCountry",
",",
"@",
"Nullable",
"final",
"String",
"sPostalCode",
")",
"{",
"return",
"isValidPostalCode",
"(",
"aCountry",
",",
"sPostalCode",
")",
".",
"getAsBooleanValue... | Check if the passed postal code is valid for the passed country. If no
information for that specific country is defined, the postal code is
assumed invalid!
@param aCountry
The country to check. May be <code>null</code>.
@param sPostalCode
The postal code to check. May be <code>null</code>.
@return <code>true</code> if the postal code is valid for the passed
country, <code>false</code> otherwise also if no information for
the passed country are present. | [
"Check",
"if",
"the",
"passed",
"postal",
"code",
"is",
"valid",
"for",
"the",
"passed",
"country",
".",
"If",
"no",
"information",
"for",
"that",
"specific",
"country",
"is",
"defined",
"the",
"postal",
"code",
"is",
"assumed",
"invalid!"
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java#L151-L154 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java | PostalCodeManager.getPostalCodeExamples | @Nullable
@ReturnsMutableCopy
public ICommonsList <String> getPostalCodeExamples (@Nullable final Locale aCountry)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
return aPostalCountry == null ? null : aPostalCountry.getAllExamples ();
} | java | @Nullable
@ReturnsMutableCopy
public ICommonsList <String> getPostalCodeExamples (@Nullable final Locale aCountry)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
return aPostalCountry == null ? null : aPostalCountry.getAllExamples ();
} | [
"@",
"Nullable",
"@",
"ReturnsMutableCopy",
"public",
"ICommonsList",
"<",
"String",
">",
"getPostalCodeExamples",
"(",
"@",
"Nullable",
"final",
"Locale",
"aCountry",
")",
"{",
"final",
"IPostalCodeCountry",
"aPostalCountry",
"=",
"getPostalCountryOfCountry",
"(",
"a... | Get a list of possible postal code examples for the passed country.
@param aCountry
The country for which the examples are to be retrieved. May be
<code>null</code>.
@return <code>null</code> if no postal code definitions exists for the
passed country, a non-empty list with all examples otherwise. | [
"Get",
"a",
"list",
"of",
"possible",
"postal",
"code",
"examples",
"for",
"the",
"passed",
"country",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/postal/PostalCodeManager.java#L165-L171 | train |
sbang/jsr330activator | jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java | MockBundleContext.registerService | @Override
public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) {
MockServiceReference<Object> serviceReference = new MockServiceReference<Object>(getBundle(), properties);
if (serviceRegistrations.get(clazz) == null) { serviceRegistrations.put(clazz, new ArrayList<ServiceReference<?>>()); }
serviceRegistrations.get(clazz).add(serviceReference);
serviceImplementations.put(serviceReference, service);
notifyListenersAboutNewService(clazz, serviceReference);
return new MockServiceRegistration<Object>(this, serviceReference);
} | java | @Override
public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) {
MockServiceReference<Object> serviceReference = new MockServiceReference<Object>(getBundle(), properties);
if (serviceRegistrations.get(clazz) == null) { serviceRegistrations.put(clazz, new ArrayList<ServiceReference<?>>()); }
serviceRegistrations.get(clazz).add(serviceReference);
serviceImplementations.put(serviceReference, service);
notifyListenersAboutNewService(clazz, serviceReference);
return new MockServiceRegistration<Object>(this, serviceReference);
} | [
"@",
"Override",
"public",
"ServiceRegistration",
"<",
"?",
">",
"registerService",
"(",
"String",
"clazz",
",",
"Object",
"service",
",",
"Dictionary",
"<",
"String",
",",
"?",
">",
"properties",
")",
"{",
"MockServiceReference",
"<",
"Object",
">",
"serviceR... | Register a service with the bundle context.
@param clazz the fully qualified name of the interface of the service being registered
@param service the object referencing the service
@param properties a name/value map for names and values that can be used to qualify the service when multiple implementations are availabl
@return a {@link ServiceRegistration} object that can be used to unregister the service later | [
"Register",
"a",
"service",
"with",
"the",
"bundle",
"context",
"."
] | a9e106db3242f1bfcf76ec391b5a3026679b9645 | https://github.com/sbang/jsr330activator/blob/a9e106db3242f1bfcf76ec391b5a3026679b9645/jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java#L71-L79 | train |
sbang/jsr330activator | jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java | MockBundleContext.addServiceListener | @Override
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
if (null == filteredServiceListeners.get(filter)) {
filteredServiceListeners.put(filter, new ArrayList<ServiceListener>(1));
}
filteredServiceListeners.get(filter).add(listener);
} | java | @Override
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
if (null == filteredServiceListeners.get(filter)) {
filteredServiceListeners.put(filter, new ArrayList<ServiceListener>(1));
}
filteredServiceListeners.get(filter).add(listener);
} | [
"@",
"Override",
"public",
"void",
"addServiceListener",
"(",
"ServiceListener",
"listener",
",",
"String",
"filter",
")",
"throws",
"InvalidSyntaxException",
"{",
"if",
"(",
"null",
"==",
"filteredServiceListeners",
".",
"get",
"(",
"filter",
")",
")",
"{",
"fi... | Register a listener for a service, using a filter expression.
@param listener the listener callback object to register
@param filter a filter expression matching a service | [
"Register",
"a",
"listener",
"for",
"a",
"service",
"using",
"a",
"filter",
"expression",
"."
] | a9e106db3242f1bfcf76ec391b5a3026679b9645 | https://github.com/sbang/jsr330activator/blob/a9e106db3242f1bfcf76ec391b5a3026679b9645/jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java#L202-L209 | train |
sbang/jsr330activator | jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java | MockBundleContext.removeServiceListener | @Override
public void removeServiceListener(ServiceListener listener) {
// Note: if unfiltered service listeners are implemented
// This method needs to look for, and remove, the listener there
// as well
// Go through all of the filters, and for each filter
// remove the listener from the filter's list.
for(Entry<String, List<ServiceListener>> filteredList : filteredServiceListeners.entrySet()) {
filteredList.getValue().remove(listener);
}
} | java | @Override
public void removeServiceListener(ServiceListener listener) {
// Note: if unfiltered service listeners are implemented
// This method needs to look for, and remove, the listener there
// as well
// Go through all of the filters, and for each filter
// remove the listener from the filter's list.
for(Entry<String, List<ServiceListener>> filteredList : filteredServiceListeners.entrySet()) {
filteredList.getValue().remove(listener);
}
} | [
"@",
"Override",
"public",
"void",
"removeServiceListener",
"(",
"ServiceListener",
"listener",
")",
"{",
"// Note: if unfiltered service listeners are implemented",
"// This method needs to look for, and remove, the listener there",
"// as well",
"// Go through all of the filters, and for... | Remove a listener object
@param listener the listener callback object to remove | [
"Remove",
"a",
"listener",
"object"
] | a9e106db3242f1bfcf76ec391b5a3026679b9645 | https://github.com/sbang/jsr330activator/blob/a9e106db3242f1bfcf76ec391b5a3026679b9645/jsr330activator.mocks/src/main/java/no/steria/osgi/mocks/MockBundleContext.java#L275-L286 | train |
CloudBees-community/cloudbees-log4j-extras | src/main/java/com/cloudbees/log4j/jmx/Log4jConfigurer.java | Log4jConfigurer.getLoggerList | @Nonnull
public String[] getLoggerList() {
try {
Enumeration<Logger> currentLoggers = LogManager.getLoggerRepository().getCurrentLoggers();
List<String> loggerNames = new ArrayList<String>();
while (currentLoggers.hasMoreElements()) {
loggerNames.add(currentLoggers.nextElement().getName());
}
return loggerNames.toArray(new String[0]);
} catch (RuntimeException e) {
logger.warn("Exception getting logger names", e);
throw e;
}
} | java | @Nonnull
public String[] getLoggerList() {
try {
Enumeration<Logger> currentLoggers = LogManager.getLoggerRepository().getCurrentLoggers();
List<String> loggerNames = new ArrayList<String>();
while (currentLoggers.hasMoreElements()) {
loggerNames.add(currentLoggers.nextElement().getName());
}
return loggerNames.toArray(new String[0]);
} catch (RuntimeException e) {
logger.warn("Exception getting logger names", e);
throw e;
}
} | [
"@",
"Nonnull",
"public",
"String",
"[",
"]",
"getLoggerList",
"(",
")",
"{",
"try",
"{",
"Enumeration",
"<",
"Logger",
">",
"currentLoggers",
"=",
"LogManager",
".",
"getLoggerRepository",
"(",
")",
".",
"getCurrentLoggers",
"(",
")",
";",
"List",
"<",
"S... | Returns the list of active loggers.
@return logger names | [
"Returns",
"the",
"list",
"of",
"active",
"loggers",
"."
] | cd204b9a4c02d69ff9adc4dbda65f90fc0de98f7 | https://github.com/CloudBees-community/cloudbees-log4j-extras/blob/cd204b9a4c02d69ff9adc4dbda65f90fc0de98f7/src/main/java/com/cloudbees/log4j/jmx/Log4jConfigurer.java#L45-L58 | train |
danieldk/conllx-io | src/main/java/eu/danieldk/nlp/conllx/SimpleSentence.java | SimpleSentence.checkHead | private void checkHead(Token token, Optional<Integer> optHead) {
if (optHead.isPresent()) {
int head = optHead.get();
Preconditions.checkArgument(head >= 0 && head <= tokens.size(), String.format("Head should refer to token or 0: %s", token));
}
} | java | private void checkHead(Token token, Optional<Integer> optHead) {
if (optHead.isPresent()) {
int head = optHead.get();
Preconditions.checkArgument(head >= 0 && head <= tokens.size(), String.format("Head should refer to token or 0: %s", token));
}
} | [
"private",
"void",
"checkHead",
"(",
"Token",
"token",
",",
"Optional",
"<",
"Integer",
">",
"optHead",
")",
"{",
"if",
"(",
"optHead",
".",
"isPresent",
"(",
")",
")",
"{",
"int",
"head",
"=",
"optHead",
".",
"get",
"(",
")",
";",
"Preconditions",
"... | Check that the head is connected.
@param optHead | [
"Check",
"that",
"the",
"head",
"is",
"connected",
"."
] | c1e6028bc3394f000b1efe231ae7e7f625e10d64 | https://github.com/danieldk/conllx-io/blob/c1e6028bc3394f000b1efe231ae7e7f625e10d64/src/main/java/eu/danieldk/nlp/conllx/SimpleSentence.java#L73-L78 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/ValueUtils.java | ValueUtils.getValue | public static Long getValue(final Long value, final Long defaultValue) {
return value == null ? defaultValue : value;
} | java | public static Long getValue(final Long value, final Long defaultValue) {
return value == null ? defaultValue : value;
} | [
"public",
"static",
"Long",
"getValue",
"(",
"final",
"Long",
"value",
",",
"final",
"Long",
"defaultValue",
")",
"{",
"return",
"value",
"==",
"null",
"?",
"defaultValue",
":",
"value",
";",
"}"
] | Returns defaultValue if given value is null; else returns it self.
@param value value to be test.
@param defaultValue default value to return if given value is null.
@return defaultValue if given value is null; else returns it self. | [
"Returns",
"defaultValue",
"if",
"given",
"value",
"is",
"null",
";",
"else",
"returns",
"it",
"self",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/ValueUtils.java#L39-L42 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/TextFile.java | TextFile.read | public boolean read() throws IOException
{
valid = false;
File file = new File(filename);
FileReader reader = new FileReader(file);
if(file.exists())
{
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
valid = true;
else
logger.severe("Unable to read file contents: "+file.getAbsolutePath());
}
else
{
logger.severe("File does not exist: "+file.getAbsolutePath());
}
try
{
if(reader != null)
reader.close();
}
catch(IOException e)
{
}
return valid;
} | java | public boolean read() throws IOException
{
valid = false;
File file = new File(filename);
FileReader reader = new FileReader(file);
if(file.exists())
{
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
valid = true;
else
logger.severe("Unable to read file contents: "+file.getAbsolutePath());
}
else
{
logger.severe("File does not exist: "+file.getAbsolutePath());
}
try
{
if(reader != null)
reader.close();
}
catch(IOException e)
{
}
return valid;
} | [
"public",
"boolean",
"read",
"(",
")",
"throws",
"IOException",
"{",
"valid",
"=",
"false",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"filename",
")",
";",
"FileReader",
"reader",
"=",
"new",
"FileReader",
"(",
"file",
")",
";",
"if",
"(",
"file",
... | Reads the contents of the file.
@return <CODE>true</CODE> if the file was read successfully
@throws IOException The file could not be opened | [
"Reads",
"the",
"contents",
"of",
"the",
"file",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/TextFile.java#L91-L120 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/TextFile.java | TextFile.read | public boolean read(InputStream stream) throws IOException
{
valid = false;
InputStreamReader reader = new InputStreamReader(stream);
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
valid = true;
else
logger.severe("Unable to read file contents: "+filename);
try
{
if(reader != null)
reader.close();
}
catch(IOException e)
{
}
return valid;
} | java | public boolean read(InputStream stream) throws IOException
{
valid = false;
InputStreamReader reader = new InputStreamReader(stream);
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
valid = true;
else
logger.severe("Unable to read file contents: "+filename);
try
{
if(reader != null)
reader.close();
}
catch(IOException e)
{
}
return valid;
} | [
"public",
"boolean",
"read",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"valid",
"=",
"false",
";",
"InputStreamReader",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"stream",
")",
";",
"// Load the file contents",
"contents",
"=",
"getCon... | Reads the contents of the given stream.
@param stream The input stream of the file
@return <CODE>true</CODE> if the file was read successfully
@throws IOException The file could not be opened | [
"Reads",
"the",
"contents",
"of",
"the",
"given",
"stream",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/TextFile.java#L128-L150 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/TextFile.java | TextFile.getContents | private String getContents(Reader reader, String terminator) throws IOException
{
String line = null;
StringBuffer buff = new StringBuffer();
BufferedReader in = new BufferedReader(reader);
while((line = in.readLine()) != null)
{
buff.append(line);
if(terminator != null)
buff.append(terminator);
}
reader.close();
return buff.toString();
} | java | private String getContents(Reader reader, String terminator) throws IOException
{
String line = null;
StringBuffer buff = new StringBuffer();
BufferedReader in = new BufferedReader(reader);
while((line = in.readLine()) != null)
{
buff.append(line);
if(terminator != null)
buff.append(terminator);
}
reader.close();
return buff.toString();
} | [
"private",
"String",
"getContents",
"(",
"Reader",
"reader",
",",
"String",
"terminator",
")",
"throws",
"IOException",
"{",
"String",
"line",
"=",
"null",
";",
"StringBuffer",
"buff",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"BufferedReader",
"in",
"=",
"... | Read the contents of the file using the given reader.
@param reader The reader used to read the file stream
@param terminator The line terminator of the YAML file
@return The contents of the file as a string | [
"Read",
"the",
"contents",
"of",
"the",
"file",
"using",
"the",
"given",
"reader",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/TextFile.java#L158-L171 | train |
wmdietl/jsr308-langtools | src/share/classes/javax/lang/model/type/MirroredTypeException.java | MirroredTypeException.readObject | private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
type = null;
types = null;
} | java | private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
type = null;
types = null;
} | [
"private",
"void",
"readObject",
"(",
"ObjectInputStream",
"s",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"s",
".",
"defaultReadObject",
"(",
")",
";",
"type",
"=",
"null",
";",
"types",
"=",
"null",
";",
"}"
] | Explicitly set all transient fields. | [
"Explicitly",
"set",
"all",
"transient",
"fields",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/javax/lang/model/type/MirroredTypeException.java#L74-L79 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java | ExportHandler.generatePdf | public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Document document = new Document();
PdfWriter.getInstance(document, out);
if (columns == null)
{
if (rows.size() > 0) return;
columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(final Object input) {
return new ColumnDef()
{{
setName((String)input);
}};
}
}));
}
if (columns.size() > 14)
document.setPageSize(PageSize.A1);
else if (columns.size() > 10)
document.setPageSize(PageSize.A2);
else if (columns.size() > 7)
document.setPageSize(PageSize.A3);
else
document.setPageSize(PageSize.A4);
document.open();
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, BaseColor.BLACK);
Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD, BaseColor.BLACK);
int size = columns.size();
PdfPTable table = new PdfPTable(size);
for (ColumnDef column : columns)
{
PdfPCell c1 = new PdfPCell(new Phrase(column.getName(), headerFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
}
table.setHeaderRows(1);
if (rows != null)
for (Map<String, Object> row : rows)
{
for (ColumnDef column : columns)
{
table.addCell(new Phrase(String.valueOf(row.get(column.getName())), font));
}
}
document.add(table);
document.close();
} catch (Exception e) {
e.printStackTrace();
}
} | java | public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Document document = new Document();
PdfWriter.getInstance(document, out);
if (columns == null)
{
if (rows.size() > 0) return;
columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(final Object input) {
return new ColumnDef()
{{
setName((String)input);
}};
}
}));
}
if (columns.size() > 14)
document.setPageSize(PageSize.A1);
else if (columns.size() > 10)
document.setPageSize(PageSize.A2);
else if (columns.size() > 7)
document.setPageSize(PageSize.A3);
else
document.setPageSize(PageSize.A4);
document.open();
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, BaseColor.BLACK);
Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD, BaseColor.BLACK);
int size = columns.size();
PdfPTable table = new PdfPTable(size);
for (ColumnDef column : columns)
{
PdfPCell c1 = new PdfPCell(new Phrase(column.getName(), headerFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
}
table.setHeaderRows(1);
if (rows != null)
for (Map<String, Object> row : rows)
{
for (ColumnDef column : columns)
{
table.addCell(new Phrase(String.valueOf(row.get(column.getName())), font));
}
}
document.add(table);
document.close();
} catch (Exception e) {
e.printStackTrace();
}
} | [
"public",
"void",
"generatePdf",
"(",
"OutputStream",
"out",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"rows",
",",
"List",
"<",
"ColumnDef",
">",
"columns",
")",
"{",
"try",
"{",
"Document",
"document",
"=",
"new",
"Document",
"... | Takes the output and transforms it into a PDF file.
@param out Output stream.
@param rows Rows of data from reporting-core
@param columns Columns to list on report | [
"Takes",
"the",
"output",
"and",
"transforms",
"it",
"into",
"a",
"PDF",
"file",
"."
] | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java#L58-L109 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java | ExportHandler.generateCsv | public void generateCsv(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
ICsvMapWriter csvWriter = null;
try {
csvWriter = new CsvMapWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the bean values to each column (names must match)
String[] header = new String[] {};
CellProcessor[] processors = new CellProcessor[] {};
if (columns != null)
{
header = (String[])CollectionUtils.collect(columns, new Transformer() {
@Override
public Object transform(Object input) {
ColumnDef column = (ColumnDef)input;
return column.getName();
}
}).toArray(new String[0]) ;
processors = (CellProcessor[]) CollectionUtils.collect(columns, new Transformer() {
@Override
public Object transform(Object input) {
return new Optional();
}
}).toArray(new CellProcessor[0]);
} else if (rows.size() > 0)
{
header = new ArrayList<String>(rows.get(0).keySet()).toArray(new String[0]);
processors = (CellProcessor[]) CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(Object input) {
return new Optional();
}
}).toArray(new CellProcessor[0]);
}
if (header.length > 0)
csvWriter.writeHeader(header);
if (rows != null)
for (Map<String, Object> row : rows)
{
csvWriter.write(row, header, processors);
}
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} finally {
if( csvWriter != null ) {
try {
csvWriter.close();
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
} | java | public void generateCsv(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
ICsvMapWriter csvWriter = null;
try {
csvWriter = new CsvMapWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the bean values to each column (names must match)
String[] header = new String[] {};
CellProcessor[] processors = new CellProcessor[] {};
if (columns != null)
{
header = (String[])CollectionUtils.collect(columns, new Transformer() {
@Override
public Object transform(Object input) {
ColumnDef column = (ColumnDef)input;
return column.getName();
}
}).toArray(new String[0]) ;
processors = (CellProcessor[]) CollectionUtils.collect(columns, new Transformer() {
@Override
public Object transform(Object input) {
return new Optional();
}
}).toArray(new CellProcessor[0]);
} else if (rows.size() > 0)
{
header = new ArrayList<String>(rows.get(0).keySet()).toArray(new String[0]);
processors = (CellProcessor[]) CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(Object input) {
return new Optional();
}
}).toArray(new CellProcessor[0]);
}
if (header.length > 0)
csvWriter.writeHeader(header);
if (rows != null)
for (Map<String, Object> row : rows)
{
csvWriter.write(row, header, processors);
}
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} finally {
if( csvWriter != null ) {
try {
csvWriter.close();
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
} | [
"public",
"void",
"generateCsv",
"(",
"OutputStream",
"out",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"rows",
",",
"List",
"<",
"ColumnDef",
">",
"columns",
")",
"{",
"ICsvMapWriter",
"csvWriter",
"=",
"null",
";",
"try",
"{",
"... | Takes the output and transforms it into a csv file.
@param out Output stream.
@param rows Rows of data from reporting-core
@param columns Columns to list on report | [
"Takes",
"the",
"output",
"and",
"transforms",
"it",
"into",
"a",
"csv",
"file",
"."
] | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java#L117-L167 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java | ExportHandler.generateXls | public void generateXls(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
String safeName = WorkbookUtil.createSafeSheetName("Report"); // returns " O'Brien's sales "
Sheet reportSheet = wb.createSheet(safeName);
short rowc = 0;
Row nrow = reportSheet.createRow(rowc++);
short cellc = 0;
if (rows == null) return;
if (columns == null && rows.size() > 0)
{
columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(final Object input) {
return new ColumnDef()
{{
setName((String)input);
}};
}
}));
}
if (columns != null)
{
for (ColumnDef column : columns)
{
Cell cell = nrow.createCell(cellc++);
cell.setCellValue(column.getName());
}
}
for (Map<String, Object> row : rows)
{
nrow = reportSheet.createRow(rowc++);
cellc = 0;
for (ColumnDef column : columns)
{
Cell cell = nrow.createCell(cellc++);
cell.setCellValue(String.valueOf(row.get(column.getName())));
}
}
wb.write(out);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} | java | public void generateXls(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
String safeName = WorkbookUtil.createSafeSheetName("Report"); // returns " O'Brien's sales "
Sheet reportSheet = wb.createSheet(safeName);
short rowc = 0;
Row nrow = reportSheet.createRow(rowc++);
short cellc = 0;
if (rows == null) return;
if (columns == null && rows.size() > 0)
{
columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
@Override
public Object transform(final Object input) {
return new ColumnDef()
{{
setName((String)input);
}};
}
}));
}
if (columns != null)
{
for (ColumnDef column : columns)
{
Cell cell = nrow.createCell(cellc++);
cell.setCellValue(column.getName());
}
}
for (Map<String, Object> row : rows)
{
nrow = reportSheet.createRow(rowc++);
cellc = 0;
for (ColumnDef column : columns)
{
Cell cell = nrow.createCell(cellc++);
cell.setCellValue(String.valueOf(row.get(column.getName())));
}
}
wb.write(out);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} | [
"public",
"void",
"generateXls",
"(",
"OutputStream",
"out",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"rows",
",",
"List",
"<",
"ColumnDef",
">",
"columns",
")",
"{",
"try",
"{",
"Workbook",
"wb",
"=",
"new",
"HSSFWorkbook",
"("... | Takes the output and transforms it into a Excel file.
@param out Output stream.
@param rows Rows of data from reporting-core
@param columns Columns to list on report | [
"Takes",
"the",
"output",
"and",
"transforms",
"it",
"into",
"a",
"Excel",
"file",
"."
] | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/ExportHandler.java#L175-L220 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java | Extern.readPackageListFromFile | private void readPackageListFromFile(String path, DocFile pkgListPath)
throws Fault {
DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
if (! (file.isAbsolute() || linkoffline)){
file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
}
try {
if (file.exists() && file.canRead()) {
boolean pathIsRelative =
!DocFile.createFileForInput(configuration, path).isAbsolute()
&& !isUrl(path);
readPackageList(file.openInputStream(), path, pathIsRelative);
} else {
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
}
} catch (IOException exc) {
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
}
} | java | private void readPackageListFromFile(String path, DocFile pkgListPath)
throws Fault {
DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
if (! (file.isAbsolute() || linkoffline)){
file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
}
try {
if (file.exists() && file.canRead()) {
boolean pathIsRelative =
!DocFile.createFileForInput(configuration, path).isAbsolute()
&& !isUrl(path);
readPackageList(file.openInputStream(), path, pathIsRelative);
} else {
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
}
} catch (IOException exc) {
throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
}
} | [
"private",
"void",
"readPackageListFromFile",
"(",
"String",
"path",
",",
"DocFile",
"pkgListPath",
")",
"throws",
"Fault",
"{",
"DocFile",
"file",
"=",
"pkgListPath",
".",
"resolve",
"(",
"DocPaths",
".",
"PACKAGE_LIST",
")",
";",
"if",
"(",
"!",
"(",
"file... | Read the "package-list" file which is available locally.
@param path URL or directory path to the packages.
@param pkgListPath Path to the local "package-list" file. | [
"Read",
"the",
"package",
"-",
"list",
"file",
"which",
"is",
"available",
"locally",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java#L252-L270 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java | VisibleMemberMap.sort | private void sort(List<ClassDoc> list) {
List<ClassDoc> classes = new ArrayList<ClassDoc>();
List<ClassDoc> interfaces = new ArrayList<ClassDoc>();
for (int i = 0; i < list.size(); i++) {
ClassDoc cd = list.get(i);
if (cd.isClass()) {
classes.add(cd);
} else {
interfaces.add(cd);
}
}
list.clear();
list.addAll(classes);
list.addAll(interfaces);
} | java | private void sort(List<ClassDoc> list) {
List<ClassDoc> classes = new ArrayList<ClassDoc>();
List<ClassDoc> interfaces = new ArrayList<ClassDoc>();
for (int i = 0; i < list.size(); i++) {
ClassDoc cd = list.get(i);
if (cd.isClass()) {
classes.add(cd);
} else {
interfaces.add(cd);
}
}
list.clear();
list.addAll(classes);
list.addAll(interfaces);
} | [
"private",
"void",
"sort",
"(",
"List",
"<",
"ClassDoc",
">",
"list",
")",
"{",
"List",
"<",
"ClassDoc",
">",
"classes",
"=",
"new",
"ArrayList",
"<",
"ClassDoc",
">",
"(",
")",
";",
"List",
"<",
"ClassDoc",
">",
"interfaces",
"=",
"new",
"ArrayList",
... | Sort the given mixed list of classes and interfaces to a list of
classes followed by interfaces traversed. Don't sort alphabetically. | [
"Sort",
"the",
"given",
"mixed",
"list",
"of",
"classes",
"and",
"interfaces",
"to",
"a",
"list",
"of",
"classes",
"followed",
"by",
"interfaces",
"traversed",
".",
"Don",
"t",
"sort",
"alphabetically",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java#L221-L235 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java | ThreadExtensions.runCallableWithCpuCores | public static <T> T runCallableWithCpuCores(Callable<T> task, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
return forkJoinPool.submit(task).get();
} | java | public static <T> T runCallableWithCpuCores(Callable<T> task, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
return forkJoinPool.submit(task).get();
} | [
"public",
"static",
"<",
"T",
">",
"T",
"runCallableWithCpuCores",
"(",
"Callable",
"<",
"T",
">",
"task",
",",
"int",
"cpuCores",
")",
"throws",
"ExecutionException",
",",
"InterruptedException",
"{",
"ForkJoinPool",
"forkJoinPool",
"=",
"new",
"ForkJoinPool",
... | Creates a custom thread pool that are executed in parallel processes with the given number of
the cpu cores
@param task
the {@link Callable} task to execute
@param cpuCores
the number of the cpu cores to run with
@param <T>
the generic type of the result
@return the result of the given task
@throws ExecutionException
if the computation threw an exception
@throws InterruptedException
if the current thread is not a member of a ForkJoinPool and was interrupted while
waiting | [
"Creates",
"a",
"custom",
"thread",
"pool",
"that",
"are",
"executed",
"in",
"parallel",
"processes",
"with",
"the",
"given",
"number",
"of",
"the",
"cpu",
"cores"
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java#L62-L67 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java | ThreadExtensions.runAsyncSupplierWithCpuCores | public static <T> T runAsyncSupplierWithCpuCores(Supplier<T> supplier, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
CompletableFuture<T> future = CompletableFuture.supplyAsync(supplier, forkJoinPool);
return future.get();
} | java | public static <T> T runAsyncSupplierWithCpuCores(Supplier<T> supplier, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
CompletableFuture<T> future = CompletableFuture.supplyAsync(supplier, forkJoinPool);
return future.get();
} | [
"public",
"static",
"<",
"T",
">",
"T",
"runAsyncSupplierWithCpuCores",
"(",
"Supplier",
"<",
"T",
">",
"supplier",
",",
"int",
"cpuCores",
")",
"throws",
"ExecutionException",
",",
"InterruptedException",
"{",
"ForkJoinPool",
"forkJoinPool",
"=",
"new",
"ForkJoin... | Creates a custom thread pool that are executed in parallel processes with the will run with
the given number of the cpu cores
@param supplier
the {@link Supplier} task to execute
@param cpuCores
the number of the cpu cores to run with
@param <T>
the generic type of the result
@return the result of the given task
@throws ExecutionException
if the computation threw an exception
@throws InterruptedException
if the current thread is not a member of a ForkJoinPool and was interrupted while
waiting | [
"Creates",
"a",
"custom",
"thread",
"pool",
"that",
"are",
"executed",
"in",
"parallel",
"processes",
"with",
"the",
"will",
"run",
"with",
"the",
"given",
"number",
"of",
"the",
"cpu",
"cores"
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java#L86-L92 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java | ThreadExtensions.resolveRunningThreads | public static Thread[] resolveRunningThreads()
{
final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
final Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
return threadArray;
} | java | public static Thread[] resolveRunningThreads()
{
final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
final Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
return threadArray;
} | [
"public",
"static",
"Thread",
"[",
"]",
"resolveRunningThreads",
"(",
")",
"{",
"final",
"Set",
"<",
"Thread",
">",
"threadSet",
"=",
"Thread",
".",
"getAllStackTraces",
"(",
")",
".",
"keySet",
"(",
")",
";",
"final",
"Thread",
"[",
"]",
"threadArray",
... | Finds all threads the are currently running.
@return An array with all threads the are currently running. | [
"Finds",
"all",
"threads",
"the",
"are",
"currently",
"running",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/thread/ThreadExtensions.java#L99-L104 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/TraceWrapper.java | TraceWrapper.alert | public final Trace alert(Class<?> c, String message) {
return _trace.alert(c, message);
} | java | public final Trace alert(Class<?> c, String message) {
return _trace.alert(c, message);
} | [
"public",
"final",
"Trace",
"alert",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"String",
"message",
")",
"{",
"return",
"_trace",
".",
"alert",
"(",
"c",
",",
"message",
")",
";",
"}"
] | Reports an error condition. | [
"Reports",
"an",
"error",
"condition",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/TraceWrapper.java#L74-L76 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java | GeneratedDFactoryDaoImpl.queryByBaseUrl | public Iterable<DFactory> queryByBaseUrl(java.lang.String baseUrl) {
return queryByField(null, DFactoryMapper.Field.BASEURL.getFieldName(), baseUrl);
} | java | public Iterable<DFactory> queryByBaseUrl(java.lang.String baseUrl) {
return queryByField(null, DFactoryMapper.Field.BASEURL.getFieldName(), baseUrl);
} | [
"public",
"Iterable",
"<",
"DFactory",
">",
"queryByBaseUrl",
"(",
"java",
".",
"lang",
".",
"String",
"baseUrl",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DFactoryMapper",
".",
"Field",
".",
"BASEURL",
".",
"getFieldName",
"(",
")",
",",
"bas... | query-by method for field baseUrl
@param baseUrl the specified attribute
@return an Iterable of DFactorys for the specified baseUrl | [
"query",
"-",
"by",
"method",
"for",
"field",
"baseUrl"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java#L70-L72 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java | GeneratedDFactoryDaoImpl.queryByClientId | public Iterable<DFactory> queryByClientId(java.lang.String clientId) {
return queryByField(null, DFactoryMapper.Field.CLIENTID.getFieldName(), clientId);
} | java | public Iterable<DFactory> queryByClientId(java.lang.String clientId) {
return queryByField(null, DFactoryMapper.Field.CLIENTID.getFieldName(), clientId);
} | [
"public",
"Iterable",
"<",
"DFactory",
">",
"queryByClientId",
"(",
"java",
".",
"lang",
".",
"String",
"clientId",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DFactoryMapper",
".",
"Field",
".",
"CLIENTID",
".",
"getFieldName",
"(",
")",
",",
"... | query-by method for field clientId
@param clientId the specified attribute
@return an Iterable of DFactorys for the specified clientId | [
"query",
"-",
"by",
"method",
"for",
"field",
"clientId"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java#L79-L81 | train |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java | GeneratedDFactoryDaoImpl.queryByClientSecret | public Iterable<DFactory> queryByClientSecret(java.lang.String clientSecret) {
return queryByField(null, DFactoryMapper.Field.CLIENTSECRET.getFieldName(), clientSecret);
} | java | public Iterable<DFactory> queryByClientSecret(java.lang.String clientSecret) {
return queryByField(null, DFactoryMapper.Field.CLIENTSECRET.getFieldName(), clientSecret);
} | [
"public",
"Iterable",
"<",
"DFactory",
">",
"queryByClientSecret",
"(",
"java",
".",
"lang",
".",
"String",
"clientSecret",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DFactoryMapper",
".",
"Field",
".",
"CLIENTSECRET",
".",
"getFieldName",
"(",
")"... | query-by method for field clientSecret
@param clientSecret the specified attribute
@return an Iterable of DFactorys for the specified clientSecret | [
"query",
"-",
"by",
"method",
"for",
"field",
"clientSecret"
] | eb8ba8e6794a96ea0dd9744cada4f9ad9618f114 | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDFactoryDaoImpl.java#L88-L90 | train |
danieldk/conllx-io | src/main/java/eu/danieldk/nlp/conllx/reader/CONLLReader.java | CONLLReader.constructSentence | private Sentence constructSentence(List<Token> tokens) throws IOException {
Sentence sentence;
try {
sentence = new SimpleSentence(tokens, strict);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
return sentence;
} | java | private Sentence constructSentence(List<Token> tokens) throws IOException {
Sentence sentence;
try {
sentence = new SimpleSentence(tokens, strict);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
return sentence;
} | [
"private",
"Sentence",
"constructSentence",
"(",
"List",
"<",
"Token",
">",
"tokens",
")",
"throws",
"IOException",
"{",
"Sentence",
"sentence",
";",
"try",
"{",
"sentence",
"=",
"new",
"SimpleSentence",
"(",
"tokens",
",",
"strict",
")",
";",
"}",
"catch",
... | Construct a sentence. If strictness is used and invariants do not hold, convert
the exception to an IOException. | [
"Construct",
"a",
"sentence",
".",
"If",
"strictness",
"is",
"used",
"and",
"invariants",
"do",
"not",
"hold",
"convert",
"the",
"exception",
"to",
"an",
"IOException",
"."
] | c1e6028bc3394f000b1efe231ae7e7f625e10d64 | https://github.com/danieldk/conllx-io/blob/c1e6028bc3394f000b1efe231ae7e7f625e10d64/src/main/java/eu/danieldk/nlp/conllx/reader/CONLLReader.java#L115-L123 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javap/Options.java | Options.checkAccess | public boolean checkAccess(AccessFlags flags){
boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
boolean isPackage = !(isPublic || isProtected || isPrivate);
if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
return false;
else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
return false;
else if ((showAccess == 0) && (isPrivate))
return false;
else
return true;
} | java | public boolean checkAccess(AccessFlags flags){
boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
boolean isPackage = !(isPublic || isProtected || isPrivate);
if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
return false;
else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
return false;
else if ((showAccess == 0) && (isPrivate))
return false;
else
return true;
} | [
"public",
"boolean",
"checkAccess",
"(",
"AccessFlags",
"flags",
")",
"{",
"boolean",
"isPublic",
"=",
"flags",
".",
"is",
"(",
"AccessFlags",
".",
"ACC_PUBLIC",
")",
";",
"boolean",
"isProtected",
"=",
"flags",
".",
"is",
"(",
"AccessFlags",
".",
"ACC_PROTE... | Checks access of class, field or method. | [
"Checks",
"access",
"of",
"class",
"field",
"or",
"method",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javap/Options.java#L57-L72 | train |
petrbouda/joyrest | joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java | RequestMatcher.matchProduces | public static boolean matchProduces(InternalRoute route, InternalRequest<?> request) {
if (nonEmpty(request.getAccept())) {
List<MediaType> matchedAcceptTypes = getAcceptedMediaTypes(route.getProduces(), request.getAccept());
if (nonEmpty(matchedAcceptTypes)) {
request.setMatchedAccept(matchedAcceptTypes.get(0));
return true;
}
}
return false;
} | java | public static boolean matchProduces(InternalRoute route, InternalRequest<?> request) {
if (nonEmpty(request.getAccept())) {
List<MediaType> matchedAcceptTypes = getAcceptedMediaTypes(route.getProduces(), request.getAccept());
if (nonEmpty(matchedAcceptTypes)) {
request.setMatchedAccept(matchedAcceptTypes.get(0));
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"matchProduces",
"(",
"InternalRoute",
"route",
",",
"InternalRequest",
"<",
"?",
">",
"request",
")",
"{",
"if",
"(",
"nonEmpty",
"(",
"request",
".",
"getAccept",
"(",
")",
")",
")",
"{",
"List",
"<",
"MediaType",
">",
"m... | Matches route produces configurer and Accept-header in an incoming provider
@param route route configurer
@param request incoming provider object
@return returns {@code true} if the given route has produces Media-Type one of an Accept from an incoming provider | [
"Matches",
"route",
"produces",
"configurer",
"and",
"Accept",
"-",
"header",
"in",
"an",
"incoming",
"provider"
] | 58903f06fb7f0b8fdf1ef91318fb48a88bf970e0 | https://github.com/petrbouda/joyrest/blob/58903f06fb7f0b8fdf1ef91318fb48a88bf970e0/joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java#L47-L58 | train |
petrbouda/joyrest | joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java | RequestMatcher.matchConsumes | public static boolean matchConsumes(InternalRoute route, InternalRequest<?> request) {
if (route.getConsumes().contains(WILDCARD)) {
return true;
}
return route.getConsumes().contains(request.getContentType());
} | java | public static boolean matchConsumes(InternalRoute route, InternalRequest<?> request) {
if (route.getConsumes().contains(WILDCARD)) {
return true;
}
return route.getConsumes().contains(request.getContentType());
} | [
"public",
"static",
"boolean",
"matchConsumes",
"(",
"InternalRoute",
"route",
",",
"InternalRequest",
"<",
"?",
">",
"request",
")",
"{",
"if",
"(",
"route",
".",
"getConsumes",
"(",
")",
".",
"contains",
"(",
"WILDCARD",
")",
")",
"{",
"return",
"true",
... | Matches route consumes configurer and Content-Type header in an incoming provider
@param route route configurer
@param request incoming provider object
@return returns {@code true} if the given route has consumes Media-Type one of a Content-Type from an incoming provider | [
"Matches",
"route",
"consumes",
"configurer",
"and",
"Content",
"-",
"Type",
"header",
"in",
"an",
"incoming",
"provider"
] | 58903f06fb7f0b8fdf1ef91318fb48a88bf970e0 | https://github.com/petrbouda/joyrest/blob/58903f06fb7f0b8fdf1ef91318fb48a88bf970e0/joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java#L81-L87 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/IOUtils.java | IOUtils.getBytes | public static byte[] getBytes(final InputStream sourceInputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
byteArrayOutputStream.write(buffer, 0, len);
}
byte[] arrayOfByte = byteArrayOutputStream.toByteArray();
return arrayOfByte;
} | java | public static byte[] getBytes(final InputStream sourceInputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
byteArrayOutputStream.write(buffer, 0, len);
}
byte[] arrayOfByte = byteArrayOutputStream.toByteArray();
return arrayOfByte;
} | [
"public",
"static",
"byte",
"[",
"]",
"getBytes",
"(",
"final",
"InputStream",
"sourceInputStream",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"byteArrayOutputStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"byte",
"[",
"]",
"buffer",
... | Get bytes from given input stream.
@param sourceInputStream Source inputStream object to be handled.
@return bytes from given input stream.
@throws IOException | [
"Get",
"bytes",
"from",
"given",
"input",
"stream",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/IOUtils.java#L39-L48 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/IOUtils.java | IOUtils.write | public static boolean write(final InputStream sourceInputStream,
final OutputStream destinationOutputStream) throws IOException {
byte[] buffer = buildBuffer(BUFFER_SIZE);
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
destinationOutputStream.write(buffer, 0, len);
}
destinationOutputStream.flush();
return true;
} | java | public static boolean write(final InputStream sourceInputStream,
final OutputStream destinationOutputStream) throws IOException {
byte[] buffer = buildBuffer(BUFFER_SIZE);
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
destinationOutputStream.write(buffer, 0, len);
}
destinationOutputStream.flush();
return true;
} | [
"public",
"static",
"boolean",
"write",
"(",
"final",
"InputStream",
"sourceInputStream",
",",
"final",
"OutputStream",
"destinationOutputStream",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"buildBuffer",
"(",
"BUFFER_SIZE",
")",
";",
"for... | Write source input stream bytes into destination output stream.
@param sourceInputStream input stream to be handled.
@param destinationOutputStream output stream to be handled.
@return true if write source input stream bytes into destination output
stream success; false otherwise.
@throws IOException | [
"Write",
"source",
"input",
"stream",
"bytes",
"into",
"destination",
"output",
"stream",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/IOUtils.java#L59-L68 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/IOUtils.java | IOUtils.write | public static boolean write(final byte[] sourceBytes, final OutputStream destinationOutputStream)
throws IOException {
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(destinationOutputStream);
bufferedOutputStream.write(sourceBytes, 0, sourceBytes.length);
bufferedOutputStream.flush();
return true;
} | java | public static boolean write(final byte[] sourceBytes, final OutputStream destinationOutputStream)
throws IOException {
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(destinationOutputStream);
bufferedOutputStream.write(sourceBytes, 0, sourceBytes.length);
bufferedOutputStream.flush();
return true;
} | [
"public",
"static",
"boolean",
"write",
"(",
"final",
"byte",
"[",
"]",
"sourceBytes",
",",
"final",
"OutputStream",
"destinationOutputStream",
")",
"throws",
"IOException",
"{",
"BufferedOutputStream",
"bufferedOutputStream",
"=",
"new",
"BufferedOutputStream",
"(",
... | Write source bytes into destination output stream.
@param sourceBytes bytes to be handled.
@param destinationOutputStream destination output stream to be handled.
@return true if write source bytes into destination output stream success.
@throws IOException | [
"Write",
"source",
"bytes",
"into",
"destination",
"output",
"stream",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/IOUtils.java#L78-L85 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/CachedResultSet.java | CachedResultSet.asList | public <T extends DataObject> List<T> asList(Class<T> type) throws InstantiationException, IllegalAccessException {
Map<String, Field> fields = new HashMap<String, Field>();
for (String column: columns) try { fields.put(column, Beans.getKnownField(type, column)); } catch (Exception x) {}
List<T> list = new ArrayList<T>();
for (Object[] row: rows) {
T object = type.newInstance();
for (int i = 0; i < row.length; ++i) {
Field field = fields.get(columns[i]);
if (field != null) {
Beans.setValue(object, field, row[i]);
}
}
list.add(object);
}
return list;
} | java | public <T extends DataObject> List<T> asList(Class<T> type) throws InstantiationException, IllegalAccessException {
Map<String, Field> fields = new HashMap<String, Field>();
for (String column: columns) try { fields.put(column, Beans.getKnownField(type, column)); } catch (Exception x) {}
List<T> list = new ArrayList<T>();
for (Object[] row: rows) {
T object = type.newInstance();
for (int i = 0; i < row.length; ++i) {
Field field = fields.get(columns[i]);
if (field != null) {
Beans.setValue(object, field, row[i]);
}
}
list.add(object);
}
return list;
} | [
"public",
"<",
"T",
"extends",
"DataObject",
">",
"List",
"<",
"T",
">",
"asList",
"(",
"Class",
"<",
"T",
">",
"type",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Map",
"<",
"String",
",",
"Field",
">",
"fields",
"=",
"... | Retrieves the contents of this result set as a List of DataObjects.
@param <T> the type of the objects to be in the list
@param type the class of the objects to be in the list
@return the list of objects
@throws InstantiationException if new instances of the given class can't be created
@throws IllegalAccessException if the fields of the given type can't be read or updated | [
"Retrieves",
"the",
"contents",
"of",
"this",
"result",
"set",
"as",
"a",
"List",
"of",
"DataObjects",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/CachedResultSet.java#L183-L200 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/CachedResultSet.java | CachedResultSet.rename | public CachedResultSet rename(String... names) {
for (int i = 0; i < names.length; ++i) {
this.columns[i] = names[i];
}
return this;
} | java | public CachedResultSet rename(String... names) {
for (int i = 0; i < names.length; ++i) {
this.columns[i] = names[i];
}
return this;
} | [
"public",
"CachedResultSet",
"rename",
"(",
"String",
"...",
"names",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";",
"++",
"i",
")",
"{",
"this",
".",
"columns",
"[",
"i",
"]",
"=",
"names",
"[",
"i",
"]... | Renames the columns of a CachedResultSet.
@param names the new names of the columns, starting from the first column. If not enought new names are provided,
the rest columns keep their original name.
@return this object | [
"Renames",
"the",
"columns",
"of",
"a",
"CachedResultSet",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/CachedResultSet.java#L220-L225 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/CachedResultSet.java | CachedResultSet.buildIndex | public Map<String, Integer> buildIndex() {
Map<String, Integer> index = new HashMap<String, Integer>();
for (int i = 0; i < columns.length; ++i) {
index.put(columns[i], i);
}
return index;
} | java | public Map<String, Integer> buildIndex() {
Map<String, Integer> index = new HashMap<String, Integer>();
for (int i = 0; i < columns.length; ++i) {
index.put(columns[i], i);
}
return index;
} | [
"public",
"Map",
"<",
"String",
",",
"Integer",
">",
"buildIndex",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"index",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",... | Builds a name-to-column index for quick access to data by columm names.
@return a {@code Map} that maps column names to column positions starting from 0 | [
"Builds",
"a",
"name",
"-",
"to",
"-",
"column",
"index",
"for",
"quick",
"access",
"to",
"data",
"by",
"columm",
"names",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/CachedResultSet.java#L232-L238 | train |
incodehq-legacy/incode-module-document | dom/src/main/java/org/incode/module/document/dom/impl/paperclips/PaperclipRepository.java | PaperclipRepository.attach | @Programmatic
public Paperclip attach(
final DocumentAbstract documentAbstract,
final String roleName,
final Object attachTo) {
Paperclip paperclip = findByDocumentAndAttachedToAndRoleName(
documentAbstract, attachTo, roleName);
if(paperclip != null) {
return paperclip;
}
final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo);
paperclip = repositoryService.instantiate(subtype);
paperclip.setDocument(documentAbstract);
paperclip.setRoleName(roleName);
if(documentAbstract instanceof Document) {
final Document document = (Document) documentAbstract;
paperclip.setDocumentCreatedAt(document.getCreatedAt());
}
if(!repositoryService.isPersistent(attachTo)) {
transactionService.flushTransaction();
}
final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo);
paperclip.setAttachedTo(attachTo);
paperclip.setAttachedToStr(bookmark.toString());
repositoryService.persistAndFlush(paperclip);
return paperclip;
} | java | @Programmatic
public Paperclip attach(
final DocumentAbstract documentAbstract,
final String roleName,
final Object attachTo) {
Paperclip paperclip = findByDocumentAndAttachedToAndRoleName(
documentAbstract, attachTo, roleName);
if(paperclip != null) {
return paperclip;
}
final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo);
paperclip = repositoryService.instantiate(subtype);
paperclip.setDocument(documentAbstract);
paperclip.setRoleName(roleName);
if(documentAbstract instanceof Document) {
final Document document = (Document) documentAbstract;
paperclip.setDocumentCreatedAt(document.getCreatedAt());
}
if(!repositoryService.isPersistent(attachTo)) {
transactionService.flushTransaction();
}
final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo);
paperclip.setAttachedTo(attachTo);
paperclip.setAttachedToStr(bookmark.toString());
repositoryService.persistAndFlush(paperclip);
return paperclip;
} | [
"@",
"Programmatic",
"public",
"Paperclip",
"attach",
"(",
"final",
"DocumentAbstract",
"documentAbstract",
",",
"final",
"String",
"roleName",
",",
"final",
"Object",
"attachTo",
")",
"{",
"Paperclip",
"paperclip",
"=",
"findByDocumentAndAttachedToAndRoleName",
"(",
... | This is an idempotent operation. | [
"This",
"is",
"an",
"idempotent",
"operation",
"."
] | c62f064e96d6e6007f7fd6a4bc06e03b78b1816c | https://github.com/incodehq-legacy/incode-module-document/blob/c62f064e96d6e6007f7fd6a4bc06e03b78b1816c/dom/src/main/java/org/incode/module/document/dom/impl/paperclips/PaperclipRepository.java#L165-L198 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java | JavaTokenizer.scanFraction | private void scanFraction(int pos) {
skipIllegalUnderscores();
if ('0' <= reader.ch && reader.ch <= '9') {
scanDigits(pos, 10);
}
int sp1 = reader.sp;
if (reader.ch == 'e' || reader.ch == 'E') {
reader.putChar(true);
skipIllegalUnderscores();
if (reader.ch == '+' || reader.ch == '-') {
reader.putChar(true);
}
skipIllegalUnderscores();
if ('0' <= reader.ch && reader.ch <= '9') {
scanDigits(pos, 10);
return;
}
lexError(pos, "malformed.fp.lit");
reader.sp = sp1;
}
} | java | private void scanFraction(int pos) {
skipIllegalUnderscores();
if ('0' <= reader.ch && reader.ch <= '9') {
scanDigits(pos, 10);
}
int sp1 = reader.sp;
if (reader.ch == 'e' || reader.ch == 'E') {
reader.putChar(true);
skipIllegalUnderscores();
if (reader.ch == '+' || reader.ch == '-') {
reader.putChar(true);
}
skipIllegalUnderscores();
if ('0' <= reader.ch && reader.ch <= '9') {
scanDigits(pos, 10);
return;
}
lexError(pos, "malformed.fp.lit");
reader.sp = sp1;
}
} | [
"private",
"void",
"scanFraction",
"(",
"int",
"pos",
")",
"{",
"skipIllegalUnderscores",
"(",
")",
";",
"if",
"(",
"'",
"'",
"<=",
"reader",
".",
"ch",
"&&",
"reader",
".",
"ch",
"<=",
"'",
"'",
")",
"{",
"scanDigits",
"(",
"pos",
",",
"10",
")",
... | Read fractional part of floating point number. | [
"Read",
"fractional",
"part",
"of",
"floating",
"point",
"number",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java#L274-L294 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java | JavaTokenizer.isMagicComment | private boolean isMagicComment() {
assert reader.ch == '@';
int parens = 0;
boolean stringLit = false;
int lbp = reader.bp;
char lch = reader.buf[++lbp];
if (!Character.isJavaIdentifierStart(lch)) {
// The first thing after the @ has to be the annotation identifier
return false;
}
while (lbp < reader.buflen) {
lch = reader.buf[++lbp];
// We are outside any annotation values
if (Character.isWhitespace(lch) &&
!spacesincomments &&
parens == 0) {
return false;
} else if (lch == '@' &&
parens == 0) {
// At most one annotation per magic comment
return false;
} else if (lch == '(' && !stringLit) {
++parens;
} else if (lch == ')' && !stringLit) {
--parens;
} else if (lch == '"') {
// TODO: handle more complicated string literals,
// char literals, escape sequences, unicode, etc.
stringLit = !stringLit;
} else if (lch == '*' &&
!stringLit &&
lbp + 1 < reader.buflen &&
reader.buf[lbp+1] == '/') {
// We reached the end of the comment, make sure no
// parens are open
return parens == 0;
} else if (!Character.isJavaIdentifierPart(lch) &&
!Character.isWhitespace(lch) &&
lch != '.' && // separator in fully-qualified annotation name
// TODO: this also allows /*@A...*/ which should not be recognized.
!spacesincomments &&
parens == 0 &&
!stringLit) {
return false;
}
// Do we need anything else for annotation values, e.g. String literals?
}
// came to end of file before '*/'
return false;
} | java | private boolean isMagicComment() {
assert reader.ch == '@';
int parens = 0;
boolean stringLit = false;
int lbp = reader.bp;
char lch = reader.buf[++lbp];
if (!Character.isJavaIdentifierStart(lch)) {
// The first thing after the @ has to be the annotation identifier
return false;
}
while (lbp < reader.buflen) {
lch = reader.buf[++lbp];
// We are outside any annotation values
if (Character.isWhitespace(lch) &&
!spacesincomments &&
parens == 0) {
return false;
} else if (lch == '@' &&
parens == 0) {
// At most one annotation per magic comment
return false;
} else if (lch == '(' && !stringLit) {
++parens;
} else if (lch == ')' && !stringLit) {
--parens;
} else if (lch == '"') {
// TODO: handle more complicated string literals,
// char literals, escape sequences, unicode, etc.
stringLit = !stringLit;
} else if (lch == '*' &&
!stringLit &&
lbp + 1 < reader.buflen &&
reader.buf[lbp+1] == '/') {
// We reached the end of the comment, make sure no
// parens are open
return parens == 0;
} else if (!Character.isJavaIdentifierPart(lch) &&
!Character.isWhitespace(lch) &&
lch != '.' && // separator in fully-qualified annotation name
// TODO: this also allows /*@A...*/ which should not be recognized.
!spacesincomments &&
parens == 0 &&
!stringLit) {
return false;
}
// Do we need anything else for annotation values, e.g. String literals?
}
// came to end of file before '*/'
return false;
} | [
"private",
"boolean",
"isMagicComment",
"(",
")",
"{",
"assert",
"reader",
".",
"ch",
"==",
"'",
"'",
";",
"int",
"parens",
"=",
"0",
";",
"boolean",
"stringLit",
"=",
"false",
";",
"int",
"lbp",
"=",
"reader",
".",
"bp",
";",
"char",
"lch",
"=",
"... | with annotation values. | [
"with",
"annotation",
"values",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java#L803-L854 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java | JavaTokenizer.processComment | protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
if (scannerDebug)
System.out.println("processComment(" + pos
+ "," + endPos + "," + style + ")=|"
+ new String(reader.getRawCharacters(pos, endPos))
+ "|");
char[] buf = reader.getRawCharacters(pos, endPos);
return new BasicComment<UnicodeReader>(new UnicodeReader(fac, buf, buf.length), style);
} | java | protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
if (scannerDebug)
System.out.println("processComment(" + pos
+ "," + endPos + "," + style + ")=|"
+ new String(reader.getRawCharacters(pos, endPos))
+ "|");
char[] buf = reader.getRawCharacters(pos, endPos);
return new BasicComment<UnicodeReader>(new UnicodeReader(fac, buf, buf.length), style);
} | [
"protected",
"Tokens",
".",
"Comment",
"processComment",
"(",
"int",
"pos",
",",
"int",
"endPos",
",",
"CommentStyle",
"style",
")",
"{",
"if",
"(",
"scannerDebug",
")",
"System",
".",
"out",
".",
"println",
"(",
"\"processComment(\"",
"+",
"pos",
"+",
"\"... | Called when a complete comment has been scanned. pos and endPos
will mark the comment boundary. | [
"Called",
"when",
"a",
"complete",
"comment",
"has",
"been",
"scanned",
".",
"pos",
"and",
"endPos",
"will",
"mark",
"the",
"comment",
"boundary",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java#L872-L880 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java | VATManager.isZeroVATAllowed | public boolean isZeroVATAllowed (@Nonnull final Locale aCountry, final boolean bUndefinedValue)
{
ValueEnforcer.notNull (aCountry, "Country");
// first get locale specific VAT types
final VATCountryData aVATCountryData = getVATCountryData (aCountry);
return aVATCountryData != null ? aVATCountryData.isZeroVATAllowed () : bUndefinedValue;
} | java | public boolean isZeroVATAllowed (@Nonnull final Locale aCountry, final boolean bUndefinedValue)
{
ValueEnforcer.notNull (aCountry, "Country");
// first get locale specific VAT types
final VATCountryData aVATCountryData = getVATCountryData (aCountry);
return aVATCountryData != null ? aVATCountryData.isZeroVATAllowed () : bUndefinedValue;
} | [
"public",
"boolean",
"isZeroVATAllowed",
"(",
"@",
"Nonnull",
"final",
"Locale",
"aCountry",
",",
"final",
"boolean",
"bUndefinedValue",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aCountry",
",",
"\"Country\"",
")",
";",
"// first get locale specific VAT types",... | Check if zero VAT is allowed for the passed country
@param aCountry
The country to be checked.
@param bUndefinedValue
The value to be returned, if no VAT data is available for the passed
country
@return <code>true</code> or <code>false</code> | [
"Check",
"if",
"zero",
"VAT",
"is",
"allowed",
"for",
"the",
"passed",
"country"
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java#L258-L265 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java | VATManager.getVATCountryData | @Nullable
public VATCountryData getVATCountryData (@Nonnull final Locale aLocale)
{
ValueEnforcer.notNull (aLocale, "Locale");
final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
return m_aVATItemsPerCountry.get (aCountry);
} | java | @Nullable
public VATCountryData getVATCountryData (@Nonnull final Locale aLocale)
{
ValueEnforcer.notNull (aLocale, "Locale");
final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
return m_aVATItemsPerCountry.get (aCountry);
} | [
"@",
"Nullable",
"public",
"VATCountryData",
"getVATCountryData",
"(",
"@",
"Nonnull",
"final",
"Locale",
"aLocale",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aLocale",
",",
"\"Locale\"",
")",
";",
"final",
"Locale",
"aCountry",
"=",
"CountryCache",
".",
... | Get the VAT data of the passed country.
@param aLocale
The locale to use. May not be <code>null</code>.
@return <code>null</code> if no such country data is present. | [
"Get",
"the",
"VAT",
"data",
"of",
"the",
"passed",
"country",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java#L274-L280 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java | VATManager.findVATItem | @Nullable
public IVATItem findVATItem (@Nullable final EVATItemType eType, @Nullable final BigDecimal aPercentage)
{
if (eType == null || aPercentage == null)
return null;
return findFirst (x -> x.getType ().equals (eType) && x.hasPercentage (aPercentage));
} | java | @Nullable
public IVATItem findVATItem (@Nullable final EVATItemType eType, @Nullable final BigDecimal aPercentage)
{
if (eType == null || aPercentage == null)
return null;
return findFirst (x -> x.getType ().equals (eType) && x.hasPercentage (aPercentage));
} | [
"@",
"Nullable",
"public",
"IVATItem",
"findVATItem",
"(",
"@",
"Nullable",
"final",
"EVATItemType",
"eType",
",",
"@",
"Nullable",
"final",
"BigDecimal",
"aPercentage",
")",
"{",
"if",
"(",
"eType",
"==",
"null",
"||",
"aPercentage",
"==",
"null",
")",
"ret... | Find a matching VAT item with the passed properties, independent of the
country.
@param eType
The VAT type to use. May be <code>null</code> resulting in a
<code>null</code> result.
@param aPercentage
The percentage to find. May be <code>null</code> resulting in a
<code>null</code> result.
@return <code>null</code> if no matching item could be found, | [
"Find",
"a",
"matching",
"VAT",
"item",
"with",
"the",
"passed",
"properties",
"independent",
"of",
"the",
"country",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java#L352-L358 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java | VATManager.findFirst | @Nullable
public IVATItem findFirst (@Nonnull final Predicate <? super IVATItem> aFilter)
{
return CollectionHelper.findFirst (m_aAllVATItems.values (), aFilter);
} | java | @Nullable
public IVATItem findFirst (@Nonnull final Predicate <? super IVATItem> aFilter)
{
return CollectionHelper.findFirst (m_aAllVATItems.values (), aFilter);
} | [
"@",
"Nullable",
"public",
"IVATItem",
"findFirst",
"(",
"@",
"Nonnull",
"final",
"Predicate",
"<",
"?",
"super",
"IVATItem",
">",
"aFilter",
")",
"{",
"return",
"CollectionHelper",
".",
"findFirst",
"(",
"m_aAllVATItems",
".",
"values",
"(",
")",
",",
"aFil... | Find the first matching VAT item.
@param aFilter
The filter to be used. May not be <code>null</code>.
@return <code>null</code> if no matching item could be found, | [
"Find",
"the",
"first",
"matching",
"VAT",
"item",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java#L367-L371 | train |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java | VATManager.findAll | @Nonnull
@ReturnsMutableCopy
public ICommonsList <IVATItem> findAll (@Nonnull final Predicate <? super IVATItem> aFilter)
{
final ICommonsList <IVATItem> ret = new CommonsArrayList <> ();
CollectionHelper.findAll (m_aAllVATItems.values (), aFilter, ret::add);
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public ICommonsList <IVATItem> findAll (@Nonnull final Predicate <? super IVATItem> aFilter)
{
final ICommonsList <IVATItem> ret = new CommonsArrayList <> ();
CollectionHelper.findAll (m_aAllVATItems.values (), aFilter, ret::add);
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"ICommonsList",
"<",
"IVATItem",
">",
"findAll",
"(",
"@",
"Nonnull",
"final",
"Predicate",
"<",
"?",
"super",
"IVATItem",
">",
"aFilter",
")",
"{",
"final",
"ICommonsList",
"<",
"IVATItem",
">",
"ret",
"=... | Find all matching VAT items.
@param aFilter
The filter to be used. May not be <code>null</code>.
@return A non-<code>null</code> but maybe empty list with all matching
{@link IVATItem} objects.
@since 5.0.5 | [
"Find",
"all",
"matching",
"VAT",
"items",
"."
] | ca5e0b03c735b30b47930c018bfb5e71f00d0ff4 | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATManager.java#L382-L389 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.serialize | static private String serialize(Throwable ex, int depth, int level)
{
StringBuffer buff = new StringBuffer();
String str = ex.toString();
// Split the first line if it's too long
int pos = str.indexOf(":");
if(str.length() < 80 || pos == -1)
{
buff.append(str);
}
else
{
String str1 = str.substring(0, pos);
String str2 = str.substring(pos+2);
if(str2.indexOf(str1) == -1)
{
buff.append(str1);
buff.append(": \n\t");
}
buff.append(str2);
}
if(depth > 0)
{
StackTraceElement[] elements = ex.getStackTrace();
for(int i = 0; i < elements.length; i++)
{
buff.append("\n\tat ");
buff.append(elements[i]);
if(i == (depth-1) && elements.length > depth)
{
buff.append("\n\t... "+(elements.length-depth)+" more ...");
i = elements.length;
}
}
}
if(ex.getCause() != null && level < 3)
{
buff.append("\nCaused by: ");
buff.append(serialize(ex.getCause(), depth, ++level));
}
return buff.toString();
} | java | static private String serialize(Throwable ex, int depth, int level)
{
StringBuffer buff = new StringBuffer();
String str = ex.toString();
// Split the first line if it's too long
int pos = str.indexOf(":");
if(str.length() < 80 || pos == -1)
{
buff.append(str);
}
else
{
String str1 = str.substring(0, pos);
String str2 = str.substring(pos+2);
if(str2.indexOf(str1) == -1)
{
buff.append(str1);
buff.append(": \n\t");
}
buff.append(str2);
}
if(depth > 0)
{
StackTraceElement[] elements = ex.getStackTrace();
for(int i = 0; i < elements.length; i++)
{
buff.append("\n\tat ");
buff.append(elements[i]);
if(i == (depth-1) && elements.length > depth)
{
buff.append("\n\t... "+(elements.length-depth)+" more ...");
i = elements.length;
}
}
}
if(ex.getCause() != null && level < 3)
{
buff.append("\nCaused by: ");
buff.append(serialize(ex.getCause(), depth, ++level));
}
return buff.toString();
} | [
"static",
"private",
"String",
"serialize",
"(",
"Throwable",
"ex",
",",
"int",
"depth",
",",
"int",
"level",
")",
"{",
"StringBuffer",
"buff",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"str",
"=",
"ex",
".",
"toString",
"(",
")",
";",
"// S... | Serializes the given exception as a stack trace string.
@param ex The exception to be serialized
@param depth The maximum depth of the stack trace returned
@param level The current level of nesting of the exception
@return The serialized exception | [
"Serializes",
"the",
"given",
"exception",
"as",
"a",
"stack",
"trace",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L83-L128 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.serialize | public static String serialize(Object[] objs)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < objs.length; i++)
{
if(objs[i] != null)
{
buff.append(objs[i].toString());
if(i != objs.length-1)
buff.append(",");
}
}
return buff.toString();
} | java | public static String serialize(Object[] objs)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < objs.length; i++)
{
if(objs[i] != null)
{
buff.append(objs[i].toString());
if(i != objs.length-1)
buff.append(",");
}
}
return buff.toString();
} | [
"public",
"static",
"String",
"serialize",
"(",
"Object",
"[",
"]",
"objs",
")",
"{",
"StringBuffer",
"buff",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"objs",
".",
"length",
";",
"i",
"++",
")",
... | Returns the given array serialized as a string.
@param objs The array to be serialized
@return The given array serialized as a string | [
"Returns",
"the",
"given",
"array",
"serialized",
"as",
"a",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L147-L160 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.encode | public static String encode(String str)
{
String ret = str;
try
{
// Obfuscate the string
if(ret != null)
ret = new String(Base64.encodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.println("WARNING: unable to encode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | java | public static String encode(String str)
{
String ret = str;
try
{
// Obfuscate the string
if(ret != null)
ret = new String(Base64.encodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.println("WARNING: unable to encode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | [
"public",
"static",
"String",
"encode",
"(",
"String",
"str",
")",
"{",
"String",
"ret",
"=",
"str",
";",
"try",
"{",
"// Obfuscate the string",
"if",
"(",
"ret",
"!=",
"null",
")",
"ret",
"=",
"new",
"String",
"(",
"Base64",
".",
"encodeBase64",
"(",
... | Returns the given string after if it has been encoded.
@param str The string to be encoded
@return The encoded string | [
"Returns",
"the",
"given",
"string",
"after",
"if",
"it",
"has",
"been",
"encoded",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L167-L184 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.encodeBytes | public static String encodeBytes(byte[] bytes)
{
String ret = null;
try
{
// Obfuscate the string
if(bytes != null)
ret = new String(Base64.encodeBase64(bytes));
}
catch(NoClassDefFoundError e)
{
ret = new String(bytes);
System.out.println("WARNING: unable to encode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | java | public static String encodeBytes(byte[] bytes)
{
String ret = null;
try
{
// Obfuscate the string
if(bytes != null)
ret = new String(Base64.encodeBase64(bytes));
}
catch(NoClassDefFoundError e)
{
ret = new String(bytes);
System.out.println("WARNING: unable to encode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | [
"public",
"static",
"String",
"encodeBytes",
"(",
"byte",
"[",
"]",
"bytes",
")",
"{",
"String",
"ret",
"=",
"null",
";",
"try",
"{",
"// Obfuscate the string",
"if",
"(",
"bytes",
"!=",
"null",
")",
"ret",
"=",
"new",
"String",
"(",
"Base64",
".",
"en... | Returns the given byte array after if it has been encoded.
@param bytes The byte array to be encoded
@return The encoded string | [
"Returns",
"the",
"given",
"byte",
"array",
"after",
"if",
"it",
"has",
"been",
"encoded",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L191-L209 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.decode | public static String decode(String str)
{
String ret = str;
try
{
// De-obfuscate the string
if(ret != null)
ret = new String(Base64.decodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.println("WARNING: unable to decode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | java | public static String decode(String str)
{
String ret = str;
try
{
// De-obfuscate the string
if(ret != null)
ret = new String(Base64.decodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.println("WARNING: unable to decode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | [
"public",
"static",
"String",
"decode",
"(",
"String",
"str",
")",
"{",
"String",
"ret",
"=",
"str",
";",
"try",
"{",
"// De-obfuscate the string",
"if",
"(",
"ret",
"!=",
"null",
")",
"ret",
"=",
"new",
"String",
"(",
"Base64",
".",
"decodeBase64",
"(",... | Returns the given string after if it has been decoded.
@param str The string to be decoded
@return The decoded string | [
"Returns",
"the",
"given",
"string",
"after",
"if",
"it",
"has",
"been",
"decoded",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L216-L233 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.decodeBytes | public static byte[] decodeBytes(String str)
{
byte[] ret = null;
try
{
// De-obfuscate the string
if(str != null)
ret = Base64.decodeBase64(str.getBytes());
}
catch(NoClassDefFoundError e)
{
ret = str.getBytes();
System.out.println("WARNING: unable to decode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | java | public static byte[] decodeBytes(String str)
{
byte[] ret = null;
try
{
// De-obfuscate the string
if(str != null)
ret = Base64.decodeBase64(str.getBytes());
}
catch(NoClassDefFoundError e)
{
ret = str.getBytes();
System.out.println("WARNING: unable to decode: "
+e.getClass().getName()+": "+e.getMessage());
}
return ret;
} | [
"public",
"static",
"byte",
"[",
"]",
"decodeBytes",
"(",
"String",
"str",
")",
"{",
"byte",
"[",
"]",
"ret",
"=",
"null",
";",
"try",
"{",
"// De-obfuscate the string",
"if",
"(",
"str",
"!=",
"null",
")",
"ret",
"=",
"Base64",
".",
"decodeBase64",
"(... | Returns the given byte array after if it has been decoded.
@param str The string to be decoded
@return The decoded bytes | [
"Returns",
"the",
"given",
"byte",
"array",
"after",
"if",
"it",
"has",
"been",
"decoded",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L240-L258 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.truncate | public static String truncate(String str, int count)
{
if(count < 0 || str.length() <= count)
return str;
int pos = count;
for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
return str.substring(0, pos)+"...";
} | java | public static String truncate(String str, int count)
{
if(count < 0 || str.length() <= count)
return str;
int pos = count;
for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
return str.substring(0, pos)+"...";
} | [
"public",
"static",
"String",
"truncate",
"(",
"String",
"str",
",",
"int",
"count",
")",
"{",
"if",
"(",
"count",
"<",
"0",
"||",
"str",
".",
"length",
"(",
")",
"<=",
"count",
")",
"return",
"str",
";",
"int",
"pos",
"=",
"count",
";",
"for",
"... | Returns the given string truncated at a word break before the given number of characters.
@param str The string to be truncated
@param count The maximum length of the truncated string
@return The truncated string | [
"Returns",
"the",
"given",
"string",
"truncated",
"at",
"a",
"word",
"break",
"before",
"the",
"given",
"number",
"of",
"characters",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L266-L274 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.getOccurenceCount | public static int getOccurenceCount(char c, String s)
{
int ret = 0;
for(int i = 0; i < s.length(); i++)
{
if(s.charAt(i) == c)
++ret;
}
return ret;
} | java | public static int getOccurenceCount(char c, String s)
{
int ret = 0;
for(int i = 0; i < s.length(); i++)
{
if(s.charAt(i) == c)
++ret;
}
return ret;
} | [
"public",
"static",
"int",
"getOccurenceCount",
"(",
"char",
"c",
",",
"String",
"s",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
... | Returns the number of occurences of the given character in the given string.
@param c The character to look for occurrences of
@param s The string to search
@return The number of occurences | [
"Returns",
"the",
"number",
"of",
"occurences",
"of",
"the",
"given",
"character",
"in",
"the",
"given",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L282-L293 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.getOccurrenceCount | public static int getOccurrenceCount(String expr, String str)
{
int ret = 0;
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(str);
while(m.find())
++ret;
return ret;
} | java | public static int getOccurrenceCount(String expr, String str)
{
int ret = 0;
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(str);
while(m.find())
++ret;
return ret;
} | [
"public",
"static",
"int",
"getOccurrenceCount",
"(",
"String",
"expr",
",",
"String",
"str",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"expr",
")",
";",
"Matcher",
"m",
"=",
"p",
".",
"matcher",
"(",... | Returns the number of occurrences of the substring in the given string.
@param expr The string to look for occurrences of
@param str The string to search
@return The number of occurences | [
"Returns",
"the",
"number",
"of",
"occurrences",
"of",
"the",
"substring",
"in",
"the",
"given",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L301-L309 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.endsWith | public static boolean endsWith(StringBuffer buffer, String suffix)
{
if (suffix.length() > buffer.length())
return false;
int endIndex = suffix.length() - 1;
int bufferIndex = buffer.length() - 1;
while (endIndex >= 0)
{
if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex))
return false;
bufferIndex--;
endIndex--;
}
return true;
} | java | public static boolean endsWith(StringBuffer buffer, String suffix)
{
if (suffix.length() > buffer.length())
return false;
int endIndex = suffix.length() - 1;
int bufferIndex = buffer.length() - 1;
while (endIndex >= 0)
{
if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex))
return false;
bufferIndex--;
endIndex--;
}
return true;
} | [
"public",
"static",
"boolean",
"endsWith",
"(",
"StringBuffer",
"buffer",
",",
"String",
"suffix",
")",
"{",
"if",
"(",
"suffix",
".",
"length",
"(",
")",
">",
"buffer",
".",
"length",
"(",
")",
")",
"return",
"false",
";",
"int",
"endIndex",
"=",
"suf... | Checks that a string buffer ends up with a given string.
@param buffer The buffer to perform the check on
@param suffix The suffix
@return <code>true</code> if the character sequence represented by the
argument is a suffix of the character sequence represented by
the StringBuffer object; <code>false</code> otherwise. Note that the
result will be <code>true</code> if the argument is the empty string. | [
"Checks",
"that",
"a",
"string",
"buffer",
"ends",
"up",
"with",
"a",
"given",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L371-L385 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.toReadableForm | public static String toReadableForm(String str)
{
String ret = str;
if(str != null && str.length() > 0
&& str.indexOf("\n") != -1
&& str.indexOf("\r") == -1)
{
str.replaceAll("\n", "\r\n");
}
return ret;
} | java | public static String toReadableForm(String str)
{
String ret = str;
if(str != null && str.length() > 0
&& str.indexOf("\n") != -1
&& str.indexOf("\r") == -1)
{
str.replaceAll("\n", "\r\n");
}
return ret;
} | [
"public",
"static",
"String",
"toReadableForm",
"(",
"String",
"str",
")",
"{",
"String",
"ret",
"=",
"str",
";",
"if",
"(",
"str",
"!=",
"null",
"&&",
"str",
".",
"length",
"(",
")",
">",
"0",
"&&",
"str",
".",
"indexOf",
"(",
"\"\\n\"",
")",
"!="... | Converts the given string with CR and LF character correctly formatted.
@param str The string to be converted
@return The converted string | [
"Converts",
"the",
"given",
"string",
"with",
"CR",
"and",
"LF",
"character",
"correctly",
"formatted",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L392-L403 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.urlEncode | public static String urlEncode(String str)
{
String ret = str;
try
{
ret = URLEncoder.encode(str, "UTF-8");
}
catch (UnsupportedEncodingException e)
{
logger.severe("Failed to encode value: "+str);
}
return ret;
} | java | public static String urlEncode(String str)
{
String ret = str;
try
{
ret = URLEncoder.encode(str, "UTF-8");
}
catch (UnsupportedEncodingException e)
{
logger.severe("Failed to encode value: "+str);
}
return ret;
} | [
"public",
"static",
"String",
"urlEncode",
"(",
"String",
"str",
")",
"{",
"String",
"ret",
"=",
"str",
";",
"try",
"{",
"ret",
"=",
"URLEncoder",
".",
"encode",
"(",
"str",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"... | Encode the special characters in the string to its URL encoded representation.
@param str The string to encode
@return The encoded string | [
"Encode",
"the",
"special",
"characters",
"in",
"the",
"string",
"to",
"its",
"URL",
"encoded",
"representation",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L466-L480 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.stripSpaces | public static String stripSpaces(String s)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
if(c != ' ')
buff.append(c);
}
return buff.toString();
} | java | public static String stripSpaces(String s)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
if(c != ' ')
buff.append(c);
}
return buff.toString();
} | [
"public",
"static",
"String",
"stripSpaces",
"(",
"String",
"s",
")",
"{",
"StringBuffer",
"buff",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",... | Returns the given string with all spaces removed.
@param s The string to have spaces removed
@return The given string with all spaces removed | [
"Returns",
"the",
"given",
"string",
"with",
"all",
"spaces",
"removed",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L487-L497 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.removeControlCharacters | public static String removeControlCharacters(String s, boolean removeCR)
{
String ret = s;
if(ret != null)
{
ret = ret.replaceAll("_x000D_","");
if(removeCR)
ret = ret.replaceAll("\r","");
}
return ret;
} | java | public static String removeControlCharacters(String s, boolean removeCR)
{
String ret = s;
if(ret != null)
{
ret = ret.replaceAll("_x000D_","");
if(removeCR)
ret = ret.replaceAll("\r","");
}
return ret;
} | [
"public",
"static",
"String",
"removeControlCharacters",
"(",
"String",
"s",
",",
"boolean",
"removeCR",
")",
"{",
"String",
"ret",
"=",
"s",
";",
"if",
"(",
"ret",
"!=",
"null",
")",
"{",
"ret",
"=",
"ret",
".",
"replaceAll",
"(",
"\"_x000D_\"",
",",
... | Remove any extraneous control characters from text fields.
@param s The string to have control characters removed
@param removeCR <CODE>true</CODE> if carriage returns should be removed
@return The given string with all control characters removed | [
"Remove",
"any",
"extraneous",
"control",
"characters",
"from",
"text",
"fields",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L538-L548 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.printCharacters | public static void printCharacters(String s)
{
if(s != null)
{
logger.info("string length="+s.length());
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
logger.info("char["+i+"]="+c+" ("+(int)c+")");
}
}
} | java | public static void printCharacters(String s)
{
if(s != null)
{
logger.info("string length="+s.length());
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
logger.info("char["+i+"]="+c+" ("+(int)c+")");
}
}
} | [
"public",
"static",
"void",
"printCharacters",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"logger",
".",
"info",
"(",
"\"string length=\"",
"+",
"s",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
... | Prints the character codes for the given string.
@param s The string to be printed | [
"Prints",
"the",
"character",
"codes",
"for",
"the",
"given",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L564-L575 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.stripDoubleQuotes | public static String stripDoubleQuotes(String s)
{
String ret = s;
if(hasDoubleQuotes(s))
ret = s.substring(1, s.length()-1);
return ret;
} | java | public static String stripDoubleQuotes(String s)
{
String ret = s;
if(hasDoubleQuotes(s))
ret = s.substring(1, s.length()-1);
return ret;
} | [
"public",
"static",
"String",
"stripDoubleQuotes",
"(",
"String",
"s",
")",
"{",
"String",
"ret",
"=",
"s",
";",
"if",
"(",
"hasDoubleQuotes",
"(",
"s",
")",
")",
"ret",
"=",
"s",
".",
"substring",
"(",
"1",
",",
"s",
".",
"length",
"(",
")",
"-",
... | Returns the given string with leading and trailing quotes removed.
@param s The string to have leading and trailing quotes removed
@return The given string with leading and trailing quotes removed | [
"Returns",
"the",
"given",
"string",
"with",
"leading",
"and",
"trailing",
"quotes",
"removed",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L592-L598 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.stripClassNames | public static String stripClassNames(String str)
{
String ret = str;
if(ret != null)
{
while(ret.startsWith("java.security.PrivilegedActionException:")
|| ret.startsWith("com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:")
|| ret.startsWith("javax.jms.JMSSecurityException:"))
{
ret = ret.substring(ret.indexOf(":")+1).trim();
}
}
return ret;
} | java | public static String stripClassNames(String str)
{
String ret = str;
if(ret != null)
{
while(ret.startsWith("java.security.PrivilegedActionException:")
|| ret.startsWith("com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:")
|| ret.startsWith("javax.jms.JMSSecurityException:"))
{
ret = ret.substring(ret.indexOf(":")+1).trim();
}
}
return ret;
} | [
"public",
"static",
"String",
"stripClassNames",
"(",
"String",
"str",
")",
"{",
"String",
"ret",
"=",
"str",
";",
"if",
"(",
"ret",
"!=",
"null",
")",
"{",
"while",
"(",
"ret",
".",
"startsWith",
"(",
"\"java.security.PrivilegedActionException:\"",
")",
"||... | Strips class name prefixes from the start of the given string.
@param str The string to be converted
@return The string with class name prefixes removed | [
"Strips",
"class",
"name",
"prefixes",
"from",
"the",
"start",
"of",
"the",
"given",
"string",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L633-L646 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.stripDomain | public static String stripDomain(String hostname)
{
String ret = hostname;
int pos = hostname.indexOf(".");
if(pos != -1)
ret = hostname.substring(0,pos);
return ret;
} | java | public static String stripDomain(String hostname)
{
String ret = hostname;
int pos = hostname.indexOf(".");
if(pos != -1)
ret = hostname.substring(0,pos);
return ret;
} | [
"public",
"static",
"String",
"stripDomain",
"(",
"String",
"hostname",
")",
"{",
"String",
"ret",
"=",
"hostname",
";",
"int",
"pos",
"=",
"hostname",
".",
"indexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"pos",
"!=",
"-",
"1",
")",
"ret",
"=",
"hostna... | Returns the given hostname with the domain removed.
@param hostname The hostname to be converted
@return The hostname with the domain removed | [
"Returns",
"the",
"given",
"hostname",
"with",
"the",
"domain",
"removed",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L653-L660 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.findClass | public Class<?> findClass(String className, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
Class<?> c = this.getClassFromBundle(null, className, versionRange);
if (c == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(className, false), versionRange, false);
if (resource != null)
{
c = this.getClassFromBundle(null, className, versionRange); // It is possible that the newly started bundle registered itself
if (c == null)
c = this.getClassFromBundle(resource, className, versionRange);
}
}
return c;
} | java | public Class<?> findClass(String className, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
Class<?> c = this.getClassFromBundle(null, className, versionRange);
if (c == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(className, false), versionRange, false);
if (resource != null)
{
c = this.getClassFromBundle(null, className, versionRange); // It is possible that the newly started bundle registered itself
if (c == null)
c = this.getClassFromBundle(resource, className, versionRange);
}
}
return c;
} | [
"public",
"Class",
"<",
"?",
">",
"findClass",
"(",
"String",
"className",
",",
"String",
"versionRange",
")",
"{",
"//if (ClassServiceBootstrap.repositoryAdmin == null)",
"// return null;",
"Class",
"<",
"?",
">",
"c",
"=",
"this",
".",
"getClassFromBundle",
"("... | Find, resolve, and return this class definition.
@param className
@return The class definition or null if not found. | [
"Find",
"resolve",
"and",
"return",
"this",
"class",
"definition",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L90-L108 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.findResourceURL | public URL findResourceURL(String resourcePath, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
URL url = this.getResourceFromBundle(null, resourcePath, versionRange);
if (url == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(resourcePath, true), versionRange, false);
if (resource != null)
url = this.getResourceFromBundle(resource, resourcePath, versionRange);
}
return url;
} | java | public URL findResourceURL(String resourcePath, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
URL url = this.getResourceFromBundle(null, resourcePath, versionRange);
if (url == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(resourcePath, true), versionRange, false);
if (resource != null)
url = this.getResourceFromBundle(resource, resourcePath, versionRange);
}
return url;
} | [
"public",
"URL",
"findResourceURL",
"(",
"String",
"resourcePath",
",",
"String",
"versionRange",
")",
"{",
"//if (ClassServiceBootstrap.repositoryAdmin == null)",
"// return null;",
"URL",
"url",
"=",
"this",
".",
"getResourceFromBundle",
"(",
"null",
",",
"resourcePa... | Find, resolve, and return this resource's URL.
@param resourcePath
@return The class definition or null if not found. | [
"Find",
"resolve",
"and",
"return",
"this",
"resource",
"s",
"URL",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L114-L128 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.findResourceBundle | public ResourceBundle findResourceBundle(String resourcePath, Locale locale, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
ResourceBundle resourceBundle = this.getResourceBundleFromBundle(null, resourcePath, locale, versionRange);
if (resourceBundle == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(resourcePath, true), versionRange, false);
if (resource != null)
{
resourceBundle = this.getResourceBundleFromBundle(resource, resourcePath, locale, versionRange);
if (resourceBundle == null)
{
Class<?> c = this.getClassFromBundle(resource, resourcePath, versionRange);
if (c != null)
{
try {
resourceBundle = (ResourceBundle)c.newInstance();
} catch (InstantiationException e) {
e.printStackTrace(); // Never
} catch (IllegalAccessException e) {
e.printStackTrace(); // Never
} catch (Exception e) {
e.printStackTrace(); // Never
}
}
}
}
}
return resourceBundle;
} | java | public ResourceBundle findResourceBundle(String resourcePath, Locale locale, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
ResourceBundle resourceBundle = this.getResourceBundleFromBundle(null, resourcePath, locale, versionRange);
if (resourceBundle == null) {
Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(resourcePath, true), versionRange, false);
if (resource != null)
{
resourceBundle = this.getResourceBundleFromBundle(resource, resourcePath, locale, versionRange);
if (resourceBundle == null)
{
Class<?> c = this.getClassFromBundle(resource, resourcePath, versionRange);
if (c != null)
{
try {
resourceBundle = (ResourceBundle)c.newInstance();
} catch (InstantiationException e) {
e.printStackTrace(); // Never
} catch (IllegalAccessException e) {
e.printStackTrace(); // Never
} catch (Exception e) {
e.printStackTrace(); // Never
}
}
}
}
}
return resourceBundle;
} | [
"public",
"ResourceBundle",
"findResourceBundle",
"(",
"String",
"resourcePath",
",",
"Locale",
"locale",
",",
"String",
"versionRange",
")",
"{",
"//if (ClassServiceBootstrap.repositoryAdmin == null)",
"// return null;",
"ResourceBundle",
"resourceBundle",
"=",
"this",
".... | Find, resolve, and return this ResourceBundle.
@param resourcePath
@return The class definition or null if not found.
TODO: Need to figure out how to get the bundle's class loader, so I can set up the resource chain | [
"Find",
"resolve",
"and",
"return",
"this",
"ResourceBundle",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L135-L167 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.shutdownService | public boolean shutdownService(String serviceClass, Object service)
{
if (service == null)
return false;
if (bundleContext == null)
return false;
String filter = null;
if (serviceClass == null)
if (!(service instanceof String))
serviceClass = service.getClass().getName();
if (service instanceof String)
filter = ClassServiceUtility.addToFilter("", BundleConstants.SERVICE_PID, (String)service);
ServiceReference[] refs;
try {
refs = bundleContext.getServiceReferences(serviceClass, filter);
if ((refs == null) || (refs.length == 0))
return false;
for (ServiceReference reference : refs)
{
if ((bundleContext.getService(reference) == service) || (service instanceof String))
{
if (refs.length == 1)
{ // Last/only one, shut down the service
// Lame code
String dependentBaseBundleClassName = service.getClass().getName();
String packageName = ClassFinderActivator.getPackageName(dependentBaseBundleClassName, false);
if (service instanceof String)
packageName = (String)service;
Bundle bundle = this.findBundle(null, bundleContext, packageName, null);
if (bundle != null)
if ((bundle.getState() & Bundle.ACTIVE) != 0)
{
try {
bundle.stop();
} catch (BundleException e) {
e.printStackTrace();
}
}
return true;
}
}
}
} catch (InvalidSyntaxException e1) {
e1.printStackTrace();
}
return false; // Not found?
} | java | public boolean shutdownService(String serviceClass, Object service)
{
if (service == null)
return false;
if (bundleContext == null)
return false;
String filter = null;
if (serviceClass == null)
if (!(service instanceof String))
serviceClass = service.getClass().getName();
if (service instanceof String)
filter = ClassServiceUtility.addToFilter("", BundleConstants.SERVICE_PID, (String)service);
ServiceReference[] refs;
try {
refs = bundleContext.getServiceReferences(serviceClass, filter);
if ((refs == null) || (refs.length == 0))
return false;
for (ServiceReference reference : refs)
{
if ((bundleContext.getService(reference) == service) || (service instanceof String))
{
if (refs.length == 1)
{ // Last/only one, shut down the service
// Lame code
String dependentBaseBundleClassName = service.getClass().getName();
String packageName = ClassFinderActivator.getPackageName(dependentBaseBundleClassName, false);
if (service instanceof String)
packageName = (String)service;
Bundle bundle = this.findBundle(null, bundleContext, packageName, null);
if (bundle != null)
if ((bundle.getState() & Bundle.ACTIVE) != 0)
{
try {
bundle.stop();
} catch (BundleException e) {
e.printStackTrace();
}
}
return true;
}
}
}
} catch (InvalidSyntaxException e1) {
e1.printStackTrace();
}
return false; // Not found?
} | [
"public",
"boolean",
"shutdownService",
"(",
"String",
"serviceClass",
",",
"Object",
"service",
")",
"{",
"if",
"(",
"service",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"bundleContext",
"==",
"null",
")",
"return",
"false",
";",
"String",
"fi... | Shutdown the bundle for this service.
@param service The interface the service is registered under.
@param service The service or the package name of the service (service pid) that I'm looking for.
@return True if successful | [
"Shutdown",
"the",
"bundle",
"for",
"this",
"service",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L547-L594 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.startBundle | public void startBundle(Bundle bundle)
{
if (bundle != null)
if ((bundle.getState() != Bundle.ACTIVE) && (bundle.getState() != Bundle.STARTING))
{
try {
bundle.start();
} catch (BundleException e) {
e.printStackTrace();
}
}
} | java | public void startBundle(Bundle bundle)
{
if (bundle != null)
if ((bundle.getState() != Bundle.ACTIVE) && (bundle.getState() != Bundle.STARTING))
{
try {
bundle.start();
} catch (BundleException e) {
e.printStackTrace();
}
}
} | [
"public",
"void",
"startBundle",
"(",
"Bundle",
"bundle",
")",
"{",
"if",
"(",
"bundle",
"!=",
"null",
")",
"if",
"(",
"(",
"bundle",
".",
"getState",
"(",
")",
"!=",
"Bundle",
".",
"ACTIVE",
")",
"&&",
"(",
"bundle",
".",
"getState",
"(",
")",
"!=... | Start this bundle.
@param bundle | [
"Start",
"this",
"bundle",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L711-L722 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.getProperties | @SuppressWarnings("unchecked")
@Override
public Dictionary<String, String> getProperties(String servicePid)
{
Dictionary<String, String> properties = null;
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if (caRef != null)
{
ConfigurationAdmin configAdmin = (ConfigurationAdmin)bundleContext.getService(caRef);
Configuration config = configAdmin.getConfiguration(servicePid);
properties = config.getProperties();
}
}
} catch (IOException e) {
e.printStackTrace();
}
return properties;
} | java | @SuppressWarnings("unchecked")
@Override
public Dictionary<String, String> getProperties(String servicePid)
{
Dictionary<String, String> properties = null;
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if (caRef != null)
{
ConfigurationAdmin configAdmin = (ConfigurationAdmin)bundleContext.getService(caRef);
Configuration config = configAdmin.getConfiguration(servicePid);
properties = config.getProperties();
}
}
} catch (IOException e) {
e.printStackTrace();
}
return properties;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"Dictionary",
"<",
"String",
",",
"String",
">",
"getProperties",
"(",
"String",
"servicePid",
")",
"{",
"Dictionary",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"null",
... | Get the configuration properties for this Pid.
@param servicePid The service Pid
@return The properties or null if they don't exist. | [
"Get",
"the",
"configuration",
"properties",
"for",
"this",
"Pid",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L843-L864 | train |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java | BaseClassFinderService.saveProperties | @Override
public boolean saveProperties(String servicePid, Dictionary<String, String> properties)
{
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if (caRef != null)
{
ConfigurationAdmin configAdmin = (ConfigurationAdmin)bundleContext.getService(caRef);
Configuration config = configAdmin.getConfiguration(servicePid);
config.update(properties);
return true;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
} | java | @Override
public boolean saveProperties(String servicePid, Dictionary<String, String> properties)
{
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if (caRef != null)
{
ConfigurationAdmin configAdmin = (ConfigurationAdmin)bundleContext.getService(caRef);
Configuration config = configAdmin.getConfiguration(servicePid);
config.update(properties);
return true;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"saveProperties",
"(",
"String",
"servicePid",
",",
"Dictionary",
"<",
"String",
",",
"String",
">",
"properties",
")",
"{",
"try",
"{",
"if",
"(",
"servicePid",
"!=",
"null",
")",
"{",
"ServiceReference",
"caRef",
"=",
... | Set the configuration properties for this Pid.
@param servicePid The service Pid
@param The properties to save.
@return True if successful | [
"Set",
"the",
"configuration",
"properties",
"for",
"this",
"Pid",
"."
] | beb02aef78736a4f799aaac001c8f0327bf0536c | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L871-L891 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/util/Bytes.java | Bytes.read | public static byte[] read(InputStream in, boolean closeAfterwards) throws IOException {
byte[] buffer = new byte[32*1024];
ByteArrayOutputStream bas = new ByteArrayOutputStream();
for (int length; (length = in.read(buffer, 0, buffer.length)) > -1; bas.write(buffer, 0, length));
if (closeAfterwards) in.close();
return bas.toByteArray();
} | java | public static byte[] read(InputStream in, boolean closeAfterwards) throws IOException {
byte[] buffer = new byte[32*1024];
ByteArrayOutputStream bas = new ByteArrayOutputStream();
for (int length; (length = in.read(buffer, 0, buffer.length)) > -1; bas.write(buffer, 0, length));
if (closeAfterwards) in.close();
return bas.toByteArray();
} | [
"public",
"static",
"byte",
"[",
"]",
"read",
"(",
"InputStream",
"in",
",",
"boolean",
"closeAfterwards",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"32",
"*",
"1024",
"]",
";",
"ByteArrayOutputStream",
"bas",
... | Reads the whole contents of an input stream into a byte array, closing the stream if so requested.
@param in an input stream
@param closeAfterwards whether to close the stream afterwards
@return an array containing bytes read from the stream
@throws IOException if any I/O errors occur | [
"Reads",
"the",
"whole",
"contents",
"of",
"an",
"input",
"stream",
"into",
"a",
"byte",
"array",
"closing",
"the",
"stream",
"if",
"so",
"requested",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/util/Bytes.java#L29-L35 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.add | public void add(Collection<AlertPolicy> policies)
{
for(AlertPolicy policy : policies)
this.policies.put(policy.getId(), policy);
} | java | public void add(Collection<AlertPolicy> policies)
{
for(AlertPolicy policy : policies)
this.policies.put(policy.getId(), policy);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"AlertPolicy",
">",
"policies",
")",
"{",
"for",
"(",
"AlertPolicy",
"policy",
":",
"policies",
")",
"this",
".",
"policies",
".",
"put",
"(",
"policy",
".",
"getId",
"(",
")",
",",
"policy",
")",
";",
... | Adds the policy list to the policies for the account.
@param policies The policies to add | [
"Adds",
"the",
"policy",
"list",
"to",
"the",
"policies",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L73-L77 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.alertChannels | public AlertChannelCache alertChannels(long policyId)
{
AlertChannelCache cache = channels.get(policyId);
if(cache == null)
channels.put(policyId, cache = new AlertChannelCache(policyId));
return cache;
} | java | public AlertChannelCache alertChannels(long policyId)
{
AlertChannelCache cache = channels.get(policyId);
if(cache == null)
channels.put(policyId, cache = new AlertChannelCache(policyId));
return cache;
} | [
"public",
"AlertChannelCache",
"alertChannels",
"(",
"long",
"policyId",
")",
"{",
"AlertChannelCache",
"cache",
"=",
"channels",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"channels",
".",
"put",
"(",
"policyId",
",",
"c... | Returns the cache of alert channels for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of alert channels
@return The cache of alert channels for the given policy | [
"Returns",
"the",
"cache",
"of",
"alert",
"channels",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L119-L125 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.setAlertChannels | public void setAlertChannels(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
{
// Add the channel to any policies it is associated with
List<Long> policyIds = channel.getLinks().getPolicyIds();
for(long policyId : policyIds)
{
AlertPolicy policy = policies.get(policyId);
if(policy != null)
alertChannels(policyId).add(channel);
else
logger.severe(String.format("Unable to find policy for channel '%s': %d", channel.getName(), policyId));
}
}
} | java | public void setAlertChannels(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
{
// Add the channel to any policies it is associated with
List<Long> policyIds = channel.getLinks().getPolicyIds();
for(long policyId : policyIds)
{
AlertPolicy policy = policies.get(policyId);
if(policy != null)
alertChannels(policyId).add(channel);
else
logger.severe(String.format("Unable to find policy for channel '%s': %d", channel.getName(), policyId));
}
}
} | [
"public",
"void",
"setAlertChannels",
"(",
"Collection",
"<",
"AlertChannel",
">",
"channels",
")",
"{",
"for",
"(",
"AlertChannel",
"channel",
":",
"channels",
")",
"{",
"// Add the channel to any policies it is associated with",
"List",
"<",
"Long",
">",
"policyIds"... | Sets the channels on the policies for the account.
@param channels The channels to set | [
"Sets",
"the",
"channels",
"on",
"the",
"policies",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L131-L146 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.alertConditions | public AlertConditionCache alertConditions(long policyId)
{
AlertConditionCache cache = conditions.get(policyId);
if(cache == null)
conditions.put(policyId, cache = new AlertConditionCache(policyId));
return cache;
} | java | public AlertConditionCache alertConditions(long policyId)
{
AlertConditionCache cache = conditions.get(policyId);
if(cache == null)
conditions.put(policyId, cache = new AlertConditionCache(policyId));
return cache;
} | [
"public",
"AlertConditionCache",
"alertConditions",
"(",
"long",
"policyId",
")",
"{",
"AlertConditionCache",
"cache",
"=",
"conditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"conditions",
".",
"put",
"(",
"policyId",
... | Returns the cache of alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of alert conditions
@return The cache of alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L153-L159 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.nrqlAlertConditions | public NrqlAlertConditionCache nrqlAlertConditions(long policyId)
{
NrqlAlertConditionCache cache = nrqlConditions.get(policyId);
if(cache == null)
nrqlConditions.put(policyId, cache = new NrqlAlertConditionCache(policyId));
return cache;
} | java | public NrqlAlertConditionCache nrqlAlertConditions(long policyId)
{
NrqlAlertConditionCache cache = nrqlConditions.get(policyId);
if(cache == null)
nrqlConditions.put(policyId, cache = new NrqlAlertConditionCache(policyId));
return cache;
} | [
"public",
"NrqlAlertConditionCache",
"nrqlAlertConditions",
"(",
"long",
"policyId",
")",
"{",
"NrqlAlertConditionCache",
"cache",
"=",
"nrqlConditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"nrqlConditions",
".",
"put",
... | Returns the cache of NRQL alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of NRQL alert conditions
@return The cache of NRQL alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"NRQL",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L166-L172 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.externalServiceAlertConditions | public ExternalServiceAlertConditionCache externalServiceAlertConditions(long policyId)
{
ExternalServiceAlertConditionCache cache = externalServiceConditions.get(policyId);
if(cache == null)
externalServiceConditions.put(policyId, cache = new ExternalServiceAlertConditionCache(policyId));
return cache;
} | java | public ExternalServiceAlertConditionCache externalServiceAlertConditions(long policyId)
{
ExternalServiceAlertConditionCache cache = externalServiceConditions.get(policyId);
if(cache == null)
externalServiceConditions.put(policyId, cache = new ExternalServiceAlertConditionCache(policyId));
return cache;
} | [
"public",
"ExternalServiceAlertConditionCache",
"externalServiceAlertConditions",
"(",
"long",
"policyId",
")",
"{",
"ExternalServiceAlertConditionCache",
"cache",
"=",
"externalServiceConditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
... | Returns the cache of external service alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of external service alert conditions
@return The cache of external service alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"external",
"service",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L179-L185 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.syntheticsAlertConditions | public SyntheticsAlertConditionCache syntheticsAlertConditions(long policyId)
{
SyntheticsAlertConditionCache cache = syntheticsConditions.get(policyId);
if(cache == null)
syntheticsConditions.put(policyId, cache = new SyntheticsAlertConditionCache(policyId));
return cache;
} | java | public SyntheticsAlertConditionCache syntheticsAlertConditions(long policyId)
{
SyntheticsAlertConditionCache cache = syntheticsConditions.get(policyId);
if(cache == null)
syntheticsConditions.put(policyId, cache = new SyntheticsAlertConditionCache(policyId));
return cache;
} | [
"public",
"SyntheticsAlertConditionCache",
"syntheticsAlertConditions",
"(",
"long",
"policyId",
")",
"{",
"SyntheticsAlertConditionCache",
"cache",
"=",
"syntheticsConditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"syntheticsC... | Returns the cache of Synthetics alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of Synthetics alert conditions
@return The cache of Synthetics alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"Synthetics",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L192-L198 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.pluginsAlertConditions | public PluginsAlertConditionCache pluginsAlertConditions(long policyId)
{
PluginsAlertConditionCache cache = pluginsConditions.get(policyId);
if(cache == null)
pluginsConditions.put(policyId, cache = new PluginsAlertConditionCache(policyId));
return cache;
} | java | public PluginsAlertConditionCache pluginsAlertConditions(long policyId)
{
PluginsAlertConditionCache cache = pluginsConditions.get(policyId);
if(cache == null)
pluginsConditions.put(policyId, cache = new PluginsAlertConditionCache(policyId));
return cache;
} | [
"public",
"PluginsAlertConditionCache",
"pluginsAlertConditions",
"(",
"long",
"policyId",
")",
"{",
"PluginsAlertConditionCache",
"cache",
"=",
"pluginsConditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"pluginsConditions",
"... | Returns the cache of Plugins alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of Plugins alert conditions
@return The cache of Plugins alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"Plugins",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L205-L211 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java | AlertPolicyCache.infraAlertConditions | public InfraAlertConditionCache infraAlertConditions(long policyId)
{
InfraAlertConditionCache cache = infraConditions.get(policyId);
if(cache == null)
infraConditions.put(policyId, cache = new InfraAlertConditionCache(policyId));
return cache;
} | java | public InfraAlertConditionCache infraAlertConditions(long policyId)
{
InfraAlertConditionCache cache = infraConditions.get(policyId);
if(cache == null)
infraConditions.put(policyId, cache = new InfraAlertConditionCache(policyId));
return cache;
} | [
"public",
"InfraAlertConditionCache",
"infraAlertConditions",
"(",
"long",
"policyId",
")",
"{",
"InfraAlertConditionCache",
"cache",
"=",
"infraConditions",
".",
"get",
"(",
"policyId",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"infraConditions",
".",
"put... | Returns the cache of Infrastructure alert conditions for the given policy, creating one if it doesn't exist .
@param policyId The id of the policy for the cache of Infrastructure alert conditions
@return The cache of Infrastructure alert conditions for the given policy | [
"Returns",
"the",
"cache",
"of",
"Infrastructure",
"alert",
"conditions",
"for",
"the",
"given",
"policy",
"creating",
"one",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertPolicyCache.java#L218-L224 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/util/Log.java | Log.defaultWriter | static PrintWriter defaultWriter(Context context) {
PrintWriter result = context.get(outKey);
if (result == null)
context.put(outKey, result = new PrintWriter(System.err));
return result;
} | java | static PrintWriter defaultWriter(Context context) {
PrintWriter result = context.get(outKey);
if (result == null)
context.put(outKey, result = new PrintWriter(System.err));
return result;
} | [
"static",
"PrintWriter",
"defaultWriter",
"(",
"Context",
"context",
")",
"{",
"PrintWriter",
"result",
"=",
"context",
".",
"get",
"(",
"outKey",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"context",
".",
"put",
"(",
"outKey",
",",
"result",
"=",... | The default writer for diagnostics | [
"The",
"default",
"writer",
"for",
"diagnostics"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/Log.java#L303-L308 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/util/Log.java | Log.initRound | public void initRound(Log other) {
this.noticeWriter = other.noticeWriter;
this.warnWriter = other.warnWriter;
this.errWriter = other.errWriter;
this.sourceMap = other.sourceMap;
this.recorded = other.recorded;
this.nerrors = other.nerrors;
this.nwarnings = other.nwarnings;
} | java | public void initRound(Log other) {
this.noticeWriter = other.noticeWriter;
this.warnWriter = other.warnWriter;
this.errWriter = other.errWriter;
this.sourceMap = other.sourceMap;
this.recorded = other.recorded;
this.nerrors = other.nerrors;
this.nwarnings = other.nwarnings;
} | [
"public",
"void",
"initRound",
"(",
"Log",
"other",
")",
"{",
"this",
".",
"noticeWriter",
"=",
"other",
".",
"noticeWriter",
";",
"this",
".",
"warnWriter",
"=",
"other",
".",
"warnWriter",
";",
"this",
".",
"errWriter",
"=",
"other",
".",
"errWriter",
... | Propagate the previous log's information. | [
"Propagate",
"the",
"previous",
"log",
"s",
"information",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/Log.java#L398-L406 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/JavacState.java | JavacState.setVisibleSources | public void setVisibleSources(Map<String,Source> vs) {
visibleSrcs = new HashSet<URI>();
for (String s : vs.keySet()) {
Source src = vs.get(s);
visibleSrcs.add(src.file().toURI());
}
} | java | public void setVisibleSources(Map<String,Source> vs) {
visibleSrcs = new HashSet<URI>();
for (String s : vs.keySet()) {
Source src = vs.get(s);
visibleSrcs.add(src.file().toURI());
}
} | [
"public",
"void",
"setVisibleSources",
"(",
"Map",
"<",
"String",
",",
"Source",
">",
"vs",
")",
"{",
"visibleSrcs",
"=",
"new",
"HashSet",
"<",
"URI",
">",
"(",
")",
";",
"for",
"(",
"String",
"s",
":",
"vs",
".",
"keySet",
"(",
")",
")",
"{",
"... | Specify which sources are visible to the compiler through -sourcepath. | [
"Specify",
"which",
"sources",
"are",
"visible",
"to",
"the",
"compiler",
"through",
"-",
"sourcepath",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/JavacState.java#L199-L205 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/JavacState.java | JavacState.save | public void save() throws IOException {
if (!needsSaving) return;
try (FileWriter out = new FileWriter(javacStateFilename)) {
StringBuilder b = new StringBuilder();
long millisNow = System.currentTimeMillis();
Date d = new Date(millisNow);
SimpleDateFormat df =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
b.append("# javac_state ver 0.3 generated "+millisNow+" "+df.format(d)+"\n");
b.append("# This format might change at any time. Please do not depend on it.\n");
b.append("# M module\n");
b.append("# P package\n");
b.append("# S C source_tobe_compiled timestamp\n");
b.append("# S L link_only_source timestamp\n");
b.append("# G C generated_source timestamp\n");
b.append("# A artifact timestamp\n");
b.append("# D dependency\n");
b.append("# I pubapi\n");
b.append("# R arguments\n");
b.append("R ").append(theArgs).append("\n");
// Copy over the javac_state for the packages that did not need recompilation.
now.copyPackagesExcept(prev, recompiledPackages, new HashSet<String>());
// Save the packages, ie package names, dependencies, pubapis and artifacts!
// I.e. the lot.
Module.saveModules(now.modules(), b);
String s = b.toString();
out.write(s, 0, s.length());
}
} | java | public void save() throws IOException {
if (!needsSaving) return;
try (FileWriter out = new FileWriter(javacStateFilename)) {
StringBuilder b = new StringBuilder();
long millisNow = System.currentTimeMillis();
Date d = new Date(millisNow);
SimpleDateFormat df =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
b.append("# javac_state ver 0.3 generated "+millisNow+" "+df.format(d)+"\n");
b.append("# This format might change at any time. Please do not depend on it.\n");
b.append("# M module\n");
b.append("# P package\n");
b.append("# S C source_tobe_compiled timestamp\n");
b.append("# S L link_only_source timestamp\n");
b.append("# G C generated_source timestamp\n");
b.append("# A artifact timestamp\n");
b.append("# D dependency\n");
b.append("# I pubapi\n");
b.append("# R arguments\n");
b.append("R ").append(theArgs).append("\n");
// Copy over the javac_state for the packages that did not need recompilation.
now.copyPackagesExcept(prev, recompiledPackages, new HashSet<String>());
// Save the packages, ie package names, dependencies, pubapis and artifacts!
// I.e. the lot.
Module.saveModules(now.modules(), b);
String s = b.toString();
out.write(s, 0, s.length());
}
} | [
"public",
"void",
"save",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"needsSaving",
")",
"return",
";",
"try",
"(",
"FileWriter",
"out",
"=",
"new",
"FileWriter",
"(",
"javacStateFilename",
")",
")",
"{",
"StringBuilder",
"b",
"=",
"new",
"S... | Save the javac_state file. | [
"Save",
"the",
"javac_state",
"file",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/JavacState.java#L269-L299 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/JavacState.java | JavacState.performJavaCompilations | public boolean performJavaCompilations(File binDir,
String serverSettings,
String[] args,
Set<String> recentlyCompiled,
boolean[] rcValue) {
Map<String,Transformer> suffixRules = new HashMap<String,Transformer>();
suffixRules.put(".java", compileJavaPackages);
compileJavaPackages.setExtra(serverSettings);
compileJavaPackages.setExtra(args);
rcValue[0] = perform(binDir, suffixRules);
recentlyCompiled.addAll(taintedPackages());
clearTaintedPackages();
boolean again = !packagesWithChangedPublicApis.isEmpty();
taintPackagesDependingOnChangedPackages(packagesWithChangedPublicApis, recentlyCompiled);
packagesWithChangedPublicApis = new HashSet<String>();
return again && rcValue[0];
} | java | public boolean performJavaCompilations(File binDir,
String serverSettings,
String[] args,
Set<String> recentlyCompiled,
boolean[] rcValue) {
Map<String,Transformer> suffixRules = new HashMap<String,Transformer>();
suffixRules.put(".java", compileJavaPackages);
compileJavaPackages.setExtra(serverSettings);
compileJavaPackages.setExtra(args);
rcValue[0] = perform(binDir, suffixRules);
recentlyCompiled.addAll(taintedPackages());
clearTaintedPackages();
boolean again = !packagesWithChangedPublicApis.isEmpty();
taintPackagesDependingOnChangedPackages(packagesWithChangedPublicApis, recentlyCompiled);
packagesWithChangedPublicApis = new HashSet<String>();
return again && rcValue[0];
} | [
"public",
"boolean",
"performJavaCompilations",
"(",
"File",
"binDir",
",",
"String",
"serverSettings",
",",
"String",
"[",
"]",
"args",
",",
"Set",
"<",
"String",
">",
"recentlyCompiled",
",",
"boolean",
"[",
"]",
"rcValue",
")",
"{",
"Map",
"<",
"String",
... | Compile all the java sources. Return true, if it needs to be called again! | [
"Compile",
"all",
"the",
"java",
"sources",
".",
"Return",
"true",
"if",
"it",
"needs",
"to",
"be",
"called",
"again!"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/JavacState.java#L657-L674 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/JavacState.java | JavacState.addFileToTransform | private void addFileToTransform(Map<Transformer,Map<String,Set<URI>>> gs, Transformer t, Source s) {
Map<String,Set<URI>> fs = gs.get(t);
if (fs == null) {
fs = new HashMap<String,Set<URI>>();
gs.put(t, fs);
}
Set<URI> ss = fs.get(s.pkg().name());
if (ss == null) {
ss = new HashSet<URI>();
fs.put(s.pkg().name(), ss);
}
ss.add(s.file().toURI());
} | java | private void addFileToTransform(Map<Transformer,Map<String,Set<URI>>> gs, Transformer t, Source s) {
Map<String,Set<URI>> fs = gs.get(t);
if (fs == null) {
fs = new HashMap<String,Set<URI>>();
gs.put(t, fs);
}
Set<URI> ss = fs.get(s.pkg().name());
if (ss == null) {
ss = new HashSet<URI>();
fs.put(s.pkg().name(), ss);
}
ss.add(s.file().toURI());
} | [
"private",
"void",
"addFileToTransform",
"(",
"Map",
"<",
"Transformer",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"URI",
">",
">",
">",
"gs",
",",
"Transformer",
"t",
",",
"Source",
"s",
")",
"{",
"Map",
"<",
"String",
",",
"Set",
"<",
"URI",
">... | Store the source into the set of sources belonging to the given transform. | [
"Store",
"the",
"source",
"into",
"the",
"set",
"of",
"sources",
"belonging",
"to",
"the",
"given",
"transform",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/JavacState.java#L679-L691 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java | DeprecatedAPIListBuilder.buildDeprecatedAPIInfo | private void buildDeprecatedAPIInfo(Configuration configuration) {
PackageDoc[] packages = configuration.packages;
PackageDoc pkg;
for (int c = 0; c < packages.length; c++) {
pkg = packages[c];
if (Util.isDeprecated(pkg)) {
getList(PACKAGE).add(pkg);
}
}
ClassDoc[] classes = configuration.root.classes();
for (int i = 0; i < classes.length; i++) {
ClassDoc cd = classes[i];
if (Util.isDeprecated(cd)) {
if (cd.isOrdinaryClass()) {
getList(CLASS).add(cd);
} else if (cd.isInterface()) {
getList(INTERFACE).add(cd);
} else if (cd.isException()) {
getList(EXCEPTION).add(cd);
} else if (cd.isEnum()) {
getList(ENUM).add(cd);
} else if (cd.isError()) {
getList(ERROR).add(cd);
} else if (cd.isAnnotationType()) {
getList(ANNOTATION_TYPE).add(cd);
}
}
composeDeprecatedList(getList(FIELD), cd.fields());
composeDeprecatedList(getList(METHOD), cd.methods());
composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors());
if (cd.isEnum()) {
composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants());
}
if (cd.isAnnotationType()) {
composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER),
((AnnotationTypeDoc) cd).elements());
}
}
sortDeprecatedLists();
} | java | private void buildDeprecatedAPIInfo(Configuration configuration) {
PackageDoc[] packages = configuration.packages;
PackageDoc pkg;
for (int c = 0; c < packages.length; c++) {
pkg = packages[c];
if (Util.isDeprecated(pkg)) {
getList(PACKAGE).add(pkg);
}
}
ClassDoc[] classes = configuration.root.classes();
for (int i = 0; i < classes.length; i++) {
ClassDoc cd = classes[i];
if (Util.isDeprecated(cd)) {
if (cd.isOrdinaryClass()) {
getList(CLASS).add(cd);
} else if (cd.isInterface()) {
getList(INTERFACE).add(cd);
} else if (cd.isException()) {
getList(EXCEPTION).add(cd);
} else if (cd.isEnum()) {
getList(ENUM).add(cd);
} else if (cd.isError()) {
getList(ERROR).add(cd);
} else if (cd.isAnnotationType()) {
getList(ANNOTATION_TYPE).add(cd);
}
}
composeDeprecatedList(getList(FIELD), cd.fields());
composeDeprecatedList(getList(METHOD), cd.methods());
composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors());
if (cd.isEnum()) {
composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants());
}
if (cd.isAnnotationType()) {
composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER),
((AnnotationTypeDoc) cd).elements());
}
}
sortDeprecatedLists();
} | [
"private",
"void",
"buildDeprecatedAPIInfo",
"(",
"Configuration",
"configuration",
")",
"{",
"PackageDoc",
"[",
"]",
"packages",
"=",
"configuration",
".",
"packages",
";",
"PackageDoc",
"pkg",
";",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"packages... | Build the sorted list of all the deprecated APIs in this run.
Build separate lists for deprecated packages, classes, constructors,
methods and fields.
@param configuration the current configuration of the doclet. | [
"Build",
"the",
"sorted",
"list",
"of",
"all",
"the",
"deprecated",
"APIs",
"in",
"this",
"run",
".",
"Build",
"separate",
"lists",
"for",
"deprecated",
"packages",
"classes",
"constructors",
"methods",
"and",
"fields",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java#L86-L125 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/validation/Validator.java | Validator.parse | public Object parse(String text) throws DataValidationException {
try {
preValidate(text);
Object object = _valueOf.invoke(text);
postValidate(object);
return object;
} catch (DataValidationException x) {
throw x;
} catch (IllegalArgumentException x) {
// various format errors from valueOf() - ignore the details
throw new DataValidationException("FORMAT", _name, text);
} catch (Throwable t) {
throw new DataValidationException("", _name, text, t);
}
} | java | public Object parse(String text) throws DataValidationException {
try {
preValidate(text);
Object object = _valueOf.invoke(text);
postValidate(object);
return object;
} catch (DataValidationException x) {
throw x;
} catch (IllegalArgumentException x) {
// various format errors from valueOf() - ignore the details
throw new DataValidationException("FORMAT", _name, text);
} catch (Throwable t) {
throw new DataValidationException("", _name, text, t);
}
} | [
"public",
"Object",
"parse",
"(",
"String",
"text",
")",
"throws",
"DataValidationException",
"{",
"try",
"{",
"preValidate",
"(",
"text",
")",
";",
"Object",
"object",
"=",
"_valueOf",
".",
"invoke",
"(",
"text",
")",
";",
"postValidate",
"(",
"object",
"... | Parses a string to produce a validated value of this given data type.
@throws DataValidationException | [
"Parses",
"a",
"string",
"to",
"produce",
"a",
"validated",
"value",
"of",
"this",
"given",
"data",
"type",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/validation/Validator.java#L95-L109 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/validation/Validator.java | Validator.preValidate | public void preValidate(String text) throws DataValidationException {
// size
Trace.g.std.note(Validator.class, "preValidate: size = " + _size);
if (_size > 0 && text.length() > _size) {
throw new DataValidationException("SIZE", _name, text);
}
// pattern
Trace.g.std.note(Validator.class, "preValidate: pattern = " + _pattern);
if (_pattern != null && !_pattern.matcher(text).matches()) {
throw new DataValidationException("PATTERN", _name, text);
}
} | java | public void preValidate(String text) throws DataValidationException {
// size
Trace.g.std.note(Validator.class, "preValidate: size = " + _size);
if (_size > 0 && text.length() > _size) {
throw new DataValidationException("SIZE", _name, text);
}
// pattern
Trace.g.std.note(Validator.class, "preValidate: pattern = " + _pattern);
if (_pattern != null && !_pattern.matcher(text).matches()) {
throw new DataValidationException("PATTERN", _name, text);
}
} | [
"public",
"void",
"preValidate",
"(",
"String",
"text",
")",
"throws",
"DataValidationException",
"{",
"// size\r",
"Trace",
".",
"g",
".",
"std",
".",
"note",
"(",
"Validator",
".",
"class",
",",
"\"preValidate: size = \"",
"+",
"_size",
")",
";",
"if",
"("... | Performs all data validation that is based on the string representation of the value before it is converted.
@param text - the string representation of the data value
@throws DataValidationException if any of the data constraints are violated | [
"Performs",
"all",
"data",
"validation",
"that",
"is",
"based",
"on",
"the",
"string",
"representation",
"of",
"the",
"value",
"before",
"it",
"is",
"converted",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/validation/Validator.java#L117-L129 | train |
brianwhu/xillium | data/src/main/java/org/xillium/data/validation/Validator.java | Validator.postValidate | @SuppressWarnings("unchecked")
public void postValidate(Object object) throws DataValidationException {
if (_values != null || _ranges != null) {
if (_values != null) for (Object value: _values) {
if (value.equals(object)) return;
}
if (_ranges != null) for (@SuppressWarnings("rawtypes") Range r: _ranges) {
@SuppressWarnings("rawtypes")
Comparable o = (Comparable)object;
if (r.inclusive) {
if ((r.min == null || r.min.compareTo(o) <= 0) && (r.max == null || o.compareTo(r.max) <= 0)) {
return;
}
} else {
if ((r.min == null || r.min.compareTo(o) < 0) && (r.max == null || o.compareTo(r.max) < 0)) {
return;
}
}
}
throw new DataValidationException("VALUES/RANGES", _name, object);
}
} | java | @SuppressWarnings("unchecked")
public void postValidate(Object object) throws DataValidationException {
if (_values != null || _ranges != null) {
if (_values != null) for (Object value: _values) {
if (value.equals(object)) return;
}
if (_ranges != null) for (@SuppressWarnings("rawtypes") Range r: _ranges) {
@SuppressWarnings("rawtypes")
Comparable o = (Comparable)object;
if (r.inclusive) {
if ((r.min == null || r.min.compareTo(o) <= 0) && (r.max == null || o.compareTo(r.max) <= 0)) {
return;
}
} else {
if ((r.min == null || r.min.compareTo(o) < 0) && (r.max == null || o.compareTo(r.max) < 0)) {
return;
}
}
}
throw new DataValidationException("VALUES/RANGES", _name, object);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"postValidate",
"(",
"Object",
"object",
")",
"throws",
"DataValidationException",
"{",
"if",
"(",
"_values",
"!=",
"null",
"||",
"_ranges",
"!=",
"null",
")",
"{",
"if",
"(",
"_values",
"... | Performs all data validation that is appicable to the data value itself
@param object - the data value
@throws DataValidationException if any of the data constraints are violated | [
"Performs",
"all",
"data",
"validation",
"that",
"is",
"appicable",
"to",
"the",
"data",
"value",
"itself"
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/validation/Validator.java#L137-L160 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java | Player.startRobot | public void startRobot(Robot newRobot) {
newRobot.getData().setActiveState(DEFAULT_START_STATE);
Thread newThread = new Thread(robotsThreads, newRobot, "Bot-" + newRobot.getSerialNumber());
newThread.start(); // jumpstarts the robot
} | java | public void startRobot(Robot newRobot) {
newRobot.getData().setActiveState(DEFAULT_START_STATE);
Thread newThread = new Thread(robotsThreads, newRobot, "Bot-" + newRobot.getSerialNumber());
newThread.start(); // jumpstarts the robot
} | [
"public",
"void",
"startRobot",
"(",
"Robot",
"newRobot",
")",
"{",
"newRobot",
".",
"getData",
"(",
")",
".",
"setActiveState",
"(",
"DEFAULT_START_STATE",
")",
";",
"Thread",
"newThread",
"=",
"new",
"Thread",
"(",
"robotsThreads",
",",
"newRobot",
",",
"\... | Starts the thread of a robot in the player's thread group
@param newRobot the robot to start | [
"Starts",
"the",
"thread",
"of",
"a",
"robot",
"in",
"the",
"player",
"s",
"thread",
"group"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java#L207-L212 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.