id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,900 | ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.getMethodsReturn | public Set<Method> getMethodsReturn(Class returnType) {
return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders());
} | java | public Set<Method> getMethodsReturn(Class returnType) {
return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders());
} | [
"public",
"Set",
"<",
"Method",
">",
"getMethodsReturn",
"(",
"Class",
"returnType",
")",
"{",
"return",
"getMethodsFromDescriptors",
"(",
"store",
".",
"get",
"(",
"index",
"(",
"MethodParameterScanner",
".",
"class",
")",
",",
"names",
"(",
"returnType",
")"... | get methods with return type match given type | [
"get",
"methods",
"with",
"return",
"type",
"match",
"given",
"type"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L505-L507 |
30,901 | ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.getMethodsWithAnyParamAnnotated | public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) {
return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());
} | java | public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) {
return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());
} | [
"public",
"Set",
"<",
"Method",
">",
"getMethodsWithAnyParamAnnotated",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"return",
"getMethodsFromDescriptors",
"(",
"store",
".",
"get",
"(",
"index",
"(",
"MethodParameterScanner",
".",... | get methods with any parameter annotated with given annotation | [
"get",
"methods",
"with",
"any",
"parameter",
"annotated",
"with",
"given",
"annotation"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L510-L513 |
30,902 | ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.getMethodsWithAnyParamAnnotated | public Set<Method> getMethodsWithAnyParamAnnotated(Annotation annotation) {
return filter(getMethodsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation));
} | java | public Set<Method> getMethodsWithAnyParamAnnotated(Annotation annotation) {
return filter(getMethodsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation));
} | [
"public",
"Set",
"<",
"Method",
">",
"getMethodsWithAnyParamAnnotated",
"(",
"Annotation",
"annotation",
")",
"{",
"return",
"filter",
"(",
"getMethodsWithAnyParamAnnotated",
"(",
"annotation",
".",
"annotationType",
"(",
")",
")",
",",
"withAnyParameterAnnotation",
"... | get methods with any parameter annotated with given annotation, including annotation member values matching | [
"get",
"methods",
"with",
"any",
"parameter",
"annotated",
"with",
"given",
"annotation",
"including",
"annotation",
"member",
"values",
"matching"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L516-L518 |
30,903 | ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.getConstructorsWithAnyParamAnnotated | public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class<? extends Annotation> annotation) {
return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());
} | java | public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class<? extends Annotation> annotation) {
return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());
} | [
"public",
"Set",
"<",
"Constructor",
">",
"getConstructorsWithAnyParamAnnotated",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"return",
"getConstructorsFromDescriptors",
"(",
"store",
".",
"get",
"(",
"index",
"(",
"MethodParameterS... | get constructors with any parameter annotated with given annotation | [
"get",
"constructors",
"with",
"any",
"parameter",
"annotated",
"with",
"given",
"annotation"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L543-L545 |
30,904 | ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.getConstructorsWithAnyParamAnnotated | public Set<Constructor> getConstructorsWithAnyParamAnnotated(Annotation annotation) {
return filter(getConstructorsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation));
} | java | public Set<Constructor> getConstructorsWithAnyParamAnnotated(Annotation annotation) {
return filter(getConstructorsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation));
} | [
"public",
"Set",
"<",
"Constructor",
">",
"getConstructorsWithAnyParamAnnotated",
"(",
"Annotation",
"annotation",
")",
"{",
"return",
"filter",
"(",
"getConstructorsWithAnyParamAnnotated",
"(",
"annotation",
".",
"annotationType",
"(",
")",
")",
",",
"withAnyParameterA... | get constructors with any parameter annotated with given annotation, including annotation member values matching | [
"get",
"constructors",
"with",
"any",
"parameter",
"annotated",
"with",
"given",
"annotation",
"including",
"annotation",
"member",
"values",
"matching"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L548-L550 |
30,905 | ronmamo/reflections | src/main/java/org/reflections/util/ClasspathHelper.java | ClasspathHelper.tryToGetValidUrl | static URL tryToGetValidUrl(String workingDir, String path, String filename) {
try {
if (new File(filename).exists())
return new File(filename).toURI().toURL();
if (new File(path + File.separator + filename).exists())
return new File(path + File.separator + filename).toURI().toURL();
if (new File(workingDir + File.separator + filename).exists())
return new File(workingDir + File.separator + filename).toURI().toURL();
if (new File(new URL(filename).getFile()).exists())
return new File(new URL(filename).getFile()).toURI().toURL();
} catch (MalformedURLException e) {
// don't do anything, we're going on the assumption it is a jar, which could be wrong
}
return null;
} | java | static URL tryToGetValidUrl(String workingDir, String path, String filename) {
try {
if (new File(filename).exists())
return new File(filename).toURI().toURL();
if (new File(path + File.separator + filename).exists())
return new File(path + File.separator + filename).toURI().toURL();
if (new File(workingDir + File.separator + filename).exists())
return new File(workingDir + File.separator + filename).toURI().toURL();
if (new File(new URL(filename).getFile()).exists())
return new File(new URL(filename).getFile()).toURI().toURL();
} catch (MalformedURLException e) {
// don't do anything, we're going on the assumption it is a jar, which could be wrong
}
return null;
} | [
"static",
"URL",
"tryToGetValidUrl",
"(",
"String",
"workingDir",
",",
"String",
"path",
",",
"String",
"filename",
")",
"{",
"try",
"{",
"if",
"(",
"new",
"File",
"(",
"filename",
")",
".",
"exists",
"(",
")",
")",
"return",
"new",
"File",
"(",
"filen... | a little bit cryptic... | [
"a",
"little",
"bit",
"cryptic",
"..."
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/util/ClasspathHelper.java#L335-L349 |
30,906 | ronmamo/reflections | src/main/java/org/reflections/util/FilterBuilder.java | FilterBuilder.includePackage | public FilterBuilder includePackage(final String... prefixes) {
for (String prefix : prefixes) {
add(new Include(prefix(prefix)));
}
return this;
} | java | public FilterBuilder includePackage(final String... prefixes) {
for (String prefix : prefixes) {
add(new Include(prefix(prefix)));
}
return this;
} | [
"public",
"FilterBuilder",
"includePackage",
"(",
"final",
"String",
"...",
"prefixes",
")",
"{",
"for",
"(",
"String",
"prefix",
":",
"prefixes",
")",
"{",
"add",
"(",
"new",
"Include",
"(",
"prefix",
"(",
"prefix",
")",
")",
")",
";",
"}",
"return",
... | include packages of given prefixes | [
"include",
"packages",
"of",
"given",
"prefixes"
] | 084cf4a759a06d88e88753ac00397478c2e0ed52 | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/util/FilterBuilder.java#L43-L48 |
30,907 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/MetadataSet.java | MetadataSet.getRefinedBy | public Optional<Metadata> getRefinedBy(Metadata meta)
{
return Optional.fromNullable(refines.get(meta));
} | java | public Optional<Metadata> getRefinedBy(Metadata meta)
{
return Optional.fromNullable(refines.get(meta));
} | [
"public",
"Optional",
"<",
"Metadata",
">",
"getRefinedBy",
"(",
"Metadata",
"meta",
")",
"{",
"return",
"Optional",
".",
"fromNullable",
"(",
"refines",
".",
"get",
"(",
"meta",
")",
")",
";",
"}"
] | Returns an optional metadata expression refined by the given metadata
expression.
@param meta
a metadata expression
@return {@link Optional#absent()} if the given metadata expression does not
refine another metadata expression or a
{@link Optional#of(Metadata)} containing the refined metadata
expression | [
"Returns",
"an",
"optional",
"metadata",
"expression",
"refined",
"by",
"the",
"given",
"metadata",
"expression",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/MetadataSet.java#L188-L191 |
30,908 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/util/Messages.java | Messages.getInstance | public static Messages getInstance(Locale locale, Class<?> cls)
{
Messages instance = null;
locale = (locale == null) ? Locale.getDefault() : locale;
String bundleKey = (cls==null)? BUNDLE_NAME : getBundleName(cls);
String localeKey = locale.getLanguage();
if (messageTable.contains(bundleKey, localeKey)) {
instance = messageTable.get(bundleKey, localeKey);
}
else
{
synchronized (Messages.class)
{
if (instance == null)
{
instance = new Messages(locale, bundleKey);
messageTable.put(bundleKey, localeKey, instance);
}
}
}
return instance;
} | java | public static Messages getInstance(Locale locale, Class<?> cls)
{
Messages instance = null;
locale = (locale == null) ? Locale.getDefault() : locale;
String bundleKey = (cls==null)? BUNDLE_NAME : getBundleName(cls);
String localeKey = locale.getLanguage();
if (messageTable.contains(bundleKey, localeKey)) {
instance = messageTable.get(bundleKey, localeKey);
}
else
{
synchronized (Messages.class)
{
if (instance == null)
{
instance = new Messages(locale, bundleKey);
messageTable.put(bundleKey, localeKey, instance);
}
}
}
return instance;
} | [
"public",
"static",
"Messages",
"getInstance",
"(",
"Locale",
"locale",
",",
"Class",
"<",
"?",
">",
"cls",
")",
"{",
"Messages",
"instance",
"=",
"null",
";",
"locale",
"=",
"(",
"locale",
"==",
"null",
")",
"?",
"Locale",
".",
"getDefault",
"(",
")",... | Get a Messages instance that has been localized for the given locale, or
the default locale if locale is null. Note that passing an unknown locale
returns the default messages.
@param locale
The locale to use for localization of the messages.
@return The localized messages or default. | [
"Get",
"a",
"Messages",
"instance",
"that",
"has",
"been",
"localized",
"for",
"the",
"given",
"locale",
"or",
"the",
"default",
"locale",
"if",
"locale",
"is",
"null",
".",
"Note",
"that",
"passing",
"an",
"unknown",
"locale",
"returns",
"the",
"default",
... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/util/Messages.java#L83-L107 |
30,909 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/AggregateVocab.java | AggregateVocab.of | public static Vocab of(Vocab... vocabs)
{
return new AggregateVocab(new ImmutableList.Builder<Vocab>().add(vocabs).build());
} | java | public static Vocab of(Vocab... vocabs)
{
return new AggregateVocab(new ImmutableList.Builder<Vocab>().add(vocabs).build());
} | [
"public",
"static",
"Vocab",
"of",
"(",
"Vocab",
"...",
"vocabs",
")",
"{",
"return",
"new",
"AggregateVocab",
"(",
"new",
"ImmutableList",
".",
"Builder",
"<",
"Vocab",
">",
"(",
")",
".",
"add",
"(",
"vocabs",
")",
".",
"build",
"(",
")",
")",
";",... | Returns a vocabulary composed of the union of the vocabularies given as
parameter. The given vocabularies must have the same base URI.
@param vocabs
the vocabularies to aggregate.
@return the aggregated vocabulary. | [
"Returns",
"a",
"vocabulary",
"composed",
"of",
"the",
"union",
"of",
"the",
"vocabularies",
"given",
"as",
"parameter",
".",
"The",
"given",
"vocabularies",
"must",
"have",
"the",
"same",
"base",
"URI",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/AggregateVocab.java#L23-L26 |
30,910 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java | VocabUtil.parseProperty | public static Optional<Property> parseProperty(String value, Map<String, Vocab> vocabs,
ValidationContext context, EPUBLocation location)
{
return Optional.fromNullable(
Iterables.get(parseProperties(value, vocabs, false, context, location), 0, null));
} | java | public static Optional<Property> parseProperty(String value, Map<String, Vocab> vocabs,
ValidationContext context, EPUBLocation location)
{
return Optional.fromNullable(
Iterables.get(parseProperties(value, vocabs, false, context, location), 0, null));
} | [
"public",
"static",
"Optional",
"<",
"Property",
">",
"parseProperty",
"(",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"Vocab",
">",
"vocabs",
",",
"ValidationContext",
"context",
",",
"EPUBLocation",
"location",
")",
"{",
"return",
"Optional",
".",
... | Parses a single property value and report validation errors on the fly.
@param value
the value to parse.
@param vocabs
a map of prefix to vocabularies.
@param context
the validation context (report, locale, path, etc).
@param location
the location in the validated file.
@return an {@link Optional} containing the property if it was parsed
successfully or nothing if there was a parsing error | [
"Parses",
"a",
"single",
"property",
"value",
"and",
"report",
"validation",
"errors",
"on",
"the",
"fly",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java#L54-L60 |
30,911 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java | VocabUtil.parsePropertyList | public static Set<Property> parsePropertyList(String value, Map<String, ? extends Vocab> vocabs,
ValidationContext context, EPUBLocation location)
{
return parseProperties(value, vocabs, true, context, location);
} | java | public static Set<Property> parsePropertyList(String value, Map<String, ? extends Vocab> vocabs,
ValidationContext context, EPUBLocation location)
{
return parseProperties(value, vocabs, true, context, location);
} | [
"public",
"static",
"Set",
"<",
"Property",
">",
"parsePropertyList",
"(",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Vocab",
">",
"vocabs",
",",
"ValidationContext",
"context",
",",
"EPUBLocation",
"location",
")",
"{",
"return",
"p... | Parses a space-separated list of property values, and report validation
errors on the fly.
@param value
the value to parse.
@param vocabs
a map of prefix to vocabularies.
@param context
the validation context (report, locale, path, etc).
@param location
the location in the validated file.
@return | [
"Parses",
"a",
"space",
"-",
"separated",
"list",
"of",
"property",
"values",
"and",
"report",
"validation",
"errors",
"on",
"the",
"fly",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java#L76-L80 |
30,912 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java | VocabUtil.parsePrefixDeclaration | public static Map<String, Vocab> parsePrefixDeclaration(String value,
Map<String, ? extends Vocab> predefined, Map<String, ? extends Vocab> known,
Set<String> forbidden, Report report, EPUBLocation location)
{
Map<String, Vocab> vocabs = Maps.newHashMap(predefined);
Map<String, String> mappings = PrefixDeclarationParser.parsePrefixMappings(value, report,
location);
for (Entry<String, String> mapping : mappings.entrySet())
{
String prefix = mapping.getKey();
String uri = mapping.getValue();
if ("_".equals(prefix))
{
// must not define the '_' prefix
report.message(MessageId.OPF_007a, location);
}
else if (forbidden.contains(uri))
{
// must not declare a default vocab
report.message(MessageId.OPF_007b, location, prefix);
}
else
{
if (predefined.containsKey(prefix)
&& !Strings.nullToEmpty(predefined.get(prefix).getURI()).equals(uri))
{
// re-declaration of reserved prefix
report.message(MessageId.OPF_007, location, prefix);
}
Vocab vocab = known.get(uri);
vocabs.put(mapping.getKey(), (vocab == null) ? new UncheckedVocab(uri, prefix) : vocab);
}
}
return ImmutableMap.copyOf(vocabs);
} | java | public static Map<String, Vocab> parsePrefixDeclaration(String value,
Map<String, ? extends Vocab> predefined, Map<String, ? extends Vocab> known,
Set<String> forbidden, Report report, EPUBLocation location)
{
Map<String, Vocab> vocabs = Maps.newHashMap(predefined);
Map<String, String> mappings = PrefixDeclarationParser.parsePrefixMappings(value, report,
location);
for (Entry<String, String> mapping : mappings.entrySet())
{
String prefix = mapping.getKey();
String uri = mapping.getValue();
if ("_".equals(prefix))
{
// must not define the '_' prefix
report.message(MessageId.OPF_007a, location);
}
else if (forbidden.contains(uri))
{
// must not declare a default vocab
report.message(MessageId.OPF_007b, location, prefix);
}
else
{
if (predefined.containsKey(prefix)
&& !Strings.nullToEmpty(predefined.get(prefix).getURI()).equals(uri))
{
// re-declaration of reserved prefix
report.message(MessageId.OPF_007, location, prefix);
}
Vocab vocab = known.get(uri);
vocabs.put(mapping.getKey(), (vocab == null) ? new UncheckedVocab(uri, prefix) : vocab);
}
}
return ImmutableMap.copyOf(vocabs);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Vocab",
">",
"parsePrefixDeclaration",
"(",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Vocab",
">",
"predefined",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Vocab",
">",
"know... | Parses a prefix attribute value and returns a map of prefixes to
vocabularies, given a pre-existing set of reserved prefixes, known
vocabularies, and default vocabularies that cannot be re-declared.
@param value
the prefix declaration to parse.
@param predefined
a map of reserved prefixes to associated vocabularies.
@param known
a map of known URIs to known vocabularies.
@param forbidden
a set of URIs of default vocabularies that cannot be re-declared.
@param report
to report errors on the fly.
@param location
the location of the attribute in the source file.
@return | [
"Parses",
"a",
"prefix",
"attribute",
"value",
"and",
"returns",
"a",
"map",
"of",
"prefixes",
"to",
"vocabularies",
"given",
"a",
"pre",
"-",
"existing",
"set",
"of",
"reserved",
"prefixes",
"known",
"vocabularies",
"and",
"default",
"vocabularies",
"that",
"... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/VocabUtil.java#L174-L208 |
30,913 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/LinkedResources.java | LinkedResources.getById | public Optional<LinkedResource> getById(String id)
{
return Optional.fromNullable(resourcesById.get(id));
} | java | public Optional<LinkedResource> getById(String id)
{
return Optional.fromNullable(resourcesById.get(id));
} | [
"public",
"Optional",
"<",
"LinkedResource",
">",
"getById",
"(",
"String",
"id",
")",
"{",
"return",
"Optional",
".",
"fromNullable",
"(",
"resourcesById",
".",
"get",
"(",
"id",
")",
")",
";",
"}"
] | Search the linked resource with the given ID.
@param id
the ID of the resource to search, can be <code>null</code>.
@return An {@link Optional} containing the linked resource if found, or
{@link Optional#absent()} if not found. | [
"Search",
"the",
"linked",
"resource",
"with",
"the",
"given",
"ID",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/LinkedResources.java#L35-L38 |
30,914 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._dashmatch | private void _dashmatch() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '|');
}
builder.type = Type.DASHMATCH;
builder.append("|=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | java | private void _dashmatch() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '|');
}
builder.type = Type.DASHMATCH;
builder.append("|=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | [
"private",
"void",
"_dashmatch",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"debug",
")",
"{",
"checkState",
"(",
"reader",
".",
"curChar",
"==",
"'",
"'",
")",
";",
"}",
"builder",
".",
"type",
"=",
"Type",
".",
"DASHMATCH",
";",
"builder",
... | DASHMATCH |= | [
"DASHMATCH",
"|",
"="
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L451-L465 |
30,915 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._includes | private void _includes() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '~');
}
builder.type = Type.INCLUDES;
builder.append("~=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | java | private void _includes() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '~');
}
builder.type = Type.INCLUDES;
builder.append("~=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | [
"private",
"void",
"_includes",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"debug",
")",
"{",
"checkState",
"(",
"reader",
".",
"curChar",
"==",
"'",
"'",
")",
";",
"}",
"builder",
".",
"type",
"=",
"Type",
".",
"INCLUDES",
";",
"builder",
".... | INCLUDES ~= | [
"INCLUDES",
"~",
"="
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L470-L484 |
30,916 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._prefixmatch | private void _prefixmatch() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '^');
}
builder.type = Type.PREFIXMATCH;
builder.append("^=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | java | private void _prefixmatch() throws
IOException
{
if (debug)
{
checkState(reader.curChar == '^');
}
builder.type = Type.PREFIXMATCH;
builder.append("^=");
reader.next();
if (debug)
{
checkState(reader.curChar == '=');
}
} | [
"private",
"void",
"_prefixmatch",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"debug",
")",
"{",
"checkState",
"(",
"reader",
".",
"curChar",
"==",
"'",
"'",
")",
";",
"}",
"builder",
".",
"type",
"=",
"Type",
".",
"PREFIXMATCH",
";",
"builder"... | PREFIXMATCH ^= | [
"PREFIXMATCH",
"^",
"="
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L489-L503 |
30,917 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._comment | private void _comment() throws
IOException,
CssException
{
if (debug)
{
checkState(reader.curChar == '/' && reader.peek() == '*');
}
/*
* badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)* badcomment2
* \/\*[^*]*(\*+[^/*][^*]*)* comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/
*
*
* "comments can not nest" just close at first occurrence of comment
* close and let the grammar level handle reporting
*/
builder.type = Type.COMMENT;
reader.next(); // '*'
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch == -1)
{
builder.error(SCANNER_PREMATURE_EOF, reader);
reader.unread(ch, mark);
break;
}
else if (ch == '*' && reader.peek() == '/')
{
reader.next();
break;
}
else
{
builder.append(ch);
}
}
if (debug && builder.errors.size() < 1)
{
checkState('/' == reader.curChar && '*' == reader.prevChar);
}
} | java | private void _comment() throws
IOException,
CssException
{
if (debug)
{
checkState(reader.curChar == '/' && reader.peek() == '*');
}
/*
* badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)* badcomment2
* \/\*[^*]*(\*+[^/*][^*]*)* comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/
*
*
* "comments can not nest" just close at first occurrence of comment
* close and let the grammar level handle reporting
*/
builder.type = Type.COMMENT;
reader.next(); // '*'
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch == -1)
{
builder.error(SCANNER_PREMATURE_EOF, reader);
reader.unread(ch, mark);
break;
}
else if (ch == '*' && reader.peek() == '/')
{
reader.next();
break;
}
else
{
builder.append(ch);
}
}
if (debug && builder.errors.size() < 1)
{
checkState('/' == reader.curChar && '*' == reader.prevChar);
}
} | [
"private",
"void",
"_comment",
"(",
")",
"throws",
"IOException",
",",
"CssException",
"{",
"if",
"(",
"debug",
")",
"{",
"checkState",
"(",
"reader",
".",
"curChar",
"==",
"'",
"'",
"&&",
"reader",
".",
"peek",
"(",
")",
"==",
"'",
"'",
")",
";",
... | Builds a comment token, excluding the leading and trailing comment
tokens. | [
"Builds",
"a",
"comment",
"token",
"excluding",
"the",
"leading",
"and",
"trailing",
"comment",
"tokens",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L600-L647 |
30,918 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._quantity | private void _quantity() throws
IOException,
CssException
{
if (debug)
{
int ch = reader.peek();
checkState(QNTSTART.matches((char) ch) || isNextEscape());
checkState(builder.getLength() > 0
&& NUM.matches(builder.getLast()));
}
/*
* Assume we have a {num}{ident} instance (DIMEN), and then override
* that if a specific quantity literal is found.
*/
builder.type = Type.QNTY_DIMEN;
TokenBuilder suffix = new TokenBuilder(reader, errHandler, locale);
append(QNTSTART, suffix);
if (suffix.getLast() != '%')
{ // QNTSTART = NMSTART | '%'
append(NMCHAR, suffix);
}
if (suffix.getLength() > QNT_TOKEN_MAXLENGTH)
{
// longer than max length in quantities map
builder.append(suffix.toString());
return;
}
// shorter or equal to max length in quantities map
// we might have a more specific match
final int[] ident = suffix.toArray();
int[] match = null;
for (int[] test : quantities.keySet())
{
if (equals(ident, test, true))
{
builder.type = quantities.get(test);
match = test;
break;
}
}
if (builder.type == Type.QNTY_DIMEN)
{
builder.append(ident);
}
else
{
if (debug)
{
checkState(match != null);
}
builder.append(match);
}
} | java | private void _quantity() throws
IOException,
CssException
{
if (debug)
{
int ch = reader.peek();
checkState(QNTSTART.matches((char) ch) || isNextEscape());
checkState(builder.getLength() > 0
&& NUM.matches(builder.getLast()));
}
/*
* Assume we have a {num}{ident} instance (DIMEN), and then override
* that if a specific quantity literal is found.
*/
builder.type = Type.QNTY_DIMEN;
TokenBuilder suffix = new TokenBuilder(reader, errHandler, locale);
append(QNTSTART, suffix);
if (suffix.getLast() != '%')
{ // QNTSTART = NMSTART | '%'
append(NMCHAR, suffix);
}
if (suffix.getLength() > QNT_TOKEN_MAXLENGTH)
{
// longer than max length in quantities map
builder.append(suffix.toString());
return;
}
// shorter or equal to max length in quantities map
// we might have a more specific match
final int[] ident = suffix.toArray();
int[] match = null;
for (int[] test : quantities.keySet())
{
if (equals(ident, test, true))
{
builder.type = quantities.get(test);
match = test;
break;
}
}
if (builder.type == Type.QNTY_DIMEN)
{
builder.append(ident);
}
else
{
if (debug)
{
checkState(match != null);
}
builder.append(match);
}
} | [
"private",
"void",
"_quantity",
"(",
")",
"throws",
"IOException",
",",
"CssException",
"{",
"if",
"(",
"debug",
")",
"{",
"int",
"ch",
"=",
"reader",
".",
"peek",
"(",
")",
";",
"checkState",
"(",
"QNTSTART",
".",
"matches",
"(",
"(",
"char",
")",
"... | With incoming builder containing a valid NUMBER, and next char being a
valid QNTSTART, modify the type and append to the builder | [
"With",
"incoming",
"builder",
"containing",
"a",
"valid",
"NUMBER",
"and",
"next",
"char",
"being",
"a",
"valid",
"QNTSTART",
"modify",
"the",
"type",
"and",
"append",
"to",
"the",
"builder"
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L730-L790 |
30,919 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner._urange | private void _urange() throws
IOException,
CssException
{
if (debug)
{
checkArgument((reader.curChar == 'U' || reader.curChar == 'u')
&& reader.peek() == '+');
}
builder.type = Type.URANGE;
reader.next(); // '+'
List<Integer> cbuf = Lists.newArrayList();
int count = 0;
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch == -1)
{
reader.unread(ch, mark);
break;
}
if (URANGECHAR.matches((char) ch))
{
count = ch == '-' ? 0 : count + 1;
if (count == 7)
{
builder.error(CssErrorCode.SCANNER_ILLEGAL_URANGE, reader,
"U+" + toString(cbuf) + (char) ch);
}
cbuf.add(ch);
}
else
{
reader.unread(ch, mark);
break;
}
}
builder.append("U+");
builder.append(Ints.toArray(cbuf));
} | java | private void _urange() throws
IOException,
CssException
{
if (debug)
{
checkArgument((reader.curChar == 'U' || reader.curChar == 'u')
&& reader.peek() == '+');
}
builder.type = Type.URANGE;
reader.next(); // '+'
List<Integer> cbuf = Lists.newArrayList();
int count = 0;
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch == -1)
{
reader.unread(ch, mark);
break;
}
if (URANGECHAR.matches((char) ch))
{
count = ch == '-' ? 0 : count + 1;
if (count == 7)
{
builder.error(CssErrorCode.SCANNER_ILLEGAL_URANGE, reader,
"U+" + toString(cbuf) + (char) ch);
}
cbuf.add(ch);
}
else
{
reader.unread(ch, mark);
break;
}
}
builder.append("U+");
builder.append(Ints.toArray(cbuf));
} | [
"private",
"void",
"_urange",
"(",
")",
"throws",
"IOException",
",",
"CssException",
"{",
"if",
"(",
"debug",
")",
"{",
"checkArgument",
"(",
"(",
"reader",
".",
"curChar",
"==",
"'",
"'",
"||",
"reader",
".",
"curChar",
"==",
"'",
"'",
")",
"&&",
"... | Builds a UNICODE_RANGE token. | [
"Builds",
"a",
"UNICODE_RANGE",
"token",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L946-L992 |
30,920 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner.append | private void append(CharMatcher matcher, TokenBuilder builder)
throws
IOException,
CssException
{
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch > -1 && matcher.matches((char) ch))
{
builder.append(ch);
}
else if (ch == '\\')
{
Optional<CssEscape> escape = new CssEscape(reader, builder)
.create();
if (escape.isPresent())
{
reader.forward(escape.get().render(builder, matcher));
}
else
{
reader.unread(ch, mark);
break;
}
}
else
{
reader.unread(ch, mark);
break;
}
}
} | java | private void append(CharMatcher matcher, TokenBuilder builder)
throws
IOException,
CssException
{
while (true)
{
Mark mark = reader.mark();
int ch = reader.next();
if (ch > -1 && matcher.matches((char) ch))
{
builder.append(ch);
}
else if (ch == '\\')
{
Optional<CssEscape> escape = new CssEscape(reader, builder)
.create();
if (escape.isPresent())
{
reader.forward(escape.get().render(builder, matcher));
}
else
{
reader.unread(ch, mark);
break;
}
}
else
{
reader.unread(ch, mark);
break;
}
}
} | [
"private",
"void",
"append",
"(",
"CharMatcher",
"matcher",
",",
"TokenBuilder",
"builder",
")",
"throws",
"IOException",
",",
"CssException",
"{",
"while",
"(",
"true",
")",
"{",
"Mark",
"mark",
"=",
"reader",
".",
"mark",
"(",
")",
";",
"int",
"ch",
"=... | Parse forward and append to the supplied builder all characters that
match matcher, or until the next character is EOF. Escapes are included
verbatim if they don't match matcher, else literal. | [
"Parse",
"forward",
"and",
"append",
"to",
"the",
"supplied",
"builder",
"all",
"characters",
"that",
"match",
"matcher",
"or",
"until",
"the",
"next",
"character",
"is",
"EOF",
".",
"Escapes",
"are",
"included",
"verbatim",
"if",
"they",
"don",
"t",
"match"... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L1043-L1076 |
30,921 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner.forwardMatch | private boolean forwardMatch(String match, boolean ignoreCase, boolean resetOnTrue)
throws
IOException
{
Mark mark = reader.mark();
List<Integer> cbuf = Lists.newArrayList();
StringBuilder builder = new StringBuilder();
boolean result = true;
boolean seenChar = false;
while (true)
{
cbuf.add(reader.next());
char ch = (char) reader.curChar;
if (reader.curChar == -1)
{
result = false;
break;
}
else if (WHITESPACE.matches(ch))
{
if (seenChar)
{
builder.append(ch);
}
}
else
{
if (builder.length() == 0)
{
seenChar = true;
}
builder.append(ch);
int index = builder.length() - 1;
if (!ignoreCase
&& (builder.charAt(index) == match.charAt(index)))
{
result = false;
break;
}
if (ignoreCase
&& (Ascii.toLowerCase(builder.charAt(index)) != Ascii
.toLowerCase(match.charAt(index))))
{
result = false;
break;
}
}
if (builder.length() == match.length())
{
if (!match.equalsIgnoreCase(builder.toString()))
{
result = false;
}
break;
}
}
if (!result || resetOnTrue)
{
reader.unread(cbuf, mark);
}
return result;
} | java | private boolean forwardMatch(String match, boolean ignoreCase, boolean resetOnTrue)
throws
IOException
{
Mark mark = reader.mark();
List<Integer> cbuf = Lists.newArrayList();
StringBuilder builder = new StringBuilder();
boolean result = true;
boolean seenChar = false;
while (true)
{
cbuf.add(reader.next());
char ch = (char) reader.curChar;
if (reader.curChar == -1)
{
result = false;
break;
}
else if (WHITESPACE.matches(ch))
{
if (seenChar)
{
builder.append(ch);
}
}
else
{
if (builder.length() == 0)
{
seenChar = true;
}
builder.append(ch);
int index = builder.length() - 1;
if (!ignoreCase
&& (builder.charAt(index) == match.charAt(index)))
{
result = false;
break;
}
if (ignoreCase
&& (Ascii.toLowerCase(builder.charAt(index)) != Ascii
.toLowerCase(match.charAt(index))))
{
result = false;
break;
}
}
if (builder.length() == match.length())
{
if (!match.equalsIgnoreCase(builder.toString()))
{
result = false;
}
break;
}
}
if (!result || resetOnTrue)
{
reader.unread(cbuf, mark);
}
return result;
} | [
"private",
"boolean",
"forwardMatch",
"(",
"String",
"match",
",",
"boolean",
"ignoreCase",
",",
"boolean",
"resetOnTrue",
")",
"throws",
"IOException",
"{",
"Mark",
"mark",
"=",
"reader",
".",
"mark",
"(",
")",
";",
"List",
"<",
"Integer",
">",
"cbuf",
"=... | Check if a forward scan will equal given match string
@param match The string to match
@param ignoreCase Whether case should be ignored
@param resetOnTrue Whether the reader should be reset on found match
@throws IOException | [
"Check",
"if",
"a",
"forward",
"scan",
"will",
"equal",
"given",
"match",
"string"
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L1086-L1156 |
30,922 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssScanner.java | CssScanner.isNewLine | static int isNewLine(int[] chars)
{
checkArgument(chars.length > 1);
// nl \n|\r\n|\r|\f
if (chars[0] == '\r' && chars[1] == '\n')
{
return 2;
}
else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f')
{
return 1;
}
return 0;
} | java | static int isNewLine(int[] chars)
{
checkArgument(chars.length > 1);
// nl \n|\r\n|\r|\f
if (chars[0] == '\r' && chars[1] == '\n')
{
return 2;
}
else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f')
{
return 1;
}
return 0;
} | [
"static",
"int",
"isNewLine",
"(",
"int",
"[",
"]",
"chars",
")",
"{",
"checkArgument",
"(",
"chars",
".",
"length",
">",
"1",
")",
";",
"// nl \\n|\\r\\n|\\r|\\f",
"if",
"(",
"chars",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"chars",
"[",
"1",
"]",
"=... | Determine whether a sequence of chars begin with a CSS newline.
@param chars An array with minimum two characters
@return 0 if there is no newline, else 1 or 2, representing the newline
length in characters. | [
"Determine",
"whether",
"a",
"sequence",
"of",
"chars",
"begin",
"with",
"a",
"CSS",
"newline",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssScanner.java#L1241-L1254 |
30,923 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFHandler.java | OPFHandler.getItemById | public Optional<OPFItem> getItemById(String id)
{
return (items != null) ? items.getItemById(id) : Optional.<OPFItem> absent();
} | java | public Optional<OPFItem> getItemById(String id)
{
return (items != null) ? items.getItemById(id) : Optional.<OPFItem> absent();
} | [
"public",
"Optional",
"<",
"OPFItem",
">",
"getItemById",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"items",
"!=",
"null",
")",
"?",
"items",
".",
"getItemById",
"(",
"id",
")",
":",
"Optional",
".",
"<",
"OPFItem",
">",
"absent",
"(",
")",
";",
... | Search the list of item by ID.
@param id
the ID of the item to search
@return an {@link Optional} containing the item of the given ID if found,
or {@link Optional#absent()} | [
"Search",
"the",
"list",
"of",
"item",
"by",
"ID",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFHandler.java#L149-L152 |
30,924 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFHandler.java | OPFHandler.getItemByPath | public Optional<OPFItem> getItemByPath(String path)
{
return (items != null) ? items.getItemByPath(path) : Optional.<OPFItem> absent();
} | java | public Optional<OPFItem> getItemByPath(String path)
{
return (items != null) ? items.getItemByPath(path) : Optional.<OPFItem> absent();
} | [
"public",
"Optional",
"<",
"OPFItem",
">",
"getItemByPath",
"(",
"String",
"path",
")",
"{",
"return",
"(",
"items",
"!=",
"null",
")",
"?",
"items",
".",
"getItemByPath",
"(",
"path",
")",
":",
"Optional",
".",
"<",
"OPFItem",
">",
"absent",
"(",
")",... | Search the list of item by path.
@param id
the path of the item to search
@return an {@link Optional} containing the item of the given path if found,
or {@link Optional#absent()} | [
"Search",
"the",
"list",
"of",
"item",
"by",
"path",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFHandler.java#L162-L165 |
30,925 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFHandler.java | OPFHandler.buildItems | private void buildItems()
{
Preconditions.checkState(items == null);
items = OPFItems.build(itemBuilders.values(), spineIDs);
for (OPFItem item : items.getItems())
{
reportItem(item);
}
} | java | private void buildItems()
{
Preconditions.checkState(items == null);
items = OPFItems.build(itemBuilders.values(), spineIDs);
for (OPFItem item : items.getItems())
{
reportItem(item);
}
} | [
"private",
"void",
"buildItems",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"items",
"==",
"null",
")",
";",
"items",
"=",
"OPFItems",
".",
"build",
"(",
"itemBuilders",
".",
"values",
"(",
")",
",",
"spineIDs",
")",
";",
"for",
"(",
"OPFI... | Build the final items from the item builders | [
"Build",
"the",
"final",
"items",
"from",
"the",
"item",
"builders"
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFHandler.java#L671-L680 |
30,926 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFHandler.java | OPFHandler.reportItem | protected void reportItem(OPFItem item)
{
if (item.isInSpine())
{
report.info(item.getPath(), FeatureEnum.IS_SPINEITEM, "true");
report.info(item.getPath(), FeatureEnum.IS_LINEAR, String.valueOf(item.isLinear()));
}
if (item.isNcx())
{
report.info(item.getPath(), FeatureEnum.HAS_NCX, "true");
if (!item.getMimeType().equals("application/x-dtbncx+xml"))
{
report.message(MessageId.OPF_050,
EPUBLocation.create(path, item.getLineNumber(), item.getColumnNumber()));
}
}
} | java | protected void reportItem(OPFItem item)
{
if (item.isInSpine())
{
report.info(item.getPath(), FeatureEnum.IS_SPINEITEM, "true");
report.info(item.getPath(), FeatureEnum.IS_LINEAR, String.valueOf(item.isLinear()));
}
if (item.isNcx())
{
report.info(item.getPath(), FeatureEnum.HAS_NCX, "true");
if (!item.getMimeType().equals("application/x-dtbncx+xml"))
{
report.message(MessageId.OPF_050,
EPUBLocation.create(path, item.getLineNumber(), item.getColumnNumber()));
}
}
} | [
"protected",
"void",
"reportItem",
"(",
"OPFItem",
"item",
")",
"{",
"if",
"(",
"item",
".",
"isInSpine",
"(",
")",
")",
"{",
"report",
".",
"info",
"(",
"item",
".",
"getPath",
"(",
")",
",",
"FeatureEnum",
".",
"IS_SPINEITEM",
",",
"\"true\"",
")",
... | Report features or messages for a given item.
@param item
the item to report. | [
"Report",
"features",
"or",
"messages",
"for",
"a",
"given",
"item",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFHandler.java#L688-L704 |
30,927 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssEscape.java | CssEscape.render | int render(TokenBuilder builder, CharMatcher asLiteral)
{
char ch = (char) character;
if (asLiteral.matches(ch))
{
builder.append(ch);
}
else
{
//TODO could normalize space end chars
builder.append(sequence);
}
return sequence.length() - 1;
} | java | int render(TokenBuilder builder, CharMatcher asLiteral)
{
char ch = (char) character;
if (asLiteral.matches(ch))
{
builder.append(ch);
}
else
{
//TODO could normalize space end chars
builder.append(sequence);
}
return sequence.length() - 1;
} | [
"int",
"render",
"(",
"TokenBuilder",
"builder",
",",
"CharMatcher",
"asLiteral",
")",
"{",
"char",
"ch",
"=",
"(",
"char",
")",
"character",
";",
"if",
"(",
"asLiteral",
".",
"matches",
"(",
"ch",
")",
")",
"{",
"builder",
".",
"append",
"(",
"ch",
... | Render this escape.
@param builder The TokenBuilder to render into
@param asLiteral If given matcher matches this escapes literal, then render as literal, else as escape.
@return the length of the token in the input character stream | [
"Render",
"this",
"escape",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssEscape.java#L178-L191 |
30,928 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.parseStyleAttribute | public void parseStyleAttribute(final Reader reader, String systemID, final CssErrorHandler err, final CssContentHandler doc) throws
IOException,
CssException
{
CssTokenIterator iter = scan(reader, systemID, err);
doc.startDocument();
while (iter.hasNext())
{
CssToken tk = iter.next();
if(MATCH_SEMI.apply(tk))
{
continue; //starting with ';' is allowed, Issue 238
}
try
{
CssDeclaration decl = handleDeclaration(tk, iter, doc, err, true);
if (decl != null)
{
doc.declaration(decl);
}
else
{
// #handleDeclaration has issued errors
return;
}
}
catch (PrematureEOFException te)
{
// The subroutines report premature EOF to ErrHandler
// on occurrence; if the listener rethrows it will
// be a CssException so we don't catch it here.
break;
}
}
doc.endDocument();
} | java | public void parseStyleAttribute(final Reader reader, String systemID, final CssErrorHandler err, final CssContentHandler doc) throws
IOException,
CssException
{
CssTokenIterator iter = scan(reader, systemID, err);
doc.startDocument();
while (iter.hasNext())
{
CssToken tk = iter.next();
if(MATCH_SEMI.apply(tk))
{
continue; //starting with ';' is allowed, Issue 238
}
try
{
CssDeclaration decl = handleDeclaration(tk, iter, doc, err, true);
if (decl != null)
{
doc.declaration(decl);
}
else
{
// #handleDeclaration has issued errors
return;
}
}
catch (PrematureEOFException te)
{
// The subroutines report premature EOF to ErrHandler
// on occurrence; if the listener rethrows it will
// be a CssException so we don't catch it here.
break;
}
}
doc.endDocument();
} | [
"public",
"void",
"parseStyleAttribute",
"(",
"final",
"Reader",
"reader",
",",
"String",
"systemID",
",",
"final",
"CssErrorHandler",
"err",
",",
"final",
"CssContentHandler",
"doc",
")",
"throws",
"IOException",
",",
"CssException",
"{",
"CssTokenIterator",
"iter"... | Parse a CSS style attribute. | [
"Parse",
"a",
"CSS",
"style",
"attribute",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L160-L197 |
30,929 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.handleRuleSet | private void handleRuleSet(CssToken start, final CssTokenIterator iter, final CssContentHandler doc,
CssErrorHandler err) throws
CssException
{
char errChar = '{';
try
{
List<CssSelector> selectors = handleSelectors(start, iter, err);
errChar = '}';
if (selectors == null)
{
// handleSelectors() has issued errors, we forward
iter.next(MATCH_CLOSEBRACE);
return;
}
if (debug)
{
checkState(iter.last.getChar() == '{');
checkState(!selectors.isEmpty());
}
doc.selectors(selectors);
handleDeclarationBlock(iter.next(), iter, doc, err);
doc.endSelectors(selectors);
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "'" + errChar + "'"));
throw new PrematureEOFException();
}
if (debug)
{
checkState(iter.last.getChar() == '}');
}
} | java | private void handleRuleSet(CssToken start, final CssTokenIterator iter, final CssContentHandler doc,
CssErrorHandler err) throws
CssException
{
char errChar = '{';
try
{
List<CssSelector> selectors = handleSelectors(start, iter, err);
errChar = '}';
if (selectors == null)
{
// handleSelectors() has issued errors, we forward
iter.next(MATCH_CLOSEBRACE);
return;
}
if (debug)
{
checkState(iter.last.getChar() == '{');
checkState(!selectors.isEmpty());
}
doc.selectors(selectors);
handleDeclarationBlock(iter.next(), iter, doc, err);
doc.endSelectors(selectors);
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "'" + errChar + "'"));
throw new PrematureEOFException();
}
if (debug)
{
checkState(iter.last.getChar() == '}');
}
} | [
"private",
"void",
"handleRuleSet",
"(",
"CssToken",
"start",
",",
"final",
"CssTokenIterator",
"iter",
",",
"final",
"CssContentHandler",
"doc",
",",
"CssErrorHandler",
"err",
")",
"throws",
"CssException",
"{",
"char",
"errChar",
"=",
"'",
"'",
";",
"try",
"... | With the start token expected to be the first token of a selector group,
create and issue the group, then invoke handleDeclarationBlock. At exit
the last token returned from the iterator is expected to be '}'. | [
"With",
"the",
"start",
"token",
"expected",
"to",
"be",
"the",
"first",
"token",
"of",
"a",
"selector",
"group",
"create",
"and",
"issue",
"the",
"group",
"then",
"invoke",
"handleDeclarationBlock",
".",
"At",
"exit",
"the",
"last",
"token",
"returned",
"fr... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L222-L262 |
30,930 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.handleDeclarationBlock | private void handleDeclarationBlock(CssToken start, CssTokenIterator iter,
final CssContentHandler doc, CssErrorHandler err) throws
CssException
{
while (true)
{
if (MATCH_CLOSEBRACE.apply(start))
{
return;
}
CssDeclaration decl = handleDeclaration(start, iter, doc, err, false);
try
{
if (decl != null)
{
doc.declaration(decl);
if (debug)
{
checkState(MATCH_SEMI_CLOSEBRACE.apply(iter.last));
}
// continue or return: we may be at "; next decl" or "}" or ";}"
if (MATCH_CLOSEBRACE.apply(iter.last))
{
return;
}
else if (MATCH_SEMI.apply(iter.last) && MATCH_CLOSEBRACE.apply(iter.peek()))
{
iter.next();
return;
}
else
{
if (debug)
{
checkState(MATCH_SEMI.apply(iter.last));
}
// we have ';', expect another decl
start = iter.next(); // first token after ';'
}
}
else
{
// #handleDeclaration returned null to signal error
// #handleDeclaration has issued errors, we forward
start = iter.next(MATCH_SEMI_CLOSEBRACE);
if (MATCH_SEMI.apply(start))
{
start = iter.next();
}
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "';' " + messages.get("or") + " '}'"));
throw new PrematureEOFException();
}
}
} | java | private void handleDeclarationBlock(CssToken start, CssTokenIterator iter,
final CssContentHandler doc, CssErrorHandler err) throws
CssException
{
while (true)
{
if (MATCH_CLOSEBRACE.apply(start))
{
return;
}
CssDeclaration decl = handleDeclaration(start, iter, doc, err, false);
try
{
if (decl != null)
{
doc.declaration(decl);
if (debug)
{
checkState(MATCH_SEMI_CLOSEBRACE.apply(iter.last));
}
// continue or return: we may be at "; next decl" or "}" or ";}"
if (MATCH_CLOSEBRACE.apply(iter.last))
{
return;
}
else if (MATCH_SEMI.apply(iter.last) && MATCH_CLOSEBRACE.apply(iter.peek()))
{
iter.next();
return;
}
else
{
if (debug)
{
checkState(MATCH_SEMI.apply(iter.last));
}
// we have ';', expect another decl
start = iter.next(); // first token after ';'
}
}
else
{
// #handleDeclaration returned null to signal error
// #handleDeclaration has issued errors, we forward
start = iter.next(MATCH_SEMI_CLOSEBRACE);
if (MATCH_SEMI.apply(start))
{
start = iter.next();
}
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "';' " + messages.get("or") + " '}'"));
throw new PrematureEOFException();
}
}
} | [
"private",
"void",
"handleDeclarationBlock",
"(",
"CssToken",
"start",
",",
"CssTokenIterator",
"iter",
",",
"final",
"CssContentHandler",
"doc",
",",
"CssErrorHandler",
"err",
")",
"throws",
"CssException",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"MATCH... | With start token being the first non-ignorable token inside the declaration
block, iterate issuing CssDeclaration objects until the block ends. | [
"With",
"start",
"token",
"being",
"the",
"first",
"non",
"-",
"ignorable",
"token",
"inside",
"the",
"declaration",
"block",
"iterate",
"issuing",
"CssDeclaration",
"objects",
"until",
"the",
"block",
"ends",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L268-L329 |
30,931 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.handleDeclaration | private CssDeclaration handleDeclaration(CssToken name, CssTokenIterator iter,
CssContentHandler doc, CssErrorHandler err, boolean isStyleAttribute) throws
CssException
{
if (name.type != CssToken.Type.IDENT)
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location,
messages.getLocale(), name.getChars(), messages.get("a_property_name")));
return null;
}
CssDeclaration declaration = new CssDeclaration(name.getChars(), name.location);
try
{
if (!MATCH_COLON.apply(iter.next()))
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location,
messages.getLocale(), iter.last.getChars(), ":"));
return null;
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), ":"));
throw new PrematureEOFException();
}
try
{
while (true)
{
CssToken value = iter.next();
if (MATCH_SEMI_CLOSEBRACE.apply(value))
{
if (declaration.components.size() < 1)
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, iter.last.location,
messages.getLocale(), value.getChar(), messages.get("a_property_value")));
return null;
}
else
{
return declaration;
}
}
else
{
if (!handlePropertyValue(declaration, value, iter, isStyleAttribute))
{
err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN, iter.last.location,
messages.getLocale(), iter.last.getChars()));
return null;
}
else
{
if (isStyleAttribute && !iter.hasNext())
{
return declaration;
}
}
}
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "';' " + messages.get("or") + " '}'"));
throw new PrematureEOFException();
}
} | java | private CssDeclaration handleDeclaration(CssToken name, CssTokenIterator iter,
CssContentHandler doc, CssErrorHandler err, boolean isStyleAttribute) throws
CssException
{
if (name.type != CssToken.Type.IDENT)
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location,
messages.getLocale(), name.getChars(), messages.get("a_property_name")));
return null;
}
CssDeclaration declaration = new CssDeclaration(name.getChars(), name.location);
try
{
if (!MATCH_COLON.apply(iter.next()))
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location,
messages.getLocale(), iter.last.getChars(), ":"));
return null;
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), ":"));
throw new PrematureEOFException();
}
try
{
while (true)
{
CssToken value = iter.next();
if (MATCH_SEMI_CLOSEBRACE.apply(value))
{
if (declaration.components.size() < 1)
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, iter.last.location,
messages.getLocale(), value.getChar(), messages.get("a_property_value")));
return null;
}
else
{
return declaration;
}
}
else
{
if (!handlePropertyValue(declaration, value, iter, isStyleAttribute))
{
err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN, iter.last.location,
messages.getLocale(), iter.last.getChars()));
return null;
}
else
{
if (isStyleAttribute && !iter.hasNext())
{
return declaration;
}
}
}
}
}
catch (NoSuchElementException nse)
{
err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location,
messages.getLocale(), "';' " + messages.get("or") + " '}'"));
throw new PrematureEOFException();
}
} | [
"private",
"CssDeclaration",
"handleDeclaration",
"(",
"CssToken",
"name",
",",
"CssTokenIterator",
"iter",
",",
"CssContentHandler",
"doc",
",",
"CssErrorHandler",
"err",
",",
"boolean",
"isStyleAttribute",
")",
"throws",
"CssException",
"{",
"if",
"(",
"name",
"."... | With start expected to be an IDENT token representing the property name,
build the declaration and return after hitting ';' or '}'. On error,
issue to errhandler, return null, caller forwards. | [
"With",
"start",
"expected",
"to",
"be",
"an",
"IDENT",
"token",
"representing",
"the",
"property",
"name",
"build",
"the",
"declaration",
"and",
"return",
"after",
"hitting",
";",
"or",
"}",
".",
"On",
"error",
"issue",
"to",
"errhandler",
"return",
"null",... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L336-L409 |
30,932 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.handlePropertyValue | private boolean handlePropertyValue(CssDeclaration declaration, CssToken start,
CssTokenIterator iter, boolean isStyleAttribute)
{
// we dont worry about EOF here, throw to caller
while (true)
{
if (start.type == CssToken.Type.IMPORTANT)
{
declaration.important = true;
}
else
{
CssConstruct cc = CssConstructFactory.create(
start, iter, MATCH_SEMI_CLOSEBRACE,
ContextRestrictions.PROPERTY_VALUE);
if (cc == null)
{
return false;
}
else
{
declaration.components.add(cc);
}
}
//if isStyleAttribute, then parse as declaration-list grammar,
//i.e. no braces
if ((isStyleAttribute && !iter.hasNext())
|| (MATCH_SEMI.apply(iter.peek()))
|| (!isStyleAttribute && MATCH_CLOSEBRACE.apply(iter.peek())))
{
return declaration.components.size() > 0;
}
else
{
start = iter.next();
}
}
} | java | private boolean handlePropertyValue(CssDeclaration declaration, CssToken start,
CssTokenIterator iter, boolean isStyleAttribute)
{
// we dont worry about EOF here, throw to caller
while (true)
{
if (start.type == CssToken.Type.IMPORTANT)
{
declaration.important = true;
}
else
{
CssConstruct cc = CssConstructFactory.create(
start, iter, MATCH_SEMI_CLOSEBRACE,
ContextRestrictions.PROPERTY_VALUE);
if (cc == null)
{
return false;
}
else
{
declaration.components.add(cc);
}
}
//if isStyleAttribute, then parse as declaration-list grammar,
//i.e. no braces
if ((isStyleAttribute && !iter.hasNext())
|| (MATCH_SEMI.apply(iter.peek()))
|| (!isStyleAttribute && MATCH_CLOSEBRACE.apply(iter.peek())))
{
return declaration.components.size() > 0;
}
else
{
start = iter.next();
}
}
} | [
"private",
"boolean",
"handlePropertyValue",
"(",
"CssDeclaration",
"declaration",
",",
"CssToken",
"start",
",",
"CssTokenIterator",
"iter",
",",
"boolean",
"isStyleAttribute",
")",
"{",
"// we dont worry about EOF here, throw to caller",
"while",
"(",
"true",
")",
"{",
... | Append property value components to declaration.value, return false if
fail with iter.last at the the token which caused the fail. | [
"Append",
"property",
"value",
"components",
"to",
"declaration",
".",
"value",
"return",
"false",
"if",
"fail",
"with",
"iter",
".",
"last",
"at",
"the",
"the",
"token",
"which",
"caused",
"the",
"fail",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L415-L454 |
30,933 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.handleAtRuleParam | private CssConstruct handleAtRuleParam(CssToken start, CssTokenIterator iter,
CssContentHandler doc, CssErrorHandler err)
{
return CssConstructFactory.create(start, iter, MATCH_SEMI_OPENBRACE,
ContextRestrictions.ATRULE_PARAM);
} | java | private CssConstruct handleAtRuleParam(CssToken start, CssTokenIterator iter,
CssContentHandler doc, CssErrorHandler err)
{
return CssConstructFactory.create(start, iter, MATCH_SEMI_OPENBRACE,
ContextRestrictions.ATRULE_PARAM);
} | [
"private",
"CssConstruct",
"handleAtRuleParam",
"(",
"CssToken",
"start",
",",
"CssTokenIterator",
"iter",
",",
"CssContentHandler",
"doc",
",",
"CssErrorHandler",
"err",
")",
"{",
"return",
"CssConstructFactory",
".",
"create",
"(",
"start",
",",
"iter",
",",
"MA... | With inparam token being the first token of an atrule param, create the
construct and return it.
@return A CssConstruct, or null if fail. | [
"With",
"inparam",
"token",
"being",
"the",
"first",
"token",
"of",
"an",
"atrule",
"param",
"create",
"the",
"construct",
"and",
"return",
"it",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L655-L660 |
30,934 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/util/DateParser.java | DateParser.checkValueAndNext | private boolean checkValueAndNext(StringTokenizer st, String token) throws
InvalidDateException
{
if (!st.hasMoreTokens())
{
return false;
}
String t = st.nextToken();
if (!t.equals(token))
{
throw new InvalidDateException("Unexpected: " + t);
}
if (!st.hasMoreTokens())
{
throw new InvalidDateException("Incomplete date.");
}
return true;
} | java | private boolean checkValueAndNext(StringTokenizer st, String token) throws
InvalidDateException
{
if (!st.hasMoreTokens())
{
return false;
}
String t = st.nextToken();
if (!t.equals(token))
{
throw new InvalidDateException("Unexpected: " + t);
}
if (!st.hasMoreTokens())
{
throw new InvalidDateException("Incomplete date.");
}
return true;
} | [
"private",
"boolean",
"checkValueAndNext",
"(",
"StringTokenizer",
"st",
",",
"String",
"token",
")",
"throws",
"InvalidDateException",
"{",
"if",
"(",
"!",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"t",
"=",
"s... | Check if the next token, if exists, has a given value and that the
provided string tokenizer has more tokens after that. It consumes
the token checked against the expected value from the string tokenizer.
@param st The StringTokenizer to check.
@param token The value expected for the next token.
@return <code>true</code> if the token matches the value and there are more tokens.
<code>false</code> if there are no more tokens and we do not have a token to check.
@throws InvalidDateException If the token does not match the value or if there are no
more tokens after the token that matches the expected value. | [
"Check",
"if",
"the",
"next",
"token",
"if",
"exists",
"has",
"a",
"given",
"value",
"and",
"that",
"the",
"provided",
"string",
"tokenizer",
"has",
"more",
"tokens",
"after",
"that",
".",
"It",
"consumes",
"the",
"token",
"checked",
"against",
"the",
"exp... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/util/DateParser.java#L106-L123 |
30,935 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/ops/OPSHandler.java | OPSHandler.checkDependentCondition | protected void checkDependentCondition(MessageId id, boolean condition1, boolean condition2,
EPUBLocation location)
{
if (condition1 && !condition2)
{
report.message(id, location);
}
} | java | protected void checkDependentCondition(MessageId id, boolean condition1, boolean condition2,
EPUBLocation location)
{
if (condition1 && !condition2)
{
report.message(id, location);
}
} | [
"protected",
"void",
"checkDependentCondition",
"(",
"MessageId",
"id",
",",
"boolean",
"condition1",
",",
"boolean",
"condition2",
",",
"EPUBLocation",
"location",
")",
"{",
"if",
"(",
"condition1",
"&&",
"!",
"condition2",
")",
"{",
"report",
".",
"message",
... | condition2 is false. | [
"condition2",
"is",
"false",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/ops/OPSHandler.java#L544-L551 |
30,936 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/EnumVocab.java | EnumVocab.getName | public String getName(P property)
{
Preconditions.checkNotNull(property);
return converter.convert(property);
} | java | public String getName(P property)
{
Preconditions.checkNotNull(property);
return converter.convert(property);
} | [
"public",
"String",
"getName",
"(",
"P",
"property",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"property",
")",
";",
"return",
"converter",
".",
"convert",
"(",
"property",
")",
";",
"}"
] | Returns the property name for the given enum item contained in this
vocabulary.
@param property
the property to get the name of, must not be <code>null</code>
@return the name of <code>property</code>. | [
"Returns",
"the",
"property",
"name",
"for",
"the",
"given",
"enum",
"item",
"contained",
"in",
"this",
"vocabulary",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/EnumVocab.java#L161-L165 |
30,937 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/EnumVocab.java | EnumVocab.getNames | public Collection<String> getNames(Collection<P> properties)
{
Preconditions.checkNotNull(properties);
return Collections2.transform(properties, new Function<P, String>()
{
@Override
public String apply(P property)
{
return converter.convert(property);
}
});
} | java | public Collection<String> getNames(Collection<P> properties)
{
Preconditions.checkNotNull(properties);
return Collections2.transform(properties, new Function<P, String>()
{
@Override
public String apply(P property)
{
return converter.convert(property);
}
});
} | [
"public",
"Collection",
"<",
"String",
">",
"getNames",
"(",
"Collection",
"<",
"P",
">",
"properties",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"properties",
")",
";",
"return",
"Collections2",
".",
"transform",
"(",
"properties",
",",
"new",
"F... | Returns the property names of the given enum items contained in this
vocabulary.
@param properties
a collection of properties to get the name of, must not be
<code>null</code>
@return the collection of the names of properties in <code>properties</code>. | [
"Returns",
"the",
"property",
"names",
"of",
"the",
"given",
"enum",
"items",
"contained",
"in",
"this",
"vocabulary",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/EnumVocab.java#L176-L187 |
30,938 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java | LocalizedMessages.getInstance | public static LocalizedMessages getInstance(Locale locale)
{
LocalizedMessages instance = null;
if (locale == null)
{
locale = Locale.getDefault();
}
String localeKey = locale.getLanguage();
if (localizedMessages.containsKey(localeKey))
{
instance = localizedMessages.get(localeKey);
}
else
{
synchronized (LocalizedMessages.class)
{
if (instance == null)
{
instance = new LocalizedMessages(locale);
localizedMessages.put(localeKey, instance);
}
}
}
return instance;
} | java | public static LocalizedMessages getInstance(Locale locale)
{
LocalizedMessages instance = null;
if (locale == null)
{
locale = Locale.getDefault();
}
String localeKey = locale.getLanguage();
if (localizedMessages.containsKey(localeKey))
{
instance = localizedMessages.get(localeKey);
}
else
{
synchronized (LocalizedMessages.class)
{
if (instance == null)
{
instance = new LocalizedMessages(locale);
localizedMessages.put(localeKey, instance);
}
}
}
return instance;
} | [
"public",
"static",
"LocalizedMessages",
"getInstance",
"(",
"Locale",
"locale",
")",
"{",
"LocalizedMessages",
"instance",
"=",
"null",
";",
"if",
"(",
"locale",
"==",
"null",
")",
"{",
"locale",
"=",
"Locale",
".",
"getDefault",
"(",
")",
";",
"}",
"Stri... | Provides messages for the given locale.
@param locale The locale. If null or unsupported, will use the default
locale instead.
@return Localized messages. | [
"Provides",
"messages",
"for",
"the",
"given",
"locale",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java#L49-L76 |
30,939 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java | LocalizedMessages.getMessage | public Message getMessage(MessageId id)
{
// Performance note: this method uses a lazy initialization pattern. When
// a MessageId is first requested, we fetch the data from the ResourceBundle
// and create a new Message object, which is then cached. On the next
// request, we'll use the cached version instead.
Message message;
if (cachedMessages.containsKey(id))
{
message = cachedMessages.get(id);
}
else
{
message = new Message(id, defaultSeverities.get(id), getMessageAsString(id), getSuggestion(id));
cachedMessages.put(id, message);
}
return message;
} | java | public Message getMessage(MessageId id)
{
// Performance note: this method uses a lazy initialization pattern. When
// a MessageId is first requested, we fetch the data from the ResourceBundle
// and create a new Message object, which is then cached. On the next
// request, we'll use the cached version instead.
Message message;
if (cachedMessages.containsKey(id))
{
message = cachedMessages.get(id);
}
else
{
message = new Message(id, defaultSeverities.get(id), getMessageAsString(id), getSuggestion(id));
cachedMessages.put(id, message);
}
return message;
} | [
"public",
"Message",
"getMessage",
"(",
"MessageId",
"id",
")",
"{",
"// Performance note: this method uses a lazy initialization pattern. When",
"// a MessageId is first requested, we fetch the data from the ResourceBundle",
"// and create a new Message object, which is then cached. On the next... | Gets the message for the given id.
@param id
@return A Message object, using the localized string if necessary. | [
"Gets",
"the",
"message",
"for",
"the",
"given",
"id",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java#L84-L102 |
30,940 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java | LocalizedMessages.getSuggestion | public String getSuggestion(MessageId id, String key)
{
String messageKey = id.name() + "_SUG." + key;
String messageDefaultKey = id.name() + "_SUG.default";
return bundle.containsKey(messageKey) ? getStringFromBundle(messageKey)
: (bundle.containsKey(messageDefaultKey) ? getStringFromBundle(messageDefaultKey)
: getSuggestion(id));
} | java | public String getSuggestion(MessageId id, String key)
{
String messageKey = id.name() + "_SUG." + key;
String messageDefaultKey = id.name() + "_SUG.default";
return bundle.containsKey(messageKey) ? getStringFromBundle(messageKey)
: (bundle.containsKey(messageDefaultKey) ? getStringFromBundle(messageDefaultKey)
: getSuggestion(id));
} | [
"public",
"String",
"getSuggestion",
"(",
"MessageId",
"id",
",",
"String",
"key",
")",
"{",
"String",
"messageKey",
"=",
"id",
".",
"name",
"(",
")",
"+",
"\"_SUG.\"",
"+",
"key",
";",
"String",
"messageDefaultKey",
"=",
"id",
".",
"name",
"(",
")",
"... | Returns the suggestion message for the given message ID and key.
In other words, for a message ID of `XXX_NNN`, and a key `key`,
returns the bundle message named `XXX_NNN_SUG.key`.
If the suggestion key is not found, returns the bundle message
named `XXX_NNN_SUG.default`.
If this latter is not found, returns the bundle message nameed
`XXX_NNN_SUG`.
@param id a message ID
@param key the key of a specific suggestion string
@return the associated suggestion string | [
"Returns",
"the",
"suggestion",
"message",
"for",
"the",
"given",
"message",
"ID",
"and",
"key",
".",
"In",
"other",
"words",
"for",
"a",
"message",
"ID",
"of",
"XXX_NNN",
"and",
"a",
"key",
"key",
"returns",
"the",
"bundle",
"message",
"named",
"XXX_NNN_S... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java#L164-L171 |
30,941 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFItems.java | OPFItems.getItemById | public Optional<OPFItem> getItemById(String id)
{
return Optional.fromNullable(itemsById.get(id));
} | java | public Optional<OPFItem> getItemById(String id)
{
return Optional.fromNullable(itemsById.get(id));
} | [
"public",
"Optional",
"<",
"OPFItem",
">",
"getItemById",
"(",
"String",
"id",
")",
"{",
"return",
"Optional",
".",
"fromNullable",
"(",
"itemsById",
".",
"get",
"(",
"id",
")",
")",
";",
"}"
] | Search the item with the given ID.
@param id
the ID of the item to search, can be <code>null</code>.
@return An {@link Optional} containing the item if found, or
{@link Optional#absent()} if not found. | [
"Search",
"the",
"item",
"with",
"the",
"given",
"ID",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFItems.java#L37-L40 |
30,942 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/OPFItems.java | OPFItems.getItemByPath | public Optional<OPFItem> getItemByPath(String path)
{
return Optional.fromNullable(itemsByPath.get(path));
} | java | public Optional<OPFItem> getItemByPath(String path)
{
return Optional.fromNullable(itemsByPath.get(path));
} | [
"public",
"Optional",
"<",
"OPFItem",
">",
"getItemByPath",
"(",
"String",
"path",
")",
"{",
"return",
"Optional",
".",
"fromNullable",
"(",
"itemsByPath",
".",
"get",
"(",
"path",
")",
")",
";",
"}"
] | Search the item with the given path.
@param id
the path of the item to search, can be <code>null</code>.
@return An {@link Optional} containing the item if found, or
{@link Optional#absent()} if not found. | [
"Search",
"the",
"item",
"with",
"the",
"given",
"path",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/OPFItems.java#L50-L53 |
30,943 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.next | int next() throws
IOException
{
prevChar = curChar;
checkState(prevChar > -1);
if (pos < buf.length)
{
curChar = buf[pos++];
}
else
{
curChar = in.read();
}
offset++;
/*
* Handle line and col
* lf=\n, cr=\r
*/
if (curChar == '\r' || curChar == '\n')
{
if (curChar == '\n' && prevChar == '\r')
{
//second char in a windows CR+LF
}
else
{
prevLine = line;
line++;
}
}
else if (prevLine < line)
{
col = 1;
prevLine = line;
}
else
{
if (prevChar != 0)
{
col++;
}
}
return curChar;
} | java | int next() throws
IOException
{
prevChar = curChar;
checkState(prevChar > -1);
if (pos < buf.length)
{
curChar = buf[pos++];
}
else
{
curChar = in.read();
}
offset++;
/*
* Handle line and col
* lf=\n, cr=\r
*/
if (curChar == '\r' || curChar == '\n')
{
if (curChar == '\n' && prevChar == '\r')
{
//second char in a windows CR+LF
}
else
{
prevLine = line;
line++;
}
}
else if (prevLine < line)
{
col = 1;
prevLine = line;
}
else
{
if (prevChar != 0)
{
col++;
}
}
return curChar;
} | [
"int",
"next",
"(",
")",
"throws",
"IOException",
"{",
"prevChar",
"=",
"curChar",
";",
"checkState",
"(",
"prevChar",
">",
"-",
"1",
")",
";",
"if",
"(",
"pos",
"<",
"buf",
".",
"length",
")",
"{",
"curChar",
"=",
"buf",
"[",
"pos",
"++",
"]",
"... | Returns the next character in the stream and advances the readers
position. If there are no more characters, -1 is returned the first time
this method is invoked in that state; multiple invocations at EOF will
yield an IllegalStateException. | [
"Returns",
"the",
"next",
"character",
"in",
"the",
"stream",
"and",
"advances",
"the",
"readers",
"position",
".",
"If",
"there",
"are",
"no",
"more",
"characters",
"-",
"1",
"is",
"returned",
"the",
"first",
"time",
"this",
"method",
"is",
"invoked",
"in... | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L104-L152 |
30,944 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.peek | int peek() throws
IOException
{
Mark m = mark();
int ch = next();
unread(ch, m);
return ch;
} | java | int peek() throws
IOException
{
Mark m = mark();
int ch = next();
unread(ch, m);
return ch;
} | [
"int",
"peek",
"(",
")",
"throws",
"IOException",
"{",
"Mark",
"m",
"=",
"mark",
"(",
")",
";",
"int",
"ch",
"=",
"next",
"(",
")",
";",
"unread",
"(",
"ch",
",",
"m",
")",
";",
"return",
"ch",
";",
"}"
] | Returns the next character in the stream without advancing the readers
position. If there are no more characters, -1 is returned. | [
"Returns",
"the",
"next",
"character",
"in",
"the",
"stream",
"without",
"advancing",
"the",
"readers",
"position",
".",
"If",
"there",
"are",
"no",
"more",
"characters",
"-",
"1",
"is",
"returned",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L158-L165 |
30,945 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.peek | int[] peek(int n) throws
IOException
{
int[] buf = new int[n];
Mark m = mark();
boolean seenEOF = false;
for (int i = 0; i < buf.length; i++)
{
if (!seenEOF)
{
buf[i] = next();
}
else
{
buf[i] = -1;
}
if (buf[i] == -1)
{
seenEOF = true;
}
}
if (!seenEOF)
{
unread(buf, m);
}
else
{
List<Integer> ints = Lists.newArrayList();
for (int aBuf : buf)
{
ints.add(aBuf);
if (aBuf == -1)
{
break;
}
}
unread(ints, m);
}
return buf;
} | java | int[] peek(int n) throws
IOException
{
int[] buf = new int[n];
Mark m = mark();
boolean seenEOF = false;
for (int i = 0; i < buf.length; i++)
{
if (!seenEOF)
{
buf[i] = next();
}
else
{
buf[i] = -1;
}
if (buf[i] == -1)
{
seenEOF = true;
}
}
if (!seenEOF)
{
unread(buf, m);
}
else
{
List<Integer> ints = Lists.newArrayList();
for (int aBuf : buf)
{
ints.add(aBuf);
if (aBuf == -1)
{
break;
}
}
unread(ints, m);
}
return buf;
} | [
"int",
"[",
"]",
"peek",
"(",
"int",
"n",
")",
"throws",
"IOException",
"{",
"int",
"[",
"]",
"buf",
"=",
"new",
"int",
"[",
"n",
"]",
";",
"Mark",
"m",
"=",
"mark",
"(",
")",
";",
"boolean",
"seenEOF",
"=",
"false",
";",
"for",
"(",
"int",
"... | Returns the the next n characters in the stream without advancing the
readers position.
@param n the number of characters to read
@return An array with guaranteed length n, with -1 being the value for
all elements at and after EOF.
@throws IOException | [
"Returns",
"the",
"the",
"next",
"n",
"characters",
"in",
"the",
"stream",
"without",
"advancing",
"the",
"readers",
"position",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L176-L217 |
30,946 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.at | int at(int n) throws
IOException
{
Mark mark = mark();
List<Integer> cbuf = Lists.newArrayList();
for (int i = 0; i < n; i++)
{
cbuf.add(next());
if (curChar == -1)
{
break;
}
}
unread(cbuf, mark);
return cbuf.get(cbuf.size() - 1);
} | java | int at(int n) throws
IOException
{
Mark mark = mark();
List<Integer> cbuf = Lists.newArrayList();
for (int i = 0; i < n; i++)
{
cbuf.add(next());
if (curChar == -1)
{
break;
}
}
unread(cbuf, mark);
return cbuf.get(cbuf.size() - 1);
} | [
"int",
"at",
"(",
"int",
"n",
")",
"throws",
"IOException",
"{",
"Mark",
"mark",
"=",
"mark",
"(",
")",
";",
"List",
"<",
"Integer",
">",
"cbuf",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",... | Peek and return the character at position n from current position, or -1
if EOF is reached before or at that position. | [
"Peek",
"and",
"return",
"the",
"character",
"at",
"position",
"n",
"from",
"current",
"position",
"or",
"-",
"1",
"if",
"EOF",
"is",
"reached",
"before",
"or",
"at",
"that",
"position",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L223-L238 |
30,947 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.forward | CssReader forward(CharMatcher matcher) throws
IOException
{
while (true)
{
Mark mark = mark();
next();
//TODO escape awareness
if (curChar == -1 || (matcher.matches((char) curChar) && prevChar != '\\'))
{
unread(curChar, mark);
break;
}
}
return this;
} | java | CssReader forward(CharMatcher matcher) throws
IOException
{
while (true)
{
Mark mark = mark();
next();
//TODO escape awareness
if (curChar == -1 || (matcher.matches((char) curChar) && prevChar != '\\'))
{
unread(curChar, mark);
break;
}
}
return this;
} | [
"CssReader",
"forward",
"(",
"CharMatcher",
"matcher",
")",
"throws",
"IOException",
"{",
"while",
"(",
"true",
")",
"{",
"Mark",
"mark",
"=",
"mark",
"(",
")",
";",
"next",
"(",
")",
";",
"//TODO escape awareness",
"if",
"(",
"curChar",
"==",
"-",
"1",
... | Read forward until the next non-escaped character matches the given
CharMatcher or is EOF.
@throws IOException | [
"Read",
"forward",
"until",
"the",
"next",
"non",
"-",
"escaped",
"character",
"matches",
"the",
"given",
"CharMatcher",
"or",
"is",
"EOF",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L279-L294 |
30,948 | w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssReader.java | CssReader.forward | CssReader forward(int n) throws
IOException
{
for (int i = 0; i < n; i++)
{
//TODO escape awareness
Mark mark = mark();
next();
if (curChar == -1)
{
unread(curChar, mark);
break;
}
}
return this;
} | java | CssReader forward(int n) throws
IOException
{
for (int i = 0; i < n; i++)
{
//TODO escape awareness
Mark mark = mark();
next();
if (curChar == -1)
{
unread(curChar, mark);
break;
}
}
return this;
} | [
"CssReader",
"forward",
"(",
"int",
"n",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"//TODO escape awareness",
"Mark",
"mark",
"=",
"mark",
"(",
")",
";",
"next",
"(",
")",
"... | Read forward n characters, or until the next character is EOF.
@throws IOException | [
"Read",
"forward",
"n",
"characters",
"or",
"until",
"the",
"next",
"character",
"is",
"EOF",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssReader.java#L301-L316 |
30,949 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/dtbook/DTBookHandler.java | DTBookHandler.checkURI | private URI checkURI(String uri)
{
try
{
return new URI(Preconditions.checkNotNull(uri).trim());
} catch (URISyntaxException e)
{
parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri);
return null;
}
} | java | private URI checkURI(String uri)
{
try
{
return new URI(Preconditions.checkNotNull(uri).trim());
} catch (URISyntaxException e)
{
parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri);
return null;
}
} | [
"private",
"URI",
"checkURI",
"(",
"String",
"uri",
")",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"Preconditions",
".",
"checkNotNull",
"(",
"uri",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"pa... | should be in a URI utils class | [
"should",
"be",
"in",
"a",
"URI",
"utils",
"class"
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/dtbook/DTBookHandler.java#L146-L156 |
30,950 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/util/XmlReportAbstract.java | XmlReportAbstract.correctToUtf8 | protected static String correctToUtf8(String inputString) {
final StringBuilder result = new StringBuilder(inputString.length());
final StringCharacterIterator it = new StringCharacterIterator(inputString);
char ch = it.current();
boolean modified = false;
while (ch != CharacterIterator.DONE) {
if (Character.isISOControl(ch)) {
if (ch == '\r' || ch == '\n') {
result.append(ch);
} else {
modified = true;
result.append(String.format("0x%x", (int) ch));
}
} else {
result.append(ch);
}
ch = it.next();
}
if (!modified) return inputString;
return result.toString();
} | java | protected static String correctToUtf8(String inputString) {
final StringBuilder result = new StringBuilder(inputString.length());
final StringCharacterIterator it = new StringCharacterIterator(inputString);
char ch = it.current();
boolean modified = false;
while (ch != CharacterIterator.DONE) {
if (Character.isISOControl(ch)) {
if (ch == '\r' || ch == '\n') {
result.append(ch);
} else {
modified = true;
result.append(String.format("0x%x", (int) ch));
}
} else {
result.append(ch);
}
ch = it.next();
}
if (!modified) return inputString;
return result.toString();
} | [
"protected",
"static",
"String",
"correctToUtf8",
"(",
"String",
"inputString",
")",
"{",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"inputString",
".",
"length",
"(",
")",
")",
";",
"final",
"StringCharacterIterator",
"it",
"=",
"new"... | Make sure the string contains valid UTF-8 characters
@param inputString
@return escaped String | [
"Make",
"sure",
"the",
"string",
"contains",
"valid",
"UTF",
"-",
"8",
"characters"
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/util/XmlReportAbstract.java#L433-L455 |
30,951 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/util/XmlReportAbstract.java | XmlReportAbstract.fromTime | protected static String fromTime(final long time) {
Date date = new Date(time);
// Waiting for Java 7: SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
String formatted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date);
return formatted.substring(0, 22) + ":" + formatted.substring(22);
} | java | protected static String fromTime(final long time) {
Date date = new Date(time);
// Waiting for Java 7: SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
String formatted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date);
return formatted.substring(0, 22) + ":" + formatted.substring(22);
} | [
"protected",
"static",
"String",
"fromTime",
"(",
"final",
"long",
"time",
")",
"{",
"Date",
"date",
"=",
"new",
"Date",
"(",
"time",
")",
";",
"// Waiting for Java 7: SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ssXXX\");",
"String",
"formatted",
"=",
"new",
"SimpleDateForm... | Transform time into ISO 8601 string. | [
"Transform",
"time",
"into",
"ISO",
"8601",
"string",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/util/XmlReportAbstract.java#L460-L465 |
30,952 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/opf/ResourceCollections.java | ResourceCollections.getByRole | public List<ResourceCollection> getByRole(Roles role)
{
return role == null ? ImmutableList.<ResourceCollection> of() : getByRole(role.toString());
} | java | public List<ResourceCollection> getByRole(Roles role)
{
return role == null ? ImmutableList.<ResourceCollection> of() : getByRole(role.toString());
} | [
"public",
"List",
"<",
"ResourceCollection",
">",
"getByRole",
"(",
"Roles",
"role",
")",
"{",
"return",
"role",
"==",
"null",
"?",
"ImmutableList",
".",
"<",
"ResourceCollection",
">",
"of",
"(",
")",
":",
"getByRole",
"(",
"role",
".",
"toString",
"(",
... | Returns the list of collections in this set with the given IDPF-reserved
role. | [
"Returns",
"the",
"list",
"of",
"collections",
"in",
"this",
"set",
"with",
"the",
"given",
"IDPF",
"-",
"reserved",
"role",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/opf/ResourceCollections.java#L59-L62 |
30,953 | w3c/epubcheck | src/main/java/com/adobe/epubcheck/vocab/Property.java | Property.newFrom | public static Property newFrom(String name, String base, String prefix)
{
return new Property(name, base, prefix, null);
} | java | public static Property newFrom(String name, String base, String prefix)
{
return new Property(name, base, prefix, null);
} | [
"public",
"static",
"Property",
"newFrom",
"(",
"String",
"name",
",",
"String",
"base",
",",
"String",
"prefix",
")",
"{",
"return",
"new",
"Property",
"(",
"name",
",",
"base",
",",
"prefix",
",",
"null",
")",
";",
"}"
] | Creates a new instance from a short name, a prefix, and a stem URI.
@param name
the short name of the property (aka "reference").
@param base
the stem URI used to compute the full URI value.
@param prefix
the prefix used in the CURIE form.
@return | [
"Creates",
"a",
"new",
"instance",
"from",
"a",
"short",
"name",
"a",
"prefix",
"and",
"a",
"stem",
"URI",
"."
] | 4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78 | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/vocab/Property.java#L42-L45 |
30,954 | sarxos/webcam-capture | webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/RaspividDevice.java | RaspividDevice.validateParameters | @Override
protected void validateParameters() {
super.validateParameters();
// override some arguments
parameters.put(OPT_NOPREVIEW, "");
parameters.put(OPT_RAW, "-");// must be this, then image will be in console!
parameters.put(OPT_RAW_FORMAT, "rgb");// only support rgb
parameters.put(OPT_CAMSELECT, Integer.toString(this.camSelect));
parameters.put(OPT_OUTPUT, "/dev/null");
} | java | @Override
protected void validateParameters() {
super.validateParameters();
// override some arguments
parameters.put(OPT_NOPREVIEW, "");
parameters.put(OPT_RAW, "-");// must be this, then image will be in console!
parameters.put(OPT_RAW_FORMAT, "rgb");// only support rgb
parameters.put(OPT_CAMSELECT, Integer.toString(this.camSelect));
parameters.put(OPT_OUTPUT, "/dev/null");
} | [
"@",
"Override",
"protected",
"void",
"validateParameters",
"(",
")",
"{",
"super",
".",
"validateParameters",
"(",
")",
";",
"// override some arguments",
"parameters",
".",
"put",
"(",
"OPT_NOPREVIEW",
",",
"\"\"",
")",
";",
"parameters",
".",
"put",
"(",
"O... | raspivid -rf rgb -r file.rgb will output YUV, whilst raspivid -r file.rgb -rf
rgb Somewhat yucky, but that's the way it was written. | [
"raspivid",
"-",
"rf",
"rgb",
"-",
"r",
"file",
".",
"rgb",
"will",
"output",
"YUV",
"whilst",
"raspivid",
"-",
"r",
"file",
".",
"rgb",
"-",
"rf",
"rgb",
"Somewhat",
"yucky",
"but",
"that",
"s",
"the",
"way",
"it",
"was",
"written",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/RaspividDevice.java#L87-L96 |
30,955 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.close | public boolean close() {
if (open.compareAndSet(true, false)) {
LOG.debug("Closing webcam {}", getName());
assert lock != null;
// close webcam
WebcamCloseTask task = new WebcamCloseTask(driver, device);
try {
task.close();
} catch (InterruptedException e) {
open.set(true);
LOG.debug("Thread has been interrupted before webcam was closed!", e);
return false;
} catch (WebcamException e) {
open.set(true);
throw e;
}
// stop updater
if (asynchronous) {
updater.stop();
}
// remove shutdown hook (it's not more necessary)
removeShutdownHook();
// unlock webcam so other Java processes can start using it
lock.unlock();
// notify listeners
WebcamEvent we = new WebcamEvent(WebcamEventType.CLOSED, this);
Iterator<WebcamListener> wli = listeners.iterator();
WebcamListener l = null;
while (wli.hasNext()) {
l = wli.next();
try {
l.webcamClosed(we);
} catch (Exception e) {
LOG.error(String.format("Notify webcam closed, exception when calling %s listener", l.getClass()), e);
}
}
notificator.shutdown();
while (!notificator.isTerminated()) {
try {
notificator.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return false;
}
}
LOG.debug("Webcam {} has been closed", getName());
} else {
LOG.debug("Webcam {} is already closed", getName());
}
return true;
} | java | public boolean close() {
if (open.compareAndSet(true, false)) {
LOG.debug("Closing webcam {}", getName());
assert lock != null;
// close webcam
WebcamCloseTask task = new WebcamCloseTask(driver, device);
try {
task.close();
} catch (InterruptedException e) {
open.set(true);
LOG.debug("Thread has been interrupted before webcam was closed!", e);
return false;
} catch (WebcamException e) {
open.set(true);
throw e;
}
// stop updater
if (asynchronous) {
updater.stop();
}
// remove shutdown hook (it's not more necessary)
removeShutdownHook();
// unlock webcam so other Java processes can start using it
lock.unlock();
// notify listeners
WebcamEvent we = new WebcamEvent(WebcamEventType.CLOSED, this);
Iterator<WebcamListener> wli = listeners.iterator();
WebcamListener l = null;
while (wli.hasNext()) {
l = wli.next();
try {
l.webcamClosed(we);
} catch (Exception e) {
LOG.error(String.format("Notify webcam closed, exception when calling %s listener", l.getClass()), e);
}
}
notificator.shutdown();
while (!notificator.isTerminated()) {
try {
notificator.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return false;
}
}
LOG.debug("Webcam {} has been closed", getName());
} else {
LOG.debug("Webcam {} is already closed", getName());
}
return true;
} | [
"public",
"boolean",
"close",
"(",
")",
"{",
"if",
"(",
"open",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Closing webcam {}\"",
",",
"getName",
"(",
")",
")",
";",
"assert",
"lock",
"!=",
"null",
";"... | Close the webcam.
@return True if webcam has been open, false otherwise | [
"Close",
"the",
"webcam",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L360-L424 |
30,956 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.dispose | protected void dispose() {
assert disposed != null;
assert open != null;
assert driver != null;
assert device != null;
assert listeners != null;
if (!disposed.compareAndSet(false, true)) {
return;
}
open.set(false);
LOG.info("Disposing webcam {}", getName());
WebcamDisposeTask task = new WebcamDisposeTask(driver, device);
try {
task.dispose();
} catch (InterruptedException e) {
LOG.error("Processor has been interrupted before webcam was disposed!", e);
return;
}
WebcamEvent we = new WebcamEvent(WebcamEventType.DISPOSED, this);
Iterator<WebcamListener> wli = listeners.iterator();
WebcamListener l = null;
while (wli.hasNext()) {
l = wli.next();
try {
l.webcamClosed(we);
l.webcamDisposed(we);
} catch (Exception e) {
LOG.error(String.format("Notify webcam disposed, exception when calling %s listener", l.getClass()), e);
}
}
removeShutdownHook();
LOG.debug("Webcam disposed {}", getName());
} | java | protected void dispose() {
assert disposed != null;
assert open != null;
assert driver != null;
assert device != null;
assert listeners != null;
if (!disposed.compareAndSet(false, true)) {
return;
}
open.set(false);
LOG.info("Disposing webcam {}", getName());
WebcamDisposeTask task = new WebcamDisposeTask(driver, device);
try {
task.dispose();
} catch (InterruptedException e) {
LOG.error("Processor has been interrupted before webcam was disposed!", e);
return;
}
WebcamEvent we = new WebcamEvent(WebcamEventType.DISPOSED, this);
Iterator<WebcamListener> wli = listeners.iterator();
WebcamListener l = null;
while (wli.hasNext()) {
l = wli.next();
try {
l.webcamClosed(we);
l.webcamDisposed(we);
} catch (Exception e) {
LOG.error(String.format("Notify webcam disposed, exception when calling %s listener", l.getClass()), e);
}
}
removeShutdownHook();
LOG.debug("Webcam disposed {}", getName());
} | [
"protected",
"void",
"dispose",
"(",
")",
"{",
"assert",
"disposed",
"!=",
"null",
";",
"assert",
"open",
"!=",
"null",
";",
"assert",
"driver",
"!=",
"null",
";",
"assert",
"device",
"!=",
"null",
";",
"assert",
"listeners",
"!=",
"null",
";",
"if",
"... | Completely dispose capture device. After this operation webcam cannot be used any more and
full reinstantiation is required. | [
"Completely",
"dispose",
"capture",
"device",
".",
"After",
"this",
"operation",
"webcam",
"cannot",
"be",
"used",
"any",
"more",
"and",
"full",
"reinstantiation",
"is",
"required",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L442-L483 |
30,957 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.transform | protected BufferedImage transform(BufferedImage image) {
if (image != null) {
WebcamImageTransformer tr = getImageTransformer();
if (tr != null) {
return tr.transform(image);
}
}
return image;
} | java | protected BufferedImage transform(BufferedImage image) {
if (image != null) {
WebcamImageTransformer tr = getImageTransformer();
if (tr != null) {
return tr.transform(image);
}
}
return image;
} | [
"protected",
"BufferedImage",
"transform",
"(",
"BufferedImage",
"image",
")",
"{",
"if",
"(",
"image",
"!=",
"null",
")",
"{",
"WebcamImageTransformer",
"tr",
"=",
"getImageTransformer",
"(",
")",
";",
"if",
"(",
"tr",
"!=",
"null",
")",
"{",
"return",
"t... | TRansform image using image transformer. If image transformer has not been set, this method
return instance passed in the argument, without any modifications.
@param image the image to be transformed
@return Transformed image (if transformer is set) | [
"TRansform",
"image",
"using",
"image",
"transformer",
".",
"If",
"image",
"transformer",
"has",
"not",
"been",
"set",
"this",
"method",
"return",
"instance",
"passed",
"in",
"the",
"argument",
"without",
"any",
"modifications",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L506-L514 |
30,958 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.setCustomViewSizes | public void setCustomViewSizes(Dimension... sizes) {
assert customSizes != null;
if (sizes == null) {
customSizes.clear();
return;
}
customSizes = Arrays.asList(sizes);
} | java | public void setCustomViewSizes(Dimension... sizes) {
assert customSizes != null;
if (sizes == null) {
customSizes.clear();
return;
}
customSizes = Arrays.asList(sizes);
} | [
"public",
"void",
"setCustomViewSizes",
"(",
"Dimension",
"...",
"sizes",
")",
"{",
"assert",
"customSizes",
"!=",
"null",
";",
"if",
"(",
"sizes",
"==",
"null",
")",
"{",
"customSizes",
".",
"clear",
"(",
")",
";",
"return",
";",
"}",
"customSizes",
"="... | Set custom resolution. If you are using this method you have to make sure that your webcam
device can support this specific resolution.
@param sizes the array of custom resolutions to be supported by webcam | [
"Set",
"custom",
"resolution",
".",
"If",
"you",
"are",
"using",
"this",
"method",
"you",
"have",
"to",
"make",
"sure",
"that",
"your",
"webcam",
"device",
"can",
"support",
"this",
"specific",
"resolution",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L549-L556 |
30,959 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.setViewSize | public void setViewSize(Dimension size) {
if (size == null) {
throw new IllegalArgumentException("Resolution cannot be null!");
}
if (open.get()) {
throw new IllegalStateException("Cannot change resolution when webcam is open, please close it first");
}
// check if new resolution is the same as current one
Dimension current = getViewSize();
if (current != null && current.width == size.width && current.height == size.height) {
return;
}
// check if new resolution is valid
Dimension[] predefined = getViewSizes();
Dimension[] custom = getCustomViewSizes();
assert predefined != null;
assert custom != null;
boolean ok = false;
for (Dimension d : predefined) {
if (d.width == size.width && d.height == size.height) {
ok = true;
break;
}
}
if (!ok) {
for (Dimension d : custom) {
if (d.width == size.width && d.height == size.height) {
ok = true;
break;
}
}
}
if (!ok) {
StringBuilder sb = new StringBuilder("Incorrect dimension [");
sb.append(size.width).append("x").append(size.height).append("] ");
sb.append("possible ones are ");
for (Dimension d : predefined) {
sb.append("[").append(d.width).append("x").append(d.height).append("] ");
}
for (Dimension d : custom) {
sb.append("[").append(d.width).append("x").append(d.height).append("] ");
}
throw new IllegalArgumentException(sb.toString());
}
LOG.debug("Setting new resolution {}x{}", size.width, size.height);
device.setResolution(size);
} | java | public void setViewSize(Dimension size) {
if (size == null) {
throw new IllegalArgumentException("Resolution cannot be null!");
}
if (open.get()) {
throw new IllegalStateException("Cannot change resolution when webcam is open, please close it first");
}
// check if new resolution is the same as current one
Dimension current = getViewSize();
if (current != null && current.width == size.width && current.height == size.height) {
return;
}
// check if new resolution is valid
Dimension[] predefined = getViewSizes();
Dimension[] custom = getCustomViewSizes();
assert predefined != null;
assert custom != null;
boolean ok = false;
for (Dimension d : predefined) {
if (d.width == size.width && d.height == size.height) {
ok = true;
break;
}
}
if (!ok) {
for (Dimension d : custom) {
if (d.width == size.width && d.height == size.height) {
ok = true;
break;
}
}
}
if (!ok) {
StringBuilder sb = new StringBuilder("Incorrect dimension [");
sb.append(size.width).append("x").append(size.height).append("] ");
sb.append("possible ones are ");
for (Dimension d : predefined) {
sb.append("[").append(d.width).append("x").append(d.height).append("] ");
}
for (Dimension d : custom) {
sb.append("[").append(d.width).append("x").append(d.height).append("] ");
}
throw new IllegalArgumentException(sb.toString());
}
LOG.debug("Setting new resolution {}x{}", size.width, size.height);
device.setResolution(size);
} | [
"public",
"void",
"setViewSize",
"(",
"Dimension",
"size",
")",
"{",
"if",
"(",
"size",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Resolution cannot be null!\"",
")",
";",
"}",
"if",
"(",
"open",
".",
"get",
"(",
")",
")",
... | Set new view size. New size has to exactly the same as one of the default sized or exactly
the same as one of the custom ones.
@param size the new view size to be set
@see Webcam#setCustomViewSizes(Dimension[])
@see Webcam#getViewSizes() | [
"Set",
"new",
"view",
"size",
".",
"New",
"size",
"has",
"to",
"exactly",
"the",
"same",
"as",
"one",
"of",
"the",
"default",
"sized",
"or",
"exactly",
"the",
"same",
"as",
"one",
"of",
"the",
"custom",
"ones",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L571-L628 |
30,960 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.setParameters | public void setParameters(Map<String, ?> parameters) {
WebcamDevice device = getDevice();
if (device instanceof Configurable) {
((Configurable) device).setParameters(parameters);
} else {
LOG.debug("Webcam device {} is not configurable", device);
}
} | java | public void setParameters(Map<String, ?> parameters) {
WebcamDevice device = getDevice();
if (device instanceof Configurable) {
((Configurable) device).setParameters(parameters);
} else {
LOG.debug("Webcam device {} is not configurable", device);
}
} | [
"public",
"void",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"parameters",
")",
"{",
"WebcamDevice",
"device",
"=",
"getDevice",
"(",
")",
";",
"if",
"(",
"device",
"instanceof",
"Configurable",
")",
"{",
"(",
"(",
"Configurable",
")",
"d... | If the underlying device implements Configurable interface, specified parameters are passed
to it. May be called before the open method or later in dependence of the device
implementation.
@param parameters - Map of parameters changing device defaults
@see Configurable | [
"If",
"the",
"underlying",
"device",
"implements",
"Configurable",
"interface",
"specified",
"parameters",
"are",
"passed",
"to",
"it",
".",
"May",
"be",
"called",
"before",
"the",
"open",
"method",
"or",
"later",
"in",
"dependence",
"of",
"the",
"device",
"im... | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L796-L803 |
30,961 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.isReady | private boolean isReady() {
assert disposed != null;
assert open != null;
if (disposed.get()) {
LOG.warn("Cannot get image, webcam has been already disposed");
return false;
}
if (!open.get()) {
if (autoOpen) {
open();
} else {
return false;
}
}
return true;
} | java | private boolean isReady() {
assert disposed != null;
assert open != null;
if (disposed.get()) {
LOG.warn("Cannot get image, webcam has been already disposed");
return false;
}
if (!open.get()) {
if (autoOpen) {
open();
} else {
return false;
}
}
return true;
} | [
"private",
"boolean",
"isReady",
"(",
")",
"{",
"assert",
"disposed",
"!=",
"null",
";",
"assert",
"open",
"!=",
"null",
";",
"if",
"(",
"disposed",
".",
"get",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Cannot get image, webcam has been already dispose... | Is webcam ready to be read.
@return True if ready, false otherwise | [
"Is",
"webcam",
"ready",
"to",
"be",
"read",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L810-L829 |
30,962 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.getWebcams | public static List<Webcam> getWebcams() throws WebcamException {
// timeout exception below will never be caught since user would have to
// wait around three hundreds billion years for it to occur
try {
return getWebcams(Long.MAX_VALUE);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
} | java | public static List<Webcam> getWebcams() throws WebcamException {
// timeout exception below will never be caught since user would have to
// wait around three hundreds billion years for it to occur
try {
return getWebcams(Long.MAX_VALUE);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"List",
"<",
"Webcam",
">",
"getWebcams",
"(",
")",
"throws",
"WebcamException",
"{",
"// timeout exception below will never be caught since user would have to\r",
"// wait around three hundreds billion years for it to occur\r",
"try",
"{",
"return",
"getWebcams... | Get list of webcams to use. This method will wait predefined time interval for webcam devices
to be discovered. By default this time is set to 1 minute.
@return List of webcams existing in the system
@throws WebcamException when something is wrong
@see Webcam#getWebcams(long, TimeUnit) | [
"Get",
"list",
"of",
"webcams",
"to",
"use",
".",
"This",
"method",
"will",
"wait",
"predefined",
"time",
"interval",
"for",
"webcam",
"devices",
"to",
"be",
"discovered",
".",
"By",
"default",
"this",
"time",
"is",
"set",
"to",
"1",
"minute",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L839-L849 |
30,963 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.getWebcams | public static List<Webcam> getWebcams(long timeout) throws TimeoutException, WebcamException {
if (timeout < 0) {
throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout));
}
return getWebcams(timeout, TimeUnit.MILLISECONDS);
} | java | public static List<Webcam> getWebcams(long timeout) throws TimeoutException, WebcamException {
if (timeout < 0) {
throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout));
}
return getWebcams(timeout, TimeUnit.MILLISECONDS);
} | [
"public",
"static",
"List",
"<",
"Webcam",
">",
"getWebcams",
"(",
"long",
"timeout",
")",
"throws",
"TimeoutException",
",",
"WebcamException",
"{",
"if",
"(",
"timeout",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"f... | Get list of webcams to use. This method will wait given time interval for webcam devices to
be discovered. Time argument is given in milliseconds.
@param timeout the time to wait for webcam devices to be discovered
@return List of webcams existing in the ssytem
@throws TimeoutException when timeout occurs
@throws WebcamException when something is wrong
@throws IllegalArgumentException when timeout is negative
@see Webcam#getWebcams(long, TimeUnit) | [
"Get",
"list",
"of",
"webcams",
"to",
"use",
".",
"This",
"method",
"will",
"wait",
"given",
"time",
"interval",
"for",
"webcam",
"devices",
"to",
"be",
"discovered",
".",
"Time",
"argument",
"is",
"given",
"in",
"milliseconds",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L862-L867 |
30,964 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.getWebcams | public static synchronized List<Webcam> getWebcams(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException {
if (timeout < 0) {
throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout));
}
if (tunit == null) {
throw new IllegalArgumentException("Time unit cannot be null!");
}
WebcamDiscoveryService discovery = getDiscoveryService();
assert discovery != null;
List<Webcam> webcams = discovery.getWebcams(timeout, tunit);
if (!discovery.isRunning()) {
discovery.start();
}
return webcams;
} | java | public static synchronized List<Webcam> getWebcams(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException {
if (timeout < 0) {
throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout));
}
if (tunit == null) {
throw new IllegalArgumentException("Time unit cannot be null!");
}
WebcamDiscoveryService discovery = getDiscoveryService();
assert discovery != null;
List<Webcam> webcams = discovery.getWebcams(timeout, tunit);
if (!discovery.isRunning()) {
discovery.start();
}
return webcams;
} | [
"public",
"static",
"synchronized",
"List",
"<",
"Webcam",
">",
"getWebcams",
"(",
"long",
"timeout",
",",
"TimeUnit",
"tunit",
")",
"throws",
"TimeoutException",
",",
"WebcamException",
"{",
"if",
"(",
"timeout",
"<",
"0",
")",
"{",
"throw",
"new",
"Illegal... | Get list of webcams to use. This method will wait given time interval for webcam devices to
be discovered.
@param timeout the devices discovery timeout
@param tunit the time unit
@return List of webcams
@throws TimeoutException when timeout has been exceeded
@throws WebcamException when something is wrong
@throws IllegalArgumentException when timeout is negative or tunit null | [
"Get",
"list",
"of",
"webcams",
"to",
"use",
".",
"This",
"method",
"will",
"wait",
"given",
"time",
"interval",
"for",
"webcam",
"devices",
"to",
"be",
"discovered",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L880-L899 |
30,965 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.addWebcamListener | public boolean addWebcamListener(WebcamListener l) {
if (l == null) {
throw new IllegalArgumentException("Webcam listener cannot be null!");
}
assert listeners != null;
return listeners.add(l);
} | java | public boolean addWebcamListener(WebcamListener l) {
if (l == null) {
throw new IllegalArgumentException("Webcam listener cannot be null!");
}
assert listeners != null;
return listeners.add(l);
} | [
"public",
"boolean",
"addWebcamListener",
"(",
"WebcamListener",
"l",
")",
"{",
"if",
"(",
"l",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Webcam listener cannot be null!\"",
")",
";",
"}",
"assert",
"listeners",
"!=",
"null",
";... | Add webcam listener.
@param l the listener to be added
@return True if listener has been added, false if it was already there
@throws IllegalArgumentException when argument is null | [
"Add",
"webcam",
"listener",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L993-L999 |
30,966 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.registerDriver | public static void registerDriver(Class<? extends WebcamDriver> clazz) {
if (clazz == null) {
throw new IllegalArgumentException("Webcam driver class to register cannot be null!");
}
DRIVERS_CLASS_LIST.add(clazz);
registerDriver(clazz.getCanonicalName());
} | java | public static void registerDriver(Class<? extends WebcamDriver> clazz) {
if (clazz == null) {
throw new IllegalArgumentException("Webcam driver class to register cannot be null!");
}
DRIVERS_CLASS_LIST.add(clazz);
registerDriver(clazz.getCanonicalName());
} | [
"public",
"static",
"void",
"registerDriver",
"(",
"Class",
"<",
"?",
"extends",
"WebcamDriver",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Webcam driver class to register cannot be null!\"... | Register new webcam video driver.
@param clazz webcam video driver class
@throws IllegalArgumentException when argument is null | [
"Register",
"new",
"webcam",
"video",
"driver",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L1126-L1132 |
30,967 | sarxos/webcam-capture | webcam-capture-drivers/driver-v4l4j/src/main/java/com/github/sarxos/webcam/ds/v4l4j/V4l4jDevice.java | V4l4jDevice.getVideoDevice | private static VideoDevice getVideoDevice(File file) {
LOG.debug("Creating V4L4J device from file {}", file);
try {
return new VideoDevice(file.getAbsolutePath());
} catch (V4L4JException e) {
throw new WebcamException("Cannot instantiate V4L4J device from " + file, e);
}
} | java | private static VideoDevice getVideoDevice(File file) {
LOG.debug("Creating V4L4J device from file {}", file);
try {
return new VideoDevice(file.getAbsolutePath());
} catch (V4L4JException e) {
throw new WebcamException("Cannot instantiate V4L4J device from " + file, e);
}
} | [
"private",
"static",
"VideoDevice",
"getVideoDevice",
"(",
"File",
"file",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Creating V4L4J device from file {}\"",
",",
"file",
")",
";",
"try",
"{",
"return",
"new",
"VideoDevice",
"(",
"file",
".",
"getAbsolutePath",
"(",
... | Create video device from file.
@param file the video descriptor file
@return The {@link VideoDevice} | [
"Create",
"video",
"device",
"from",
"file",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-v4l4j/src/main/java/com/github/sarxos/webcam/ds/v4l4j/V4l4jDevice.java#L100-L109 |
30,968 | sarxos/webcam-capture | webcam-capture-drivers/driver-vlcj/src/main/java/com/github/sarxos/webcam/ds/vlcj/VlcjDriver.java | VlcjDriver.initialize | protected static void initialize(boolean load) {
if (load && initialized.compareAndSet(false, true)) {
boolean nativeFound = getNativeDiscovery().discover();
if (!nativeFound) {
throw new IllegalStateException("The libvlc native library has not been found");
}
// Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
}
} | java | protected static void initialize(boolean load) {
if (load && initialized.compareAndSet(false, true)) {
boolean nativeFound = getNativeDiscovery().discover();
if (!nativeFound) {
throw new IllegalStateException("The libvlc native library has not been found");
}
// Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
}
} | [
"protected",
"static",
"void",
"initialize",
"(",
"boolean",
"load",
")",
"{",
"if",
"(",
"load",
"&&",
"initialized",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"boolean",
"nativeFound",
"=",
"getNativeDiscovery",
"(",
")",
".",
"disc... | Initialize natives. If argument is true the natives are being loaded. In case of false this
method do nothing. It's used mostly in unit tests.
@param load the control to decide whether to load natives or ignore them | [
"Initialize",
"natives",
".",
"If",
"argument",
"is",
"true",
"the",
"natives",
"are",
"being",
"loaded",
".",
"In",
"case",
"of",
"false",
"this",
"method",
"do",
"nothing",
".",
"It",
"s",
"used",
"mostly",
"in",
"unit",
"tests",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-vlcj/src/main/java/com/github/sarxos/webcam/ds/vlcj/VlcjDriver.java#L85-L93 |
30,969 | sarxos/webcam-capture | webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/IPCDevice.java | IPCDevice.setParameters | @Override
public void setParameters(Map<String, ?> map) {
if (isOpen) {
throw new UnsupportedOperationException(MSG_CANNOT_CHANGE_PROP);
}
for (Entry<String, ?> entry : map.entrySet()) {
if (this.driver.getOptions().hasOption(entry.getKey())) {
String longKey = this.driver.getOptions().getOption(entry.getKey()).getLongOpt();
this.parameters.put(longKey, entry.getValue() == null ? "" : entry.getValue().toString());
} else {
throw new UnsupportedOperationException(MSG_WRONG_ARGUMENT);
}
}
} | java | @Override
public void setParameters(Map<String, ?> map) {
if (isOpen) {
throw new UnsupportedOperationException(MSG_CANNOT_CHANGE_PROP);
}
for (Entry<String, ?> entry : map.entrySet()) {
if (this.driver.getOptions().hasOption(entry.getKey())) {
String longKey = this.driver.getOptions().getOption(entry.getKey()).getLongOpt();
this.parameters.put(longKey, entry.getValue() == null ? "" : entry.getValue().toString());
} else {
throw new UnsupportedOperationException(MSG_WRONG_ARGUMENT);
}
}
} | [
"@",
"Override",
"public",
"void",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
")",
"{",
"if",
"(",
"isOpen",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"MSG_CANNOT_CHANGE_PROP",
")",
";",
"}",
"for",
"(",
"Entry"... | support change FPS at runtime. | [
"support",
"change",
"FPS",
"at",
"runtime",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/IPCDevice.java#L123-L137 |
30,970 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUtils.java | WebcamUtils.getImageByteBuffer | public static final ByteBuffer getImageByteBuffer(Webcam webcam, String format) {
return ByteBuffer.wrap(getImageBytes(webcam, format));
} | java | public static final ByteBuffer getImageByteBuffer(Webcam webcam, String format) {
return ByteBuffer.wrap(getImageBytes(webcam, format));
} | [
"public",
"static",
"final",
"ByteBuffer",
"getImageByteBuffer",
"(",
"Webcam",
"webcam",
",",
"String",
"format",
")",
"{",
"return",
"ByteBuffer",
".",
"wrap",
"(",
"getImageBytes",
"(",
"webcam",
",",
"format",
")",
")",
";",
"}"
] | Capture image as BYteBuffer.
@param webcam the webcam from which image should be obtained
@param format the file format
@return Byte buffer | [
"Capture",
"image",
"as",
"BYteBuffer",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUtils.java#L65-L67 |
30,971 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUtils.java | WebcamUtils.loadRB | public static final ResourceBundle loadRB(Class<?> clazz, Locale locale) {
String pkg = WebcamUtils.class.getPackage().getName().replaceAll("\\.", "/");
return PropertyResourceBundle.getBundle(String.format("%s/i18n/%s", pkg, clazz.getSimpleName()));
} | java | public static final ResourceBundle loadRB(Class<?> clazz, Locale locale) {
String pkg = WebcamUtils.class.getPackage().getName().replaceAll("\\.", "/");
return PropertyResourceBundle.getBundle(String.format("%s/i18n/%s", pkg, clazz.getSimpleName()));
} | [
"public",
"static",
"final",
"ResourceBundle",
"loadRB",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Locale",
"locale",
")",
"{",
"String",
"pkg",
"=",
"WebcamUtils",
".",
"class",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
".",
"replaceAll",... | Get resource bundle for specific class.
@param clazz the class for which resource bundle should be found
@param locale the {@link Locale} object
@return Resource bundle | [
"Get",
"resource",
"bundle",
"for",
"specific",
"class",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUtils.java#L76-L79 |
30,972 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.java | WebcamDefaultDevice.startFramesRefresher | private Thread startFramesRefresher() {
Thread refresher = new Thread(this, String.format("frames-refresher-[%s]", id));
refresher.setUncaughtExceptionHandler(WebcamExceptionHandler.getInstance());
refresher.setDaemon(true);
refresher.start();
return refresher;
} | java | private Thread startFramesRefresher() {
Thread refresher = new Thread(this, String.format("frames-refresher-[%s]", id));
refresher.setUncaughtExceptionHandler(WebcamExceptionHandler.getInstance());
refresher.setDaemon(true);
refresher.start();
return refresher;
} | [
"private",
"Thread",
"startFramesRefresher",
"(",
")",
"{",
"Thread",
"refresher",
"=",
"new",
"Thread",
"(",
"this",
",",
"String",
".",
"format",
"(",
"\"frames-refresher-[%s]\"",
",",
"id",
")",
")",
";",
"refresher",
".",
"setUncaughtExceptionHandler",
"(",
... | Start underlying frames refresher.
@return Refresher thread | [
"Start",
"underlying",
"frames",
"refresher",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.java#L398-L404 |
30,973 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.java | WebcamDefaultDevice.updateFrameBuffer | private void updateFrameBuffer() {
LOG.trace("Next frame");
if (t1 == -1 || t2 == -1) {
t1 = System.currentTimeMillis();
t2 = System.currentTimeMillis();
}
int result = new NextFrameTask(this).nextFrame();
t1 = t2;
t2 = System.currentTimeMillis();
fps = (4 * fps + 1000 / (t2 - t1 + 1)) / 5;
if (result == -1) {
LOG.error("Timeout when requesting image!");
} else if (result < -1) {
LOG.error("Error requesting new frame!");
}
} | java | private void updateFrameBuffer() {
LOG.trace("Next frame");
if (t1 == -1 || t2 == -1) {
t1 = System.currentTimeMillis();
t2 = System.currentTimeMillis();
}
int result = new NextFrameTask(this).nextFrame();
t1 = t2;
t2 = System.currentTimeMillis();
fps = (4 * fps + 1000 / (t2 - t1 + 1)) / 5;
if (result == -1) {
LOG.error("Timeout when requesting image!");
} else if (result < -1) {
LOG.error("Error requesting new frame!");
}
} | [
"private",
"void",
"updateFrameBuffer",
"(",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"Next frame\"",
")",
";",
"if",
"(",
"t1",
"==",
"-",
"1",
"||",
"t2",
"==",
"-",
"1",
")",
"{",
"t1",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"t2",
... | Update underlying memory buffer and fetch new frame. | [
"Update",
"underlying",
"memory",
"buffer",
"and",
"fetch",
"new",
"frame",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.java#L469-L490 |
30,974 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetectorDefaultAlgorithm.java | WebcamMotionDetectorDefaultAlgorithm.isInDoNotEngageZone | private boolean isInDoNotEngageZone(final int x, final int y) {
for (final Rectangle zone : doNotEnganeZones) {
if (zone.contains(x, y)) {
return true;
}
}
return false;
} | java | private boolean isInDoNotEngageZone(final int x, final int y) {
for (final Rectangle zone : doNotEnganeZones) {
if (zone.contains(x, y)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"isInDoNotEngageZone",
"(",
"final",
"int",
"x",
",",
"final",
"int",
"y",
")",
"{",
"for",
"(",
"final",
"Rectangle",
"zone",
":",
"doNotEnganeZones",
")",
"{",
"if",
"(",
"zone",
".",
"contains",
"(",
"x",
",",
"y",
")",
")",
... | Return true if point identified by x and y coordinates is in one of the do-not-engage zones.
Return false otherwise.
@param x the x coordinate of a point
@param y the y coordinate of a point
@return True if point is in one of do-not-engage zones, false otherwise | [
"Return",
"true",
"if",
"point",
"identified",
"by",
"x",
"and",
"y",
"coordinates",
"is",
"in",
"one",
"of",
"the",
"do",
"-",
"not",
"-",
"engage",
"zones",
".",
"Return",
"false",
"otherwise",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetectorDefaultAlgorithm.java#L182-L189 |
30,975 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetector.java | WebcamMotionDetector.notifyMotionListeners | private void notifyMotionListeners(BufferedImage currentOriginal) {
WebcamMotionEvent wme = new WebcamMotionEvent(this, previousOriginal, currentOriginal, algorithm.getArea(), algorithm.getCog(), algorithm.getPoints());
for (WebcamMotionListener l : listeners) {
try {
l.motionDetected(wme);
} catch (Exception e) {
WebcamExceptionHandler.handle(e);
}
}
} | java | private void notifyMotionListeners(BufferedImage currentOriginal) {
WebcamMotionEvent wme = new WebcamMotionEvent(this, previousOriginal, currentOriginal, algorithm.getArea(), algorithm.getCog(), algorithm.getPoints());
for (WebcamMotionListener l : listeners) {
try {
l.motionDetected(wme);
} catch (Exception e) {
WebcamExceptionHandler.handle(e);
}
}
} | [
"private",
"void",
"notifyMotionListeners",
"(",
"BufferedImage",
"currentOriginal",
")",
"{",
"WebcamMotionEvent",
"wme",
"=",
"new",
"WebcamMotionEvent",
"(",
"this",
",",
"previousOriginal",
",",
"currentOriginal",
",",
"algorithm",
".",
"getArea",
"(",
")",
",",... | Will notify all attached motion listeners.
@param image with the motion detected | [
"Will",
"notify",
"all",
"attached",
"motion",
"listeners",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetector.java#L276-L285 |
30,976 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetector.java | WebcamMotionDetector.getMotionCog | public Point getMotionCog() {
Point cog = algorithm.getCog();
if (cog == null) {
// detectorAlgorithm hasn't been called so far - get image center
int w = webcam.getViewSize().width;
int h = webcam.getViewSize().height;
cog = new Point(w / 2, h / 2);
}
return cog;
} | java | public Point getMotionCog() {
Point cog = algorithm.getCog();
if (cog == null) {
// detectorAlgorithm hasn't been called so far - get image center
int w = webcam.getViewSize().width;
int h = webcam.getViewSize().height;
cog = new Point(w / 2, h / 2);
}
return cog;
} | [
"public",
"Point",
"getMotionCog",
"(",
")",
"{",
"Point",
"cog",
"=",
"algorithm",
".",
"getCog",
"(",
")",
";",
"if",
"(",
"cog",
"==",
"null",
")",
"{",
"// detectorAlgorithm hasn't been called so far - get image center\r",
"int",
"w",
"=",
"webcam",
".",
"... | Get motion center of gravity. When no motion is detected this value points to the image
center.
@return Center of gravity point | [
"Get",
"motion",
"center",
"of",
"gravity",
".",
"When",
"no",
"motion",
"is",
"detected",
"this",
"value",
"points",
"to",
"the",
"image",
"center",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetector.java#L415-L424 |
30,977 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamTask.java | WebcamTask.process | public void process() throws InterruptedException {
boolean alreadyInSync = Thread.currentThread() instanceof WebcamProcessor.ProcessorThread;
if (alreadyInSync) {
handle();
} else {
if (doSync) {
if (processor == null) {
throw new RuntimeException("Driver should be synchronized, but processor is null");
}
processor.process(this);
} else {
handle();
}
}
} | java | public void process() throws InterruptedException {
boolean alreadyInSync = Thread.currentThread() instanceof WebcamProcessor.ProcessorThread;
if (alreadyInSync) {
handle();
} else {
if (doSync) {
if (processor == null) {
throw new RuntimeException("Driver should be synchronized, but processor is null");
}
processor.process(this);
} else {
handle();
}
}
} | [
"public",
"void",
"process",
"(",
")",
"throws",
"InterruptedException",
"{",
"boolean",
"alreadyInSync",
"=",
"Thread",
".",
"currentThread",
"(",
")",
"instanceof",
"WebcamProcessor",
".",
"ProcessorThread",
";",
"if",
"(",
"alreadyInSync",
")",
"{",
"handle",
... | Process task by processor thread.
@throws InterruptedException when thread has been interrupted | [
"Process",
"task",
"by",
"processor",
"thread",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamTask.java#L35-L51 |
30,978 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java | WebcamDiscoveryService.getDevices | private static List<WebcamDevice> getDevices(List<Webcam> webcams) {
List<WebcamDevice> devices = new ArrayList<WebcamDevice>();
for (Webcam webcam : webcams) {
devices.add(webcam.getDevice());
}
return devices;
} | java | private static List<WebcamDevice> getDevices(List<Webcam> webcams) {
List<WebcamDevice> devices = new ArrayList<WebcamDevice>();
for (Webcam webcam : webcams) {
devices.add(webcam.getDevice());
}
return devices;
} | [
"private",
"static",
"List",
"<",
"WebcamDevice",
">",
"getDevices",
"(",
"List",
"<",
"Webcam",
">",
"webcams",
")",
"{",
"List",
"<",
"WebcamDevice",
">",
"devices",
"=",
"new",
"ArrayList",
"<",
"WebcamDevice",
">",
"(",
")",
";",
"for",
"(",
"Webcam"... | Get list of devices used by webcams.
@return List of webcam devices | [
"Get",
"list",
"of",
"devices",
"used",
"by",
"webcams",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java#L81-L87 |
30,979 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java | WebcamDiscoveryService.scan | public void scan() {
WebcamDiscoveryListener[] listeners = Webcam.getDiscoveryListeners();
List<WebcamDevice> tmpnew = driver.getDevices();
List<WebcamDevice> tmpold = null;
try {
tmpold = getDevices(getWebcams(Long.MAX_VALUE, TimeUnit.MILLISECONDS));
} catch (TimeoutException e) {
throw new WebcamException(e);
}
// convert to linked list due to O(1) on remove operation on
// iterator versus O(n) for the same operation in array list
List<WebcamDevice> oldones = new LinkedList<WebcamDevice>(tmpold);
List<WebcamDevice> newones = new LinkedList<WebcamDevice>(tmpnew);
Iterator<WebcamDevice> oi = oldones.iterator();
Iterator<WebcamDevice> ni = null;
WebcamDevice od = null; // old device
WebcamDevice nd = null; // new device
// reduce lists
while (oi.hasNext()) {
od = oi.next();
ni = newones.iterator();
while (ni.hasNext()) {
nd = ni.next();
// remove both elements, if device name is the same, which
// actually means that device is exactly the same
if (nd.getName().equals(od.getName())) {
ni.remove();
oi.remove();
break;
}
}
}
// if any left in old ones it means that devices has been removed
if (oldones.size() > 0) {
List<Webcam> notified = new ArrayList<Webcam>();
for (WebcamDevice device : oldones) {
for (Webcam webcam : webcams) {
if (webcam.getDevice().getName().equals(device.getName())) {
notified.add(webcam);
break;
}
}
}
setCurrentWebcams(tmpnew);
for (Webcam webcam : notified) {
notifyWebcamGone(webcam, listeners);
webcam.dispose();
}
}
// if any left in new ones it means that devices has been added
if (newones.size() > 0) {
setCurrentWebcams(tmpnew);
for (WebcamDevice device : newones) {
for (Webcam webcam : webcams) {
if (webcam.getDevice().getName().equals(device.getName())) {
notifyWebcamFound(webcam, listeners);
break;
}
}
}
}
} | java | public void scan() {
WebcamDiscoveryListener[] listeners = Webcam.getDiscoveryListeners();
List<WebcamDevice> tmpnew = driver.getDevices();
List<WebcamDevice> tmpold = null;
try {
tmpold = getDevices(getWebcams(Long.MAX_VALUE, TimeUnit.MILLISECONDS));
} catch (TimeoutException e) {
throw new WebcamException(e);
}
// convert to linked list due to O(1) on remove operation on
// iterator versus O(n) for the same operation in array list
List<WebcamDevice> oldones = new LinkedList<WebcamDevice>(tmpold);
List<WebcamDevice> newones = new LinkedList<WebcamDevice>(tmpnew);
Iterator<WebcamDevice> oi = oldones.iterator();
Iterator<WebcamDevice> ni = null;
WebcamDevice od = null; // old device
WebcamDevice nd = null; // new device
// reduce lists
while (oi.hasNext()) {
od = oi.next();
ni = newones.iterator();
while (ni.hasNext()) {
nd = ni.next();
// remove both elements, if device name is the same, which
// actually means that device is exactly the same
if (nd.getName().equals(od.getName())) {
ni.remove();
oi.remove();
break;
}
}
}
// if any left in old ones it means that devices has been removed
if (oldones.size() > 0) {
List<Webcam> notified = new ArrayList<Webcam>();
for (WebcamDevice device : oldones) {
for (Webcam webcam : webcams) {
if (webcam.getDevice().getName().equals(device.getName())) {
notified.add(webcam);
break;
}
}
}
setCurrentWebcams(tmpnew);
for (Webcam webcam : notified) {
notifyWebcamGone(webcam, listeners);
webcam.dispose();
}
}
// if any left in new ones it means that devices has been added
if (newones.size() > 0) {
setCurrentWebcams(tmpnew);
for (WebcamDevice device : newones) {
for (Webcam webcam : webcams) {
if (webcam.getDevice().getName().equals(device.getName())) {
notifyWebcamFound(webcam, listeners);
break;
}
}
}
}
} | [
"public",
"void",
"scan",
"(",
")",
"{",
"WebcamDiscoveryListener",
"[",
"]",
"listeners",
"=",
"Webcam",
".",
"getDiscoveryListeners",
"(",
")",
";",
"List",
"<",
"WebcamDevice",
">",
"tmpnew",
"=",
"driver",
".",
"getDevices",
"(",
")",
";",
"List",
"<",... | Scan for newly added or already removed webcams. | [
"Scan",
"for",
"newly",
"added",
"or",
"already",
"removed",
"webcams",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java#L152-L235 |
30,980 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java | WebcamDiscoveryService.stop | public void stop() {
// return if not running
if (!running.compareAndSet(true, false)) {
return;
}
try {
runner.join();
} catch (InterruptedException e) {
throw new WebcamException("Joint interrupted");
}
LOG.debug("Discovery service has been stopped");
runner = null;
} | java | public void stop() {
// return if not running
if (!running.compareAndSet(true, false)) {
return;
}
try {
runner.join();
} catch (InterruptedException e) {
throw new WebcamException("Joint interrupted");
}
LOG.debug("Discovery service has been stopped");
runner = null;
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"// return if not running",
"if",
"(",
"!",
"running",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"runner",
".",
"join",
"(",
")",
";",
"}",
"catch",
"(",
... | Stop discovery service. | [
"Stop",
"discovery",
"service",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java#L305-L322 |
30,981 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java | WebcamDiscoveryService.start | public void start() {
// if configured to not start, then simply return
if (!enabled.get()) {
LOG.info("Discovery service has been disabled and thus it will not be started");
return;
}
// capture driver does not support discovery - nothing to do
if (support == null) {
LOG.info("Discovery will not run - driver {} does not support this feature", driver.getClass().getSimpleName());
return;
}
// return if already running
if (!running.compareAndSet(false, true)) {
return;
}
// start discovery service runner
runner = new Thread(this, "webcam-discovery-service");
runner.setUncaughtExceptionHandler(WebcamExceptionHandler.getInstance());
runner.setDaemon(true);
runner.start();
} | java | public void start() {
// if configured to not start, then simply return
if (!enabled.get()) {
LOG.info("Discovery service has been disabled and thus it will not be started");
return;
}
// capture driver does not support discovery - nothing to do
if (support == null) {
LOG.info("Discovery will not run - driver {} does not support this feature", driver.getClass().getSimpleName());
return;
}
// return if already running
if (!running.compareAndSet(false, true)) {
return;
}
// start discovery service runner
runner = new Thread(this, "webcam-discovery-service");
runner.setUncaughtExceptionHandler(WebcamExceptionHandler.getInstance());
runner.setDaemon(true);
runner.start();
} | [
"public",
"void",
"start",
"(",
")",
"{",
"// if configured to not start, then simply return",
"if",
"(",
"!",
"enabled",
".",
"get",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Discovery service has been disabled and thus it will not be started\"",
")",
";",
"ret... | Start discovery service. | [
"Start",
"discovery",
"service",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDiscoveryService.java#L327-L355 |
30,982 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java | WebcamUpdater.start | public void start() {
if (running.compareAndSet(false, true)) {
image.set(new WebcamGetImageTask(Webcam.getDriver(), webcam.getDevice()).getImage());
executor = Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
executor.execute(this);
LOG.debug("Webcam updater has been started");
} else {
LOG.debug("Webcam updater is already started");
}
} | java | public void start() {
if (running.compareAndSet(false, true)) {
image.set(new WebcamGetImageTask(Webcam.getDriver(), webcam.getDevice()).getImage());
executor = Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
executor.execute(this);
LOG.debug("Webcam updater has been started");
} else {
LOG.debug("Webcam updater is already started");
}
} | [
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"running",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"image",
".",
"set",
"(",
"new",
"WebcamGetImageTask",
"(",
"Webcam",
".",
"getDriver",
"(",
")",
",",
"webcam",
".",
"get... | Start updater. | [
"Start",
"updater",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java#L157-L170 |
30,983 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java | WebcamUpdater.stop | public void stop() {
if (running.compareAndSet(true, false)) {
executor.shutdown();
while (!executor.isTerminated()) {
try {
executor.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return;
}
}
LOG.debug("Webcam updater has been stopped");
} else {
LOG.debug("Webcam updater is already stopped");
}
} | java | public void stop() {
if (running.compareAndSet(true, false)) {
executor.shutdown();
while (!executor.isTerminated()) {
try {
executor.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return;
}
}
LOG.debug("Webcam updater has been stopped");
} else {
LOG.debug("Webcam updater is already stopped");
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"running",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"executor",
".",
"shutdown",
"(",
")",
";",
"while",
"(",
"!",
"executor",
".",
"isTerminated",
"(",
")",
")",
"{",
"try"... | Stop updater. | [
"Stop",
"updater",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java#L175-L191 |
30,984 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java | WebcamUpdater.getImage | public BufferedImage getImage() {
int i = 0;
while (image.get() == null) {
// Just in case if another thread starts calling this method before
// updater has been properly started. This will loop while image is
// not available.
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// Return null if more than 10 seconds passed (timeout).
if (i++ > 100) {
LOG.error("Image has not been found for more than 10 seconds");
return null;
}
}
imageNew = false;
return image.get();
} | java | public BufferedImage getImage() {
int i = 0;
while (image.get() == null) {
// Just in case if another thread starts calling this method before
// updater has been properly started. This will loop while image is
// not available.
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// Return null if more than 10 seconds passed (timeout).
if (i++ > 100) {
LOG.error("Image has not been found for more than 10 seconds");
return null;
}
}
imageNew = false;
return image.get();
} | [
"public",
"BufferedImage",
"getImage",
"(",
")",
"{",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"image",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"// Just in case if another thread starts calling this method before",
"// updater has been properly started. This will ... | Return currently available image. This method will return immediately while it was been
called after camera has been open. In case when there are parallel threads running and there
is a possibility to call this method in the opening time, or before camera has been open at
all, this method will block until webcam return first image. Maximum blocking time will be 10
seconds, after this time method will return null.
@return Image stored in cache | [
"Return",
"currently",
"available",
"image",
".",
"This",
"method",
"will",
"return",
"immediately",
"while",
"it",
"was",
"been",
"called",
"after",
"camera",
"has",
"been",
"open",
".",
"In",
"case",
"when",
"there",
"are",
"parallel",
"threads",
"running",
... | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamUpdater.java#L273-L299 |
30,985 | sarxos/webcam-capture | webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDevice.java | GStreamerDevice.init | private synchronized void init() {
if (!initialized.compareAndSet(false, true)) {
return;
}
LOG.debug("GStreamer webcam device initialization");
pipe = new Pipeline(getName());
source = ElementFactory.make(GStreamerDriver.getSourceBySystem(), "source");
if (Platform.isWindows()) {
source.set("device-index", deviceIndex);
} else if (Platform.isLinux()) {
source.set("device", videoFile.getAbsolutePath());
} else if (Platform.isMacOSX()) {
throw new IllegalStateException("not yet implemented");
}
sink = new RGBDataSink(getName(), this);
sink.setPassDirectBuffer(true);
sink.getSinkElement().setMaximumLateness(LATENESS, TimeUnit.MILLISECONDS);
sink.getSinkElement().setQOSEnabled(true);
filter = ElementFactory.make("capsfilter", "capsfilter");
jpegdec = ElementFactory.make("jpegdec", "jpegdec");
pipelineReady();
resolutions = parseResolutions(source.getPads().get(0));
pipelineStop();
} | java | private synchronized void init() {
if (!initialized.compareAndSet(false, true)) {
return;
}
LOG.debug("GStreamer webcam device initialization");
pipe = new Pipeline(getName());
source = ElementFactory.make(GStreamerDriver.getSourceBySystem(), "source");
if (Platform.isWindows()) {
source.set("device-index", deviceIndex);
} else if (Platform.isLinux()) {
source.set("device", videoFile.getAbsolutePath());
} else if (Platform.isMacOSX()) {
throw new IllegalStateException("not yet implemented");
}
sink = new RGBDataSink(getName(), this);
sink.setPassDirectBuffer(true);
sink.getSinkElement().setMaximumLateness(LATENESS, TimeUnit.MILLISECONDS);
sink.getSinkElement().setQOSEnabled(true);
filter = ElementFactory.make("capsfilter", "capsfilter");
jpegdec = ElementFactory.make("jpegdec", "jpegdec");
pipelineReady();
resolutions = parseResolutions(source.getPads().get(0));
pipelineStop();
} | [
"private",
"synchronized",
"void",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"initialized",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"GStreamer webcam device initialization\"",
")",
";",
"... | Initialize webcam device. | [
"Initialize",
"webcam",
"device",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDevice.java#L112-L143 |
30,986 | sarxos/webcam-capture | webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDevice.java | GStreamerDevice.parseResolutions | private Dimension[] parseResolutions(Pad pad) {
Caps caps = pad.getCaps();
format = findPreferredFormat(caps);
LOG.debug("Best format is {}", format);
Dimension r = null;
Structure s = null;
String mime = null;
final int n = caps.size();
int i = 0;
Map<String, Dimension> map = new HashMap<String, Dimension>();
do {
s = caps.getStructure(i++);
LOG.debug("Found format structure {}", s);
mime = s.getName();
if (mime.equals(format)) {
if ((r = capStructToResolution(s)) != null) {
map.put(r.width + "x" + r.height, r);
}
}
} while (i < n);
final Dimension[] resolutions = new ArrayList<Dimension>(map.values()).toArray(new Dimension[0]);
if (LOG.isDebugEnabled()) {
for (Dimension d : resolutions) {
LOG.debug("Resolution detected {} with format {}", d, format);
}
}
return resolutions;
} | java | private Dimension[] parseResolutions(Pad pad) {
Caps caps = pad.getCaps();
format = findPreferredFormat(caps);
LOG.debug("Best format is {}", format);
Dimension r = null;
Structure s = null;
String mime = null;
final int n = caps.size();
int i = 0;
Map<String, Dimension> map = new HashMap<String, Dimension>();
do {
s = caps.getStructure(i++);
LOG.debug("Found format structure {}", s);
mime = s.getName();
if (mime.equals(format)) {
if ((r = capStructToResolution(s)) != null) {
map.put(r.width + "x" + r.height, r);
}
}
} while (i < n);
final Dimension[] resolutions = new ArrayList<Dimension>(map.values()).toArray(new Dimension[0]);
if (LOG.isDebugEnabled()) {
for (Dimension d : resolutions) {
LOG.debug("Resolution detected {} with format {}", d, format);
}
}
return resolutions;
} | [
"private",
"Dimension",
"[",
"]",
"parseResolutions",
"(",
"Pad",
"pad",
")",
"{",
"Caps",
"caps",
"=",
"pad",
".",
"getCaps",
"(",
")",
";",
"format",
"=",
"findPreferredFormat",
"(",
"caps",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Best format is {}\"",
... | Use GStreamer to get all possible resolutions.
@param pad the pad to get resolutions from
@return Array of resolutions supported by device connected with pad | [
"Use",
"GStreamer",
"to",
"get",
"all",
"possible",
"resolutions",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDevice.java#L151-L193 |
30,987 | sarxos/webcam-capture | webcam-capture-drivers/driver-jmf/src/main/java/com/github/sarxos/webcam/ds/jmf/JmfDevice.java | JmfDevice.getControl | private Control getControl(String name) {
Control control = player.getControl(name);
if (control == null) {
throw new RuntimeException("Cannot find format control " + name);
}
return control;
} | java | private Control getControl(String name) {
Control control = player.getControl(name);
if (control == null) {
throw new RuntimeException("Cannot find format control " + name);
}
return control;
} | [
"private",
"Control",
"getControl",
"(",
"String",
"name",
")",
"{",
"Control",
"control",
"=",
"player",
".",
"getControl",
"(",
"name",
")",
";",
"if",
"(",
"control",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot find format c... | Get player control.
@param name control name
@return Player control | [
"Get",
"player",
"control",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-jmf/src/main/java/com/github/sarxos/webcam/ds/jmf/JmfDevice.java#L167-L173 |
30,988 | sarxos/webcam-capture | webcam-capture-drivers/driver-jmf/src/main/java/com/github/sarxos/webcam/ds/jmf/JmfDevice.java | JmfDevice.getSizedVideoFormat | private VideoFormat getSizedVideoFormat(Dimension size) {
Format[] formats = device.getFormats();
VideoFormat format = null;
for (Format f : formats) {
if (!"RGB".equalsIgnoreCase(f.getEncoding()) || !(f instanceof VideoFormat)) {
continue;
}
Dimension d = ((VideoFormat) f).getSize();
if (d.width == size.width && d.height == size.height) {
format = (VideoFormat) f;
break;
}
}
return format;
} | java | private VideoFormat getSizedVideoFormat(Dimension size) {
Format[] formats = device.getFormats();
VideoFormat format = null;
for (Format f : formats) {
if (!"RGB".equalsIgnoreCase(f.getEncoding()) || !(f instanceof VideoFormat)) {
continue;
}
Dimension d = ((VideoFormat) f).getSize();
if (d.width == size.width && d.height == size.height) {
format = (VideoFormat) f;
break;
}
}
return format;
} | [
"private",
"VideoFormat",
"getSizedVideoFormat",
"(",
"Dimension",
"size",
")",
"{",
"Format",
"[",
"]",
"formats",
"=",
"device",
".",
"getFormats",
"(",
")",
";",
"VideoFormat",
"format",
"=",
"null",
";",
"for",
"(",
"Format",
"f",
":",
"formats",
")",
... | Get video format for size.
@param device device to get format from
@param size specific size to search
@return VideoFormat | [
"Get",
"video",
"format",
"for",
"size",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-jmf/src/main/java/com/github/sarxos/webcam/ds/jmf/JmfDevice.java#L182-L201 |
30,989 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/util/jh/JHBlurFilter.java | JHBlurFilter.premultiply | public static void premultiply(int[] p, int offset, int length) {
length += offset;
for (int i = offset; i < length; i++) {
int rgb = p[i];
int a = (rgb >> 24) & 0xff;
int r = (rgb >> 16) & 0xff;
int g = (rgb >> 8) & 0xff;
int b = rgb & 0xff;
float f = a * (1.0f / 255.0f);
r *= f;
g *= f;
b *= f;
p[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
} | java | public static void premultiply(int[] p, int offset, int length) {
length += offset;
for (int i = offset; i < length; i++) {
int rgb = p[i];
int a = (rgb >> 24) & 0xff;
int r = (rgb >> 16) & 0xff;
int g = (rgb >> 8) & 0xff;
int b = rgb & 0xff;
float f = a * (1.0f / 255.0f);
r *= f;
g *= f;
b *= f;
p[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
} | [
"public",
"static",
"void",
"premultiply",
"(",
"int",
"[",
"]",
"p",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"length",
"+=",
"offset",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
... | Premultiply a block of pixels
@param p pixels
@param offset the offset
@param length the length | [
"Premultiply",
"a",
"block",
"of",
"pixels"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/util/jh/JHBlurFilter.java#L296-L310 |
30,990 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/util/jh/JHBlurFilter.java | JHBlurFilter.clamp | public static int clamp(int x, int a, int b) {
return (x < a) ? a : (x > b) ? b : x;
} | java | public static int clamp(int x, int a, int b) {
return (x < a) ? a : (x > b) ? b : x;
} | [
"public",
"static",
"int",
"clamp",
"(",
"int",
"x",
",",
"int",
"a",
",",
"int",
"b",
")",
"{",
"return",
"(",
"x",
"<",
"a",
")",
"?",
"a",
":",
"(",
"x",
">",
"b",
")",
"?",
"b",
":",
"x",
";",
"}"
] | Clamp a value to an interval.
@param a the lower clamp threshold
@param b the upper clamp threshold
@param x the input parameter
@return the clamped value | [
"Clamp",
"a",
"value",
"to",
"an",
"interval",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/util/jh/JHBlurFilter.java#L354-L356 |
30,991 | sarxos/webcam-capture | webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java | IpCamDevice.isOnline | public boolean isOnline() {
LOG.debug("Checking online status for {} at {}", getName(), getURL());
try {
return client
.execute(new HttpHead(toURI(getURL())))
.getStatusLine()
.getStatusCode() != 404;
} catch (Exception e) {
return false;
}
} | java | public boolean isOnline() {
LOG.debug("Checking online status for {} at {}", getName(), getURL());
try {
return client
.execute(new HttpHead(toURI(getURL())))
.getStatusLine()
.getStatusCode() != 404;
} catch (Exception e) {
return false;
}
} | [
"public",
"boolean",
"isOnline",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Checking online status for {} at {}\"",
",",
"getName",
"(",
")",
",",
"getURL",
"(",
")",
")",
";",
"try",
"{",
"return",
"client",
".",
"execute",
"(",
"new",
"HttpHead",
"(",
... | This method will send HTTP HEAD request to the camera URL to check whether it's online or
offline. It's online when this request succeed and it's offline if any exception occurs or
response code is 404 Not Found.
@return True if camera is online, false otherwise | [
"This",
"method",
"will",
"send",
"HTTP",
"HEAD",
"request",
"to",
"the",
"camera",
"URL",
"to",
"check",
"whether",
"it",
"s",
"online",
"or",
"offline",
".",
"It",
"s",
"online",
"when",
"this",
"request",
"succeed",
"and",
"it",
"s",
"offline",
"if",
... | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDevice.java#L375-L385 |
30,992 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java | WebcamLock.lock | public void lock() {
if (disabled.get()) {
return;
}
if (isLocked()) {
throw new WebcamLockException(String.format("Webcam %s has already been locked", webcam.getName()));
}
if (!locked.compareAndSet(false, true)) {
return;
}
LOG.debug("Lock {}", webcam);
update();
updater = new LockUpdater();
updater.start();
} | java | public void lock() {
if (disabled.get()) {
return;
}
if (isLocked()) {
throw new WebcamLockException(String.format("Webcam %s has already been locked", webcam.getName()));
}
if (!locked.compareAndSet(false, true)) {
return;
}
LOG.debug("Lock {}", webcam);
update();
updater = new LockUpdater();
updater.start();
} | [
"public",
"void",
"lock",
"(",
")",
"{",
"if",
"(",
"disabled",
".",
"get",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"WebcamLockException",
"(",
"String",
".",
"format",
"(",
"\"Webcam %s has ... | Lock webcam. | [
"Lock",
"webcam",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java#L278-L298 |
30,993 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java | WebcamLock.disable | public void disable() {
if (disabled.compareAndSet(false, true)) {
LOG.info("Locking mechanism has been disabled in {}", webcam);
if (updater != null) {
updater.interrupt();
}
}
} | java | public void disable() {
if (disabled.compareAndSet(false, true)) {
LOG.info("Locking mechanism has been disabled in {}", webcam);
if (updater != null) {
updater.interrupt();
}
}
} | [
"public",
"void",
"disable",
"(",
")",
"{",
"if",
"(",
"disabled",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Locking mechanism has been disabled in {}\"",
",",
"webcam",
")",
";",
"if",
"(",
"updater",
"!="... | Completely disable locking mechanism. After this method is invoked, the lock will not have
any effect on the webcam runtime. | [
"Completely",
"disable",
"locking",
"mechanism",
".",
"After",
"this",
"method",
"is",
"invoked",
"the",
"lock",
"will",
"not",
"have",
"any",
"effect",
"on",
"the",
"webcam",
"runtime",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java#L304-L311 |
30,994 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java | WebcamLock.unlock | public void unlock() {
// do nothing when lock disabled
if (disabled.get()) {
return;
}
if (!locked.compareAndSet(true, false)) {
return;
}
LOG.debug("Unlock {}", webcam);
updater.interrupt();
write(-1);
if (!lock.delete()) {
lock.deleteOnExit();
}
} | java | public void unlock() {
// do nothing when lock disabled
if (disabled.get()) {
return;
}
if (!locked.compareAndSet(true, false)) {
return;
}
LOG.debug("Unlock {}", webcam);
updater.interrupt();
write(-1);
if (!lock.delete()) {
lock.deleteOnExit();
}
} | [
"public",
"void",
"unlock",
"(",
")",
"{",
"// do nothing when lock disabled\r",
"if",
"(",
"disabled",
".",
"get",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"locked",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"retur... | Unlock webcam. | [
"Unlock",
"webcam",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java#L316-L337 |
30,995 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java | WebcamLock.isLocked | public boolean isLocked() {
// always return false when lock is disabled
if (disabled.get()) {
return false;
}
// check if locked by current process
if (locked.get()) {
return true;
}
// check if locked by other process
if (!lock.exists()) {
return false;
}
long now = System.currentTimeMillis();
long tsp = read();
LOG.trace("Lock timestamp {} now {} for {}", tsp, now, webcam);
if (tsp > now - INTERVAL * 2) {
return true;
}
return false;
} | java | public boolean isLocked() {
// always return false when lock is disabled
if (disabled.get()) {
return false;
}
// check if locked by current process
if (locked.get()) {
return true;
}
// check if locked by other process
if (!lock.exists()) {
return false;
}
long now = System.currentTimeMillis();
long tsp = read();
LOG.trace("Lock timestamp {} now {} for {}", tsp, now, webcam);
if (tsp > now - INTERVAL * 2) {
return true;
}
return false;
} | [
"public",
"boolean",
"isLocked",
"(",
")",
"{",
"// always return false when lock is disabled\r",
"if",
"(",
"disabled",
".",
"get",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// check if locked by current process\r",
"if",
"(",
"locked",
".",
"get",
"(",
... | Check if webcam is locked.
@return True if webcam is locked, false otherwise | [
"Check",
"if",
"webcam",
"is",
"locked",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamLock.java#L344-L374 |
30,996 | sarxos/webcam-capture | webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/PNGDecoder.java | PNGDecoder.decode | public final BufferedImage decode() throws IOException {
if (!validPNG) {
return null;
}
ColorModel cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
SampleModel smodel = new ComponentSampleModel(DATA_TYPE, width, height, 3, width * 3, BAND_OFFSETS);
byte[] bytes = new byte[width * height * 3];// must new each time!
byte[][] data = new byte[][] { bytes };
ByteBuffer buffer = ByteBuffer.wrap(bytes);
decode(buffer, TextureFormat.RGB);
DataBufferByte dbuf = new DataBufferByte(data, bytes.length, OFFSET);
WritableRaster raster = Raster.createWritableRaster(smodel, dbuf, null);
BufferedImage bi = new BufferedImage(cmodel, raster, false, null);
bi.flush();
return bi;
} | java | public final BufferedImage decode() throws IOException {
if (!validPNG) {
return null;
}
ColorModel cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
SampleModel smodel = new ComponentSampleModel(DATA_TYPE, width, height, 3, width * 3, BAND_OFFSETS);
byte[] bytes = new byte[width * height * 3];// must new each time!
byte[][] data = new byte[][] { bytes };
ByteBuffer buffer = ByteBuffer.wrap(bytes);
decode(buffer, TextureFormat.RGB);
DataBufferByte dbuf = new DataBufferByte(data, bytes.length, OFFSET);
WritableRaster raster = Raster.createWritableRaster(smodel, dbuf, null);
BufferedImage bi = new BufferedImage(cmodel, raster, false, null);
bi.flush();
return bi;
} | [
"public",
"final",
"BufferedImage",
"decode",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"validPNG",
")",
"{",
"return",
"null",
";",
"}",
"ColorModel",
"cmodel",
"=",
"new",
"ComponentColorModel",
"(",
"COLOR_SPACE",
",",
"BITS",
",",
"false",
... | read just one png file, if invalid, return null
@return
@throws IOException | [
"read",
"just",
"one",
"png",
"file",
"if",
"invalid",
"return",
"null"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/PNGDecoder.java#L134-L151 |
30,997 | sarxos/webcam-capture | webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/IPCDriver.java | IPCDriver.parseArguments | protected void parseArguments(final Options options, String[] cmdArray) {
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, cmdArray);
Option[] opts = cmd.getOptions();
for (Option o : opts) {
arguments.put(o.getLongOpt(), o.getValue() == null ? "" : o.getValue());
}
} catch (ParseException e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MSG_WRONG_ARGUMENT);
}
e.printStackTrace();
}
} | java | protected void parseArguments(final Options options, String[] cmdArray) {
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, cmdArray);
Option[] opts = cmd.getOptions();
for (Option o : opts) {
arguments.put(o.getLongOpt(), o.getValue() == null ? "" : o.getValue());
}
} catch (ParseException e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MSG_WRONG_ARGUMENT);
}
e.printStackTrace();
}
} | [
"protected",
"void",
"parseArguments",
"(",
"final",
"Options",
"options",
",",
"String",
"[",
"]",
"cmdArray",
")",
"{",
"CommandLineParser",
"parser",
"=",
"new",
"PosixParser",
"(",
")",
";",
"try",
"{",
"CommandLine",
"cmd",
"=",
"parser",
".",
"parse",
... | parse arguments and add to arguments
@param options
@param cmdArray | [
"parse",
"arguments",
"and",
"add",
"to",
"arguments"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-raspberrypi/src/main/java/com/github/sarxos/webcam/ds/raspberrypi/IPCDriver.java#L90-L104 |
30,998 | sarxos/webcam-capture | webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDriver.java | GStreamerDriver.setPreferredFormats | public void setPreferredFormats(List<String> preferredFormats) {
if (preferredFormats.isEmpty()) {
throw new IllegalArgumentException("Preferred formats list must not be empty");
}
this.preferredFormats = new ArrayList<>(preferredFormats);
} | java | public void setPreferredFormats(List<String> preferredFormats) {
if (preferredFormats.isEmpty()) {
throw new IllegalArgumentException("Preferred formats list must not be empty");
}
this.preferredFormats = new ArrayList<>(preferredFormats);
} | [
"public",
"void",
"setPreferredFormats",
"(",
"List",
"<",
"String",
">",
"preferredFormats",
")",
"{",
"if",
"(",
"preferredFormats",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Preferred formats list must not be empty\"",
... | Set preferred video formats for this driver. First formats from the list are better and will
be selected if available. | [
"Set",
"preferred",
"video",
"formats",
"for",
"this",
"driver",
".",
"First",
"formats",
"from",
"the",
"list",
"are",
"better",
"and",
"will",
"be",
"selected",
"if",
"available",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-gstreamer/src/main/java/com/github/sarxos/webcam/ds/gstreamer/GStreamerDriver.java#L118-L123 |
30,999 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java | WebcamDriverUtils.findDriver | protected static WebcamDriver findDriver(List<String> names, List<Class<?>> classes) {
for (String name : names) {
LOG.info("Searching driver {}", name);
Class<?> clazz = null;
for (Class<?> c : classes) {
if (c.getCanonicalName().equals(name)) {
clazz = c;
break;
}
}
if (clazz == null) {
try {
clazz = Class.forName(name);
} catch (ClassNotFoundException e) {
LOG.trace("Class not found {}, fall thru", name);
}
}
if (clazz == null) {
LOG.debug("Driver {} not found", name);
continue;
}
LOG.info("Webcam driver {} has been found", name);
try {
return (WebcamDriver) clazz.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return null;
} | java | protected static WebcamDriver findDriver(List<String> names, List<Class<?>> classes) {
for (String name : names) {
LOG.info("Searching driver {}", name);
Class<?> clazz = null;
for (Class<?> c : classes) {
if (c.getCanonicalName().equals(name)) {
clazz = c;
break;
}
}
if (clazz == null) {
try {
clazz = Class.forName(name);
} catch (ClassNotFoundException e) {
LOG.trace("Class not found {}, fall thru", name);
}
}
if (clazz == null) {
LOG.debug("Driver {} not found", name);
continue;
}
LOG.info("Webcam driver {} has been found", name);
try {
return (WebcamDriver) clazz.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return null;
} | [
"protected",
"static",
"WebcamDriver",
"findDriver",
"(",
"List",
"<",
"String",
">",
"names",
",",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
")",
"{",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Searc... | Find webcam driver. Scan packages to search drivers specified in the
argument.
@param names array of driver names to search for
@return Driver if found or throw exception
@throw WebcamException | [
"Find",
"webcam",
"driver",
".",
"Scan",
"packages",
"to",
"search",
"drivers",
"specified",
"in",
"the",
"argument",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java#L29-L69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.