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
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,500 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.column
|
public ColumnModel column(String columnName) {// NOSONAR
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(columnName))
return columnModel;
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(columnName))
return columnModel;
}
return addColumn(columnName);
}
|
java
|
public ColumnModel column(String columnName) {// NOSONAR
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(columnName))
return columnModel;
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(columnName))
return columnModel;
}
return addColumn(columnName);
}
|
[
"public",
"ColumnModel",
"column",
"(",
"String",
"columnName",
")",
"{",
"// NOSONAR",
"for",
"(",
"ColumnModel",
"columnModel",
":",
"columns",
")",
"{",
"if",
"(",
"columnModel",
".",
"getColumnName",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getColumnName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"return",
"columnModel",
";",
"if",
"(",
"columnModel",
".",
"getEntityField",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getEntityField",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"return",
"columnModel",
";",
"}",
"return",
"addColumn",
"(",
"columnName",
")",
";",
"}"
] |
find column in tableModel by given columnName, if not found, add a new column
with columnName
|
[
"find",
"column",
"in",
"tableModel",
"by",
"given",
"columnName",
"if",
"not",
"found",
"add",
"a",
"new",
"column",
"with",
"columnName"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L240-L248
|
2,501 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.addColumn
|
public ColumnModel addColumn(String columnName) {
checkReadOnly();
DialectException.assureNotEmpty(columnName, "columnName can not be empty");
for (ColumnModel columnModel : columns)
if (columnName.equalsIgnoreCase(columnModel.getColumnName()))
throw new DialectException("ColumnModel name '" + columnName + "' already existed");
ColumnModel column = new ColumnModel(columnName);
addColumn(column);
return column;
}
|
java
|
public ColumnModel addColumn(String columnName) {
checkReadOnly();
DialectException.assureNotEmpty(columnName, "columnName can not be empty");
for (ColumnModel columnModel : columns)
if (columnName.equalsIgnoreCase(columnModel.getColumnName()))
throw new DialectException("ColumnModel name '" + columnName + "' already existed");
ColumnModel column = new ColumnModel(columnName);
addColumn(column);
return column;
}
|
[
"public",
"ColumnModel",
"addColumn",
"(",
"String",
"columnName",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"DialectException",
".",
"assureNotEmpty",
"(",
"columnName",
",",
"\"columnName can not be empty\"",
")",
";",
"for",
"(",
"ColumnModel",
"columnModel",
":",
"columns",
")",
"if",
"(",
"columnName",
".",
"equalsIgnoreCase",
"(",
"columnModel",
".",
"getColumnName",
"(",
")",
")",
")",
"throw",
"new",
"DialectException",
"(",
"\"ColumnModel name '\"",
"+",
"columnName",
"+",
"\"' already existed\"",
")",
";",
"ColumnModel",
"column",
"=",
"new",
"ColumnModel",
"(",
"columnName",
")",
";",
"addColumn",
"(",
"column",
")",
";",
"return",
"column",
";",
"}"
] |
Add a column with given columnName to tableModel
@param columnName
@return the Column object
|
[
"Add",
"a",
"column",
"with",
"given",
"columnName",
"to",
"tableModel"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L256-L265
|
2,502 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getColumn
|
public ColumnModel getColumn(String colOrFieldName) {
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(colOrFieldName))
return columnModel;
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(colOrFieldName))
return columnModel;
}
return null;
}
|
java
|
public ColumnModel getColumn(String colOrFieldName) {
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(colOrFieldName))
return columnModel;
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(colOrFieldName))
return columnModel;
}
return null;
}
|
[
"public",
"ColumnModel",
"getColumn",
"(",
"String",
"colOrFieldName",
")",
"{",
"for",
"(",
"ColumnModel",
"columnModel",
":",
"columns",
")",
"{",
"if",
"(",
"columnModel",
".",
"getColumnName",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getColumnName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"colOrFieldName",
")",
")",
"return",
"columnModel",
";",
"if",
"(",
"columnModel",
".",
"getEntityField",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getEntityField",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"colOrFieldName",
")",
")",
"return",
"columnModel",
";",
"}",
"return",
"null",
";",
"}"
] |
Get ColumnModel by column Name or field name ignore case, if not found,
return null
|
[
"Get",
"ColumnModel",
"by",
"column",
"Name",
"or",
"field",
"name",
"ignore",
"case",
"if",
"not",
"found",
"return",
"null"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L271-L279
|
2,503 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getColumnByColName
|
public ColumnModel getColumnByColName(String colName) {
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(colName))
return columnModel;
}
return null;
}
|
java
|
public ColumnModel getColumnByColName(String colName) {
for (ColumnModel columnModel : columns) {
if (columnModel.getColumnName() != null && columnModel.getColumnName().equalsIgnoreCase(colName))
return columnModel;
}
return null;
}
|
[
"public",
"ColumnModel",
"getColumnByColName",
"(",
"String",
"colName",
")",
"{",
"for",
"(",
"ColumnModel",
"columnModel",
":",
"columns",
")",
"{",
"if",
"(",
"columnModel",
".",
"getColumnName",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getColumnName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"colName",
")",
")",
"return",
"columnModel",
";",
"}",
"return",
"null",
";",
"}"
] |
Get ColumnModel by columnName ignore case, if not found, return null
|
[
"Get",
"ColumnModel",
"by",
"columnName",
"ignore",
"case",
"if",
"not",
"found",
"return",
"null"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L284-L290
|
2,504 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getColumnByFieldName
|
public ColumnModel getColumnByFieldName(String fieldName) {
for (ColumnModel columnModel : columns)
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(fieldName))
return columnModel;
return null;
}
|
java
|
public ColumnModel getColumnByFieldName(String fieldName) {
for (ColumnModel columnModel : columns)
if (columnModel.getEntityField() != null && columnModel.getEntityField().equalsIgnoreCase(fieldName))
return columnModel;
return null;
}
|
[
"public",
"ColumnModel",
"getColumnByFieldName",
"(",
"String",
"fieldName",
")",
"{",
"for",
"(",
"ColumnModel",
"columnModel",
":",
"columns",
")",
"if",
"(",
"columnModel",
".",
"getEntityField",
"(",
")",
"!=",
"null",
"&&",
"columnModel",
".",
"getEntityField",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"fieldName",
")",
")",
"return",
"columnModel",
";",
"return",
"null",
";",
"}"
] |
Get ColumnModel by entity field name ignore case, if not found, return null
|
[
"Get",
"ColumnModel",
"by",
"entity",
"field",
"name",
"ignore",
"case",
"if",
"not",
"found",
"return",
"null"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L295-L300
|
2,505 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getFkey
|
public FKeyModel getFkey(String fkeyName) {
if (fkeyConstraints == null)
return null;
for (FKeyModel fkey : fkeyConstraints)
if (!StrUtils.isEmpty(fkeyName) && fkeyName.equalsIgnoreCase(fkey.getFkeyName()))
return fkey;
return null;
}
|
java
|
public FKeyModel getFkey(String fkeyName) {
if (fkeyConstraints == null)
return null;
for (FKeyModel fkey : fkeyConstraints)
if (!StrUtils.isEmpty(fkeyName) && fkeyName.equalsIgnoreCase(fkey.getFkeyName()))
return fkey;
return null;
}
|
[
"public",
"FKeyModel",
"getFkey",
"(",
"String",
"fkeyName",
")",
"{",
"if",
"(",
"fkeyConstraints",
"==",
"null",
")",
"return",
"null",
";",
"for",
"(",
"FKeyModel",
"fkey",
":",
"fkeyConstraints",
")",
"if",
"(",
"!",
"StrUtils",
".",
"isEmpty",
"(",
"fkeyName",
")",
"&&",
"fkeyName",
".",
"equalsIgnoreCase",
"(",
"fkey",
".",
"getFkeyName",
"(",
")",
")",
")",
"return",
"fkey",
";",
"return",
"null",
";",
"}"
] |
Get a FKeyModel by given fkeyName
|
[
"Get",
"a",
"FKeyModel",
"by",
"given",
"fkeyName"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L350-L357
|
2,506 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getIdGenerator
|
public IdGenerator getIdGenerator(GenerationType generationType, String name) {
return getIdGenerator(generationType, name, getIdGenerators());
}
|
java
|
public IdGenerator getIdGenerator(GenerationType generationType, String name) {
return getIdGenerator(generationType, name, getIdGenerators());
}
|
[
"public",
"IdGenerator",
"getIdGenerator",
"(",
"GenerationType",
"generationType",
",",
"String",
"name",
")",
"{",
"return",
"getIdGenerator",
"(",
"generationType",
",",
"name",
",",
"getIdGenerators",
"(",
")",
")",
";",
"}"
] |
Search and return the IdGenerator in this TableModel by its generationType
and name
|
[
"Search",
"and",
"return",
"the",
"IdGenerator",
"in",
"this",
"TableModel",
"by",
"its",
"generationType",
"and",
"name"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L420-L422
|
2,507 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getIdGenerator
|
public static IdGenerator getIdGenerator(GenerationType generationType, String name,
List<IdGenerator> idGeneratorList) {
// fixed idGenerators
IdGenerator idGen = getIdGeneratorByType(generationType);
if (idGen != null)
return idGen;
if (StrUtils.isEmpty(name))
return null;
for (IdGenerator idGenerator : idGeneratorList) {
if (generationType != null && name.equalsIgnoreCase(idGenerator.getIdGenName()))
return idGenerator;
if ((generationType == null || GenerationType.OTHER.equals(generationType))
&& name.equalsIgnoreCase(idGenerator.getIdGenName()))
return idGenerator;
}
return null;
}
|
java
|
public static IdGenerator getIdGenerator(GenerationType generationType, String name,
List<IdGenerator> idGeneratorList) {
// fixed idGenerators
IdGenerator idGen = getIdGeneratorByType(generationType);
if (idGen != null)
return idGen;
if (StrUtils.isEmpty(name))
return null;
for (IdGenerator idGenerator : idGeneratorList) {
if (generationType != null && name.equalsIgnoreCase(idGenerator.getIdGenName()))
return idGenerator;
if ((generationType == null || GenerationType.OTHER.equals(generationType))
&& name.equalsIgnoreCase(idGenerator.getIdGenName()))
return idGenerator;
}
return null;
}
|
[
"public",
"static",
"IdGenerator",
"getIdGenerator",
"(",
"GenerationType",
"generationType",
",",
"String",
"name",
",",
"List",
"<",
"IdGenerator",
">",
"idGeneratorList",
")",
"{",
"// fixed idGenerators",
"IdGenerator",
"idGen",
"=",
"getIdGeneratorByType",
"(",
"generationType",
")",
";",
"if",
"(",
"idGen",
"!=",
"null",
")",
"return",
"idGen",
";",
"if",
"(",
"StrUtils",
".",
"isEmpty",
"(",
"name",
")",
")",
"return",
"null",
";",
"for",
"(",
"IdGenerator",
"idGenerator",
":",
"idGeneratorList",
")",
"{",
"if",
"(",
"generationType",
"!=",
"null",
"&&",
"name",
".",
"equalsIgnoreCase",
"(",
"idGenerator",
".",
"getIdGenName",
"(",
")",
")",
")",
"return",
"idGenerator",
";",
"if",
"(",
"(",
"generationType",
"==",
"null",
"||",
"GenerationType",
".",
"OTHER",
".",
"equals",
"(",
"generationType",
")",
")",
"&&",
"name",
".",
"equalsIgnoreCase",
"(",
"idGenerator",
".",
"getIdGenName",
"(",
")",
")",
")",
"return",
"idGenerator",
";",
"}",
"return",
"null",
";",
"}"
] |
Get a IdGenerator by type, if not found, search by name
|
[
"Get",
"a",
"IdGenerator",
"by",
"type",
"if",
"not",
"found",
"search",
"by",
"name"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L469-L485
|
2,508 |
drinkjava2/jDialects
|
core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java
|
TableModel.getPKeyColsSortByColumnName
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<ColumnModel> getPKeyColsSortByColumnName() {
List<ColumnModel> pkeyCols = new ArrayList<ColumnModel>();
for (ColumnModel col : columns)
if (col.getPkey() && !col.getTransientable())
pkeyCols.add(col);
Collections.sort(pkeyCols, new Comparator() {
public int compare(Object o1, Object o2) {
return ((ColumnModel) o1).getColumnName().compareTo(((ColumnModel) o1).getColumnName());
}
});
return pkeyCols;
}
|
java
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<ColumnModel> getPKeyColsSortByColumnName() {
List<ColumnModel> pkeyCols = new ArrayList<ColumnModel>();
for (ColumnModel col : columns)
if (col.getPkey() && !col.getTransientable())
pkeyCols.add(col);
Collections.sort(pkeyCols, new Comparator() {
public int compare(Object o1, Object o2) {
return ((ColumnModel) o1).getColumnName().compareTo(((ColumnModel) o1).getColumnName());
}
});
return pkeyCols;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"List",
"<",
"ColumnModel",
">",
"getPKeyColsSortByColumnName",
"(",
")",
"{",
"List",
"<",
"ColumnModel",
">",
"pkeyCols",
"=",
"new",
"ArrayList",
"<",
"ColumnModel",
">",
"(",
")",
";",
"for",
"(",
"ColumnModel",
"col",
":",
"columns",
")",
"if",
"(",
"col",
".",
"getPkey",
"(",
")",
"&&",
"!",
"col",
".",
"getTransientable",
"(",
")",
")",
"pkeyCols",
".",
"add",
"(",
"col",
")",
";",
"Collections",
".",
"sort",
"(",
"pkeyCols",
",",
"new",
"Comparator",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"Object",
"o1",
",",
"Object",
"o2",
")",
"{",
"return",
"(",
"(",
"ColumnModel",
")",
"o1",
")",
".",
"getColumnName",
"(",
")",
".",
"compareTo",
"(",
"(",
"(",
"ColumnModel",
")",
"o1",
")",
".",
"getColumnName",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"pkeyCols",
";",
"}"
] |
Get pkey columns sorted by column name
|
[
"Get",
"pkey",
"columns",
"sorted",
"by",
"column",
"name"
] |
1c165f09c6042a599b681c279024abcc1b848b88
|
https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L503-L515
|
2,509 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java
|
FileTools.createReaderForFile
|
public static Reader createReaderForFile(File source, Encoding encoding)
throws FileNotFoundException, UnsupportedEncodingException
{
return createReaderForInputStream(new FileInputStream(source), encoding);
}
|
java
|
public static Reader createReaderForFile(File source, Encoding encoding)
throws FileNotFoundException, UnsupportedEncodingException
{
return createReaderForInputStream(new FileInputStream(source), encoding);
}
|
[
"public",
"static",
"Reader",
"createReaderForFile",
"(",
"File",
"source",
",",
"Encoding",
"encoding",
")",
"throws",
"FileNotFoundException",
",",
"UnsupportedEncodingException",
"{",
"return",
"createReaderForInputStream",
"(",
"new",
"FileInputStream",
"(",
"source",
")",
",",
"encoding",
")",
";",
"}"
] |
Instanciate a Reader for a file using the given encoding.
@param source
source file.
@param encoding
can be <code>null</code>
@return the reader.
@throws FileNotFoundException
if there is a problem to deal with.
@throws UnsupportedEncodingException
if there is a problem to deal with.
@since 12.06.01
|
[
"Instanciate",
"a",
"Reader",
"for",
"a",
"file",
"using",
"the",
"given",
"encoding",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java#L131-L135
|
2,510 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java
|
FileTools.loadBundle
|
public static Map<String, String> loadBundle(List<URL> sources, Encoding encoding, String newline)
throws IOException, SyntaxErrorException
{
Map<String, String> _result = new HashMap<String, String>();
for (URL _source : sources)
{
Map<String, String> _properties = loadProperties(_source.openStream(), encoding, newline);
_result.putAll(_properties);
}
return _result;
}
|
java
|
public static Map<String, String> loadBundle(List<URL> sources, Encoding encoding, String newline)
throws IOException, SyntaxErrorException
{
Map<String, String> _result = new HashMap<String, String>();
for (URL _source : sources)
{
Map<String, String> _properties = loadProperties(_source.openStream(), encoding, newline);
_result.putAll(_properties);
}
return _result;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"loadBundle",
"(",
"List",
"<",
"URL",
">",
"sources",
",",
"Encoding",
"encoding",
",",
"String",
"newline",
")",
"throws",
"IOException",
",",
"SyntaxErrorException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"_result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"URL",
"_source",
":",
"sources",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"_properties",
"=",
"loadProperties",
"(",
"_source",
".",
"openStream",
"(",
")",
",",
"encoding",
",",
"newline",
")",
";",
"_result",
".",
"putAll",
"(",
"_properties",
")",
";",
"}",
"return",
"_result",
";",
"}"
] |
Load a collection of properties files into the same Map, supports multiple lines values.
@param sources
the list of properties files to load.
@param encoding
the encoding of the files.
@param newline
the sequence to use as a line separator for multiple line values.
@return the properties, merged following the rules "the last speaker is right".
@throws IOException
if there is a problem to deal with, especially if one of the URL points to nothing.
@throws SyntaxErrorException
if there is a problem to deal with.
@see LineByLinePropertyParser
@since 16.08.02
|
[
"Load",
"a",
"collection",
"of",
"properties",
"files",
"into",
"the",
"same",
"Map",
"supports",
"multiple",
"lines",
"values",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java#L214-L224
|
2,511 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java
|
FileTools.loadResourceBundle
|
public static Map<String, String> loadResourceBundle(String bundleName, Encoding encoding, String newline)
throws IOException, SyntaxErrorException, MissingResourceException
{
return loadResourceBundle(bundleName, encoding, newline, Locale.getDefault());
}
|
java
|
public static Map<String, String> loadResourceBundle(String bundleName, Encoding encoding, String newline)
throws IOException, SyntaxErrorException, MissingResourceException
{
return loadResourceBundle(bundleName, encoding, newline, Locale.getDefault());
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"loadResourceBundle",
"(",
"String",
"bundleName",
",",
"Encoding",
"encoding",
",",
"String",
"newline",
")",
"throws",
"IOException",
",",
"SyntaxErrorException",
",",
"MissingResourceException",
"{",
"return",
"loadResourceBundle",
"(",
"bundleName",
",",
"encoding",
",",
"newline",
",",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}"
] |
Load a properties file looking for localized versions like ResourceBundle, using the default Locale, supporting multiple line
values.
@param bundleName
the bundle name, like <code>com.foo.MyBundle</code>.
@param encoding
the encoding of the bundle files.
@param newline
the sequence to use as a line separator for multiple line values.
@return the properties, merged like a Java ResourceBundle.
@throws IOException
if there is a problem to deal with.
@throws SyntaxErrorException
if there is a problem to deal with.
@throws MissingResourceException
if no file at all is found.
@see LineByLinePropertyParser
@since 16.08.02
|
[
"Load",
"a",
"properties",
"file",
"looking",
"for",
"localized",
"versions",
"like",
"ResourceBundle",
"using",
"the",
"default",
"Locale",
"supporting",
"multiple",
"line",
"values",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java#L288-L292
|
2,512 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java
|
FileTools.loadResourceBundle
|
public static Map<String, String> loadResourceBundle(String bundleName, Encoding encoding, String newline, Locale locale)
throws IOException, SyntaxErrorException, MissingResourceException
{
String _baseName = bundleName.replace(".", "/");
List<URL> _bundle = new ArrayList<URL>(3);
URL _resource = FileTools.class.getClassLoader().getResource(_baseName + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
if (null != locale && IS_NOT_EMPTY.test(locale.getLanguage()))
{
_resource = FileTools.class.getClassLoader()
.getResource(_baseName + "_" + locale.getLanguage() + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
if (IS_NOT_EMPTY.test(locale.getCountry()))
{
_resource = FileTools.class.getClassLoader().getResource(
_baseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
}
}
if (_bundle.isEmpty())
{
throw new MissingResourceException(bundleName, null, null);
}
return loadBundle(_bundle, encoding, newline);
}
|
java
|
public static Map<String, String> loadResourceBundle(String bundleName, Encoding encoding, String newline, Locale locale)
throws IOException, SyntaxErrorException, MissingResourceException
{
String _baseName = bundleName.replace(".", "/");
List<URL> _bundle = new ArrayList<URL>(3);
URL _resource = FileTools.class.getClassLoader().getResource(_baseName + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
if (null != locale && IS_NOT_EMPTY.test(locale.getLanguage()))
{
_resource = FileTools.class.getClassLoader()
.getResource(_baseName + "_" + locale.getLanguage() + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
if (IS_NOT_EMPTY.test(locale.getCountry()))
{
_resource = FileTools.class.getClassLoader().getResource(
_baseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + FILE_EXTENSION__PROPERTIES);
if (null != _resource)
{
_bundle.add(_resource);
}
}
}
if (_bundle.isEmpty())
{
throw new MissingResourceException(bundleName, null, null);
}
return loadBundle(_bundle, encoding, newline);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"loadResourceBundle",
"(",
"String",
"bundleName",
",",
"Encoding",
"encoding",
",",
"String",
"newline",
",",
"Locale",
"locale",
")",
"throws",
"IOException",
",",
"SyntaxErrorException",
",",
"MissingResourceException",
"{",
"String",
"_baseName",
"=",
"bundleName",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
";",
"List",
"<",
"URL",
">",
"_bundle",
"=",
"new",
"ArrayList",
"<",
"URL",
">",
"(",
"3",
")",
";",
"URL",
"_resource",
"=",
"FileTools",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"_baseName",
"+",
"FILE_EXTENSION__PROPERTIES",
")",
";",
"if",
"(",
"null",
"!=",
"_resource",
")",
"{",
"_bundle",
".",
"add",
"(",
"_resource",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"locale",
"&&",
"IS_NOT_EMPTY",
".",
"test",
"(",
"locale",
".",
"getLanguage",
"(",
")",
")",
")",
"{",
"_resource",
"=",
"FileTools",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"_baseName",
"+",
"\"_\"",
"+",
"locale",
".",
"getLanguage",
"(",
")",
"+",
"FILE_EXTENSION__PROPERTIES",
")",
";",
"if",
"(",
"null",
"!=",
"_resource",
")",
"{",
"_bundle",
".",
"add",
"(",
"_resource",
")",
";",
"}",
"if",
"(",
"IS_NOT_EMPTY",
".",
"test",
"(",
"locale",
".",
"getCountry",
"(",
")",
")",
")",
"{",
"_resource",
"=",
"FileTools",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"_baseName",
"+",
"\"_\"",
"+",
"locale",
".",
"getLanguage",
"(",
")",
"+",
"\"_\"",
"+",
"locale",
".",
"getCountry",
"(",
")",
"+",
"FILE_EXTENSION__PROPERTIES",
")",
";",
"if",
"(",
"null",
"!=",
"_resource",
")",
"{",
"_bundle",
".",
"add",
"(",
"_resource",
")",
";",
"}",
"}",
"}",
"if",
"(",
"_bundle",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"MissingResourceException",
"(",
"bundleName",
",",
"null",
",",
"null",
")",
";",
"}",
"return",
"loadBundle",
"(",
"_bundle",
",",
"encoding",
",",
"newline",
")",
";",
"}"
] |
Load a properties file looking for localized versions like ResourceBundle, supporting multiple line values.
@param bundleName
the bundle name, like <code>com.foo.MyBundle</code>.
@param encoding
the encoding of the bundle files.
@param newline
the sequence to use as a line separator for multiple line values.
@param locale
the locale to use to compute the name of the localized resources.
@return the properties, merged like a Java ResourceBundle.
@throws IOException
if there is a problem to deal with.
@throws SyntaxErrorException
if there is a problem to deal with.
@throws MissingResourceException
if no file at all is found.
@see LineByLinePropertyParser
@since 16.08.02
|
[
"Load",
"a",
"properties",
"file",
"looking",
"for",
"localized",
"versions",
"like",
"ResourceBundle",
"supporting",
"multiple",
"line",
"values",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java#L315-L348
|
2,513 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java
|
FileTools.readPropertiesToListeners
|
public static void readPropertiesToListeners(InputStream source, Encoding encoding, PropertiesParsingListener... listeners)
throws IOException, SyntaxErrorException
{
BufferedReader _reader = new BufferedReader(createReaderForInputStream(source, encoding));
LineByLinePropertyParser _parser = new LineByLinePropertyParser();
for (PropertiesParsingListener _listener : listeners)
{
_parser.addListener(_listener);
}
for (String _line = _reader.readLine(); _line != null;)
{
_parser.parseLine(_line);
_line = _reader.readLine();
}
_reader.close();
}
|
java
|
public static void readPropertiesToListeners(InputStream source, Encoding encoding, PropertiesParsingListener... listeners)
throws IOException, SyntaxErrorException
{
BufferedReader _reader = new BufferedReader(createReaderForInputStream(source, encoding));
LineByLinePropertyParser _parser = new LineByLinePropertyParser();
for (PropertiesParsingListener _listener : listeners)
{
_parser.addListener(_listener);
}
for (String _line = _reader.readLine(); _line != null;)
{
_parser.parseLine(_line);
_line = _reader.readLine();
}
_reader.close();
}
|
[
"public",
"static",
"void",
"readPropertiesToListeners",
"(",
"InputStream",
"source",
",",
"Encoding",
"encoding",
",",
"PropertiesParsingListener",
"...",
"listeners",
")",
"throws",
"IOException",
",",
"SyntaxErrorException",
"{",
"BufferedReader",
"_reader",
"=",
"new",
"BufferedReader",
"(",
"createReaderForInputStream",
"(",
"source",
",",
"encoding",
")",
")",
";",
"LineByLinePropertyParser",
"_parser",
"=",
"new",
"LineByLinePropertyParser",
"(",
")",
";",
"for",
"(",
"PropertiesParsingListener",
"_listener",
":",
"listeners",
")",
"{",
"_parser",
".",
"addListener",
"(",
"_listener",
")",
";",
"}",
"for",
"(",
"String",
"_line",
"=",
"_reader",
".",
"readLine",
"(",
")",
";",
"_line",
"!=",
"null",
";",
")",
"{",
"_parser",
".",
"parseLine",
"(",
"_line",
")",
";",
"_line",
"=",
"_reader",
".",
"readLine",
"(",
")",
";",
"}",
"_reader",
".",
"close",
"(",
")",
";",
"}"
] |
Read a file of properties and notifies all the listeners for each property.
@param source
the source input stream.
@param encoding
the encoding of the file.
@param listeners
a list of any {@link PropertiesParsingListener}
@throws IOException
@throws SyntaxErrorException
@throws IOException
if there is a problem to deal with.
@throws SyntaxErrorException
if there is a problem to deal with.
@see LineByLinePropertyParser
@since 16.09.00
|
[
"Read",
"a",
"file",
"of",
"properties",
"and",
"notifies",
"all",
"the",
"listeners",
"for",
"each",
"property",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/FileTools.java#L368-L384
|
2,514 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcConfiguration.java
|
XIncProcConfiguration.setConfigurationProperty
|
public void setConfigurationProperty(final String name, final Object value)
{
if (XIncProcConfiguration.ALLOW_FIXUP_BASE_URIS.equals(name))
{
if (value instanceof Boolean)
{
this.baseUrisFixup = (Boolean) value;
}
else if (value instanceof String)
{
this.baseUrisFixup = Boolean.valueOf((String) value);
}
}
if (XIncProcConfiguration.ALLOW_FIXUP_LANGUAGE.equals(name))
{
if (value instanceof Boolean)
{
this.languageFixup = (Boolean) value;
}
else if (value instanceof String)
{
this.languageFixup = Boolean.valueOf((String) value);
}
}
}
|
java
|
public void setConfigurationProperty(final String name, final Object value)
{
if (XIncProcConfiguration.ALLOW_FIXUP_BASE_URIS.equals(name))
{
if (value instanceof Boolean)
{
this.baseUrisFixup = (Boolean) value;
}
else if (value instanceof String)
{
this.baseUrisFixup = Boolean.valueOf((String) value);
}
}
if (XIncProcConfiguration.ALLOW_FIXUP_LANGUAGE.equals(name))
{
if (value instanceof Boolean)
{
this.languageFixup = (Boolean) value;
}
else if (value instanceof String)
{
this.languageFixup = Boolean.valueOf((String) value);
}
}
}
|
[
"public",
"void",
"setConfigurationProperty",
"(",
"final",
"String",
"name",
",",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"XIncProcConfiguration",
".",
"ALLOW_FIXUP_BASE_URIS",
".",
"equals",
"(",
"name",
")",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"this",
".",
"baseUrisFixup",
"=",
"(",
"Boolean",
")",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"this",
".",
"baseUrisFixup",
"=",
"Boolean",
".",
"valueOf",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"}",
"if",
"(",
"XIncProcConfiguration",
".",
"ALLOW_FIXUP_LANGUAGE",
".",
"equals",
"(",
"name",
")",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"this",
".",
"languageFixup",
"=",
"(",
"Boolean",
")",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"this",
".",
"languageFixup",
"=",
"Boolean",
".",
"valueOf",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"}",
"}"
] |
Sets configuration property.
@param name the name
@param value the value
|
[
"Sets",
"configuration",
"property",
"."
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcConfiguration.java#L93-L117
|
2,515 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java
|
AbstractTextFileConverter.translateEncoding
|
private static String translateEncoding(final String encodingName) throws UnsupportedEncodingException
{
try
{
String _encoding = encodingName.trim().toLowerCase();
String _encodingCode = theEncodingResource.getString(_encoding);
return _encodingCode;
} // try
catch (MissingResourceException _exception)
{
throw new UnsupportedEncodingException(theMessageUnsupportedEncoding + encodingName);
} // catch(MissingResourceException _exception)
catch (Exception _exception)
{
throw new UnsupportedEncodingException(theMessageErrorTranslatingEncoding + encodingName);
} // catch (Exception _exception)
}
|
java
|
private static String translateEncoding(final String encodingName) throws UnsupportedEncodingException
{
try
{
String _encoding = encodingName.trim().toLowerCase();
String _encodingCode = theEncodingResource.getString(_encoding);
return _encodingCode;
} // try
catch (MissingResourceException _exception)
{
throw new UnsupportedEncodingException(theMessageUnsupportedEncoding + encodingName);
} // catch(MissingResourceException _exception)
catch (Exception _exception)
{
throw new UnsupportedEncodingException(theMessageErrorTranslatingEncoding + encodingName);
} // catch (Exception _exception)
}
|
[
"private",
"static",
"String",
"translateEncoding",
"(",
"final",
"String",
"encodingName",
")",
"throws",
"UnsupportedEncodingException",
"{",
"try",
"{",
"String",
"_encoding",
"=",
"encodingName",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"String",
"_encodingCode",
"=",
"theEncodingResource",
".",
"getString",
"(",
"_encoding",
")",
";",
"return",
"_encodingCode",
";",
"}",
"// try",
"catch",
"(",
"MissingResourceException",
"_exception",
")",
"{",
"throw",
"new",
"UnsupportedEncodingException",
"(",
"theMessageUnsupportedEncoding",
"+",
"encodingName",
")",
";",
"}",
"// catch(MissingResourceException _exception)",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"throw",
"new",
"UnsupportedEncodingException",
"(",
"theMessageErrorTranslatingEncoding",
"+",
"encodingName",
")",
";",
"}",
"// catch (Exception _exception)",
"}"
] |
Get the java encoding name from a standard encoding name.
@param encodingName
the standard encoding name, e.g. <code>iso-8859-1</code>
@return the java encoding name, e.g. <code>ISO_8859_1</code>
@throws UnsupportedEncodingException
if a problem occurs.
|
[
"Get",
"the",
"java",
"encoding",
"name",
"from",
"a",
"standard",
"encoding",
"name",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java#L159-L176
|
2,516 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java
|
AbstractTextFileConverter.convertFile
|
public final void convertFile(final String inputFileName, final String outputFileName) throws IOException, ConversionException
{
openInputFile(inputFileName);
openOutputFile(outputFileName);
doConvertFile(myLineReader, myBufferedWriter);
closeOutputFile();
closeInputFile();
}
|
java
|
public final void convertFile(final String inputFileName, final String outputFileName) throws IOException, ConversionException
{
openInputFile(inputFileName);
openOutputFile(outputFileName);
doConvertFile(myLineReader, myBufferedWriter);
closeOutputFile();
closeInputFile();
}
|
[
"public",
"final",
"void",
"convertFile",
"(",
"final",
"String",
"inputFileName",
",",
"final",
"String",
"outputFileName",
")",
"throws",
"IOException",
",",
"ConversionException",
"{",
"openInputFile",
"(",
"inputFileName",
")",
";",
"openOutputFile",
"(",
"outputFileName",
")",
";",
"doConvertFile",
"(",
"myLineReader",
",",
"myBufferedWriter",
")",
";",
"closeOutputFile",
"(",
")",
";",
"closeInputFile",
"(",
")",
";",
"}"
] |
The file conversion process.
@param inputFileName
Name of the file to convert
@param outputFileName
Name of the converted file
@throws IOException
IO Exceptions are not processed. It is up to the calling process to decide what to do, typically retry, abort or
ignore.
@throws ConversionException
if a conversion problem occurs.
|
[
"The",
"file",
"conversion",
"process",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java#L271-L278
|
2,517 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java
|
AbstractTextFileConverter.openInputFile
|
private void openInputFile(final String inputFileName) throws IOException
{
myInputFile = new File(inputFileName);
myInputStream = new FileInputStream(myInputFile);
myStreamReader = new InputStreamReader(myInputStream, getInputEncodingCode());
myBufferedReader = new BufferedReader(myStreamReader);
myLineReader = new LineNumberReader(myBufferedReader);
}
|
java
|
private void openInputFile(final String inputFileName) throws IOException
{
myInputFile = new File(inputFileName);
myInputStream = new FileInputStream(myInputFile);
myStreamReader = new InputStreamReader(myInputStream, getInputEncodingCode());
myBufferedReader = new BufferedReader(myStreamReader);
myLineReader = new LineNumberReader(myBufferedReader);
}
|
[
"private",
"void",
"openInputFile",
"(",
"final",
"String",
"inputFileName",
")",
"throws",
"IOException",
"{",
"myInputFile",
"=",
"new",
"File",
"(",
"inputFileName",
")",
";",
"myInputStream",
"=",
"new",
"FileInputStream",
"(",
"myInputFile",
")",
";",
"myStreamReader",
"=",
"new",
"InputStreamReader",
"(",
"myInputStream",
",",
"getInputEncodingCode",
"(",
")",
")",
";",
"myBufferedReader",
"=",
"new",
"BufferedReader",
"(",
"myStreamReader",
")",
";",
"myLineReader",
"=",
"new",
"LineNumberReader",
"(",
"myBufferedReader",
")",
";",
"}"
] |
Prepare the input stream.
@param inputFileName
the file to read from.
@throws IOException
if a problem occurs.
|
[
"Prepare",
"the",
"input",
"stream",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java#L403-L410
|
2,518 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java
|
AbstractTextFileConverter.openOutputFile
|
private void openOutputFile(final String outputFileName) throws IOException
{
myOutputFile = new File(outputFileName);
myOutputStream = new FileOutputStream(myOutputFile);
myStreamWriter = new OutputStreamWriter(myOutputStream, getOutputEncodingCode());
myBufferedWriter = new BufferedWriter(myStreamWriter);
}
|
java
|
private void openOutputFile(final String outputFileName) throws IOException
{
myOutputFile = new File(outputFileName);
myOutputStream = new FileOutputStream(myOutputFile);
myStreamWriter = new OutputStreamWriter(myOutputStream, getOutputEncodingCode());
myBufferedWriter = new BufferedWriter(myStreamWriter);
}
|
[
"private",
"void",
"openOutputFile",
"(",
"final",
"String",
"outputFileName",
")",
"throws",
"IOException",
"{",
"myOutputFile",
"=",
"new",
"File",
"(",
"outputFileName",
")",
";",
"myOutputStream",
"=",
"new",
"FileOutputStream",
"(",
"myOutputFile",
")",
";",
"myStreamWriter",
"=",
"new",
"OutputStreamWriter",
"(",
"myOutputStream",
",",
"getOutputEncodingCode",
"(",
")",
")",
";",
"myBufferedWriter",
"=",
"new",
"BufferedWriter",
"(",
"myStreamWriter",
")",
";",
"}"
] |
Prepare the output stream.
@param outputFileName
the file to write into.
@throws IOException
if a problem occurs.
|
[
"Prepare",
"the",
"output",
"stream",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/AbstractTextFileConverter.java#L420-L426
|
2,519 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/KeyboardRepresentationTable.java
|
KeyboardRepresentationTable.getKeyEvent
|
public static Integer getKeyEvent(String key) throws NoSuchElementException
{
key = key.toUpperCase();
Integer _result = theKeyTable.get(key);
if (null == _result)
{
throw new NoSuchElementException(key);
}
return (_result);
}
|
java
|
public static Integer getKeyEvent(String key) throws NoSuchElementException
{
key = key.toUpperCase();
Integer _result = theKeyTable.get(key);
if (null == _result)
{
throw new NoSuchElementException(key);
}
return (_result);
}
|
[
"public",
"static",
"Integer",
"getKeyEvent",
"(",
"String",
"key",
")",
"throws",
"NoSuchElementException",
"{",
"key",
"=",
"key",
".",
"toUpperCase",
"(",
")",
";",
"Integer",
"_result",
"=",
"theKeyTable",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"null",
"==",
"_result",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
"key",
")",
";",
"}",
"return",
"(",
"_result",
")",
";",
"}"
] |
Return an Integer representing a KeyEvent.
@param key
key code
@return Integer corresponding to the KeyEvent
@throws NoSuchElementException
if key does not exists
@see KeyEvent
|
[
"Return",
"an",
"Integer",
"representing",
"a",
"KeyEvent",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/KeyboardRepresentationTable.java#L340-L349
|
2,520 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/KeyboardRepresentationTable.java
|
KeyboardRepresentationTable.getKeyStroke
|
public static KeyStroke getKeyStroke(String key) throws NoSuchElementException
{
key = key.toUpperCase();
int _sep = key.indexOf("/");
String _mask = key.substring(0, _sep);
String _keyCode = key.substring(_sep + 1);
Integer _m = theMaskTable.get(_mask);
Integer _t = theKeyTable.get(_keyCode);
if (null == _m || null == _t)
{
throw new NoSuchElementException(key);
}
return (KeyStroke.getKeyStroke(_t.intValue(), _m.intValue()));
}
|
java
|
public static KeyStroke getKeyStroke(String key) throws NoSuchElementException
{
key = key.toUpperCase();
int _sep = key.indexOf("/");
String _mask = key.substring(0, _sep);
String _keyCode = key.substring(_sep + 1);
Integer _m = theMaskTable.get(_mask);
Integer _t = theKeyTable.get(_keyCode);
if (null == _m || null == _t)
{
throw new NoSuchElementException(key);
}
return (KeyStroke.getKeyStroke(_t.intValue(), _m.intValue()));
}
|
[
"public",
"static",
"KeyStroke",
"getKeyStroke",
"(",
"String",
"key",
")",
"throws",
"NoSuchElementException",
"{",
"key",
"=",
"key",
".",
"toUpperCase",
"(",
")",
";",
"int",
"_sep",
"=",
"key",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"String",
"_mask",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"_sep",
")",
";",
"String",
"_keyCode",
"=",
"key",
".",
"substring",
"(",
"_sep",
"+",
"1",
")",
";",
"Integer",
"_m",
"=",
"theMaskTable",
".",
"get",
"(",
"_mask",
")",
";",
"Integer",
"_t",
"=",
"theKeyTable",
".",
"get",
"(",
"_keyCode",
")",
";",
"if",
"(",
"null",
"==",
"_m",
"||",
"null",
"==",
"_t",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
"key",
")",
";",
"}",
"return",
"(",
"KeyStroke",
".",
"getKeyStroke",
"(",
"_t",
".",
"intValue",
"(",
")",
",",
"_m",
".",
"intValue",
"(",
")",
")",
")",
";",
"}"
] |
Return a KeyStroke corresponding to the given code.
@param key
key code
@return KeyStroke corresponding to the key code
@throws NoSuchElementException
if there is no corresponding KeyStroke
@see KeyEvent
|
[
"Return",
"a",
"KeyStroke",
"corresponding",
"to",
"the",
"given",
"code",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/KeyboardRepresentationTable.java#L361-L374
|
2,521 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/WindowLocation.java
|
WindowLocation.snapWindowTo
|
public static void snapWindowTo(Window win, int location)
{
Dimension _screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension _window = win.getSize();
int _wx = 0;
int _wy = 0;
switch (location)
{
case TOP_LEFT:
break;
case TOP_CENTER:
_wx = (_screen.width - _window.width) / 2;
break;
case TOP_RIGHT:
_wx = _screen.width - _window.width;
break;
case MIDDLE_LEFT:
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_RIGHT:
_wx = _screen.width - _window.width;
_wy = (_screen.height - _window.height) / 2;
break;
case BOTTOM_LEFT:
_wy = _screen.height - _window.height;
break;
case BOTTOM_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = _screen.height - _window.height;
break;
case BOTTOM_RIGHT:
_wx = _screen.width - _window.width;
_wy = _screen.height - _window.height;
break;
}
win.setLocation(new Point(_wx, _wy));
}
|
java
|
public static void snapWindowTo(Window win, int location)
{
Dimension _screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension _window = win.getSize();
int _wx = 0;
int _wy = 0;
switch (location)
{
case TOP_LEFT:
break;
case TOP_CENTER:
_wx = (_screen.width - _window.width) / 2;
break;
case TOP_RIGHT:
_wx = _screen.width - _window.width;
break;
case MIDDLE_LEFT:
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = (_screen.height - _window.height) / 2;
break;
case MIDDLE_RIGHT:
_wx = _screen.width - _window.width;
_wy = (_screen.height - _window.height) / 2;
break;
case BOTTOM_LEFT:
_wy = _screen.height - _window.height;
break;
case BOTTOM_CENTER:
_wx = (_screen.width - _window.width) / 2;
_wy = _screen.height - _window.height;
break;
case BOTTOM_RIGHT:
_wx = _screen.width - _window.width;
_wy = _screen.height - _window.height;
break;
}
win.setLocation(new Point(_wx, _wy));
}
|
[
"public",
"static",
"void",
"snapWindowTo",
"(",
"Window",
"win",
",",
"int",
"location",
")",
"{",
"Dimension",
"_screen",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getScreenSize",
"(",
")",
";",
"Dimension",
"_window",
"=",
"win",
".",
"getSize",
"(",
")",
";",
"int",
"_wx",
"=",
"0",
";",
"int",
"_wy",
"=",
"0",
";",
"switch",
"(",
"location",
")",
"{",
"case",
"TOP_LEFT",
":",
"break",
";",
"case",
"TOP_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"break",
";",
"case",
"TOP_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"break",
";",
"case",
"MIDDLE_LEFT",
":",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"MIDDLE_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"MIDDLE_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"_wy",
"=",
"(",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
")",
"/",
"2",
";",
"break",
";",
"case",
"BOTTOM_LEFT",
":",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"case",
"BOTTOM_CENTER",
":",
"_wx",
"=",
"(",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
")",
"/",
"2",
";",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"case",
"BOTTOM_RIGHT",
":",
"_wx",
"=",
"_screen",
".",
"width",
"-",
"_window",
".",
"width",
";",
"_wy",
"=",
"_screen",
".",
"height",
"-",
"_window",
".",
"height",
";",
"break",
";",
"}",
"win",
".",
"setLocation",
"(",
"new",
"Point",
"(",
"_wx",
",",
"_wy",
")",
")",
";",
"}"
] |
Snap the Window Position to a special location.
@param win
The Window to move
@param location
A value among the allowed predefined positions
|
[
"Snap",
"the",
"Window",
"Position",
"to",
"a",
"special",
"location",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/WindowLocation.java#L76-L116
|
2,522 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java
|
LineByLinePropertyParser.parseLine
|
public synchronized void parseLine(String line) throws SyntaxErrorException
{
if (null != getParserOutcome() && isParserOutcomeMultipleLine())
{
parseLine__multipleLineMode(line);
}
else
{
parseLine__singleLineMode(line);
}
}
|
java
|
public synchronized void parseLine(String line) throws SyntaxErrorException
{
if (null != getParserOutcome() && isParserOutcomeMultipleLine())
{
parseLine__multipleLineMode(line);
}
else
{
parseLine__singleLineMode(line);
}
}
|
[
"public",
"synchronized",
"void",
"parseLine",
"(",
"String",
"line",
")",
"throws",
"SyntaxErrorException",
"{",
"if",
"(",
"null",
"!=",
"getParserOutcome",
"(",
")",
"&&",
"isParserOutcomeMultipleLine",
"(",
")",
")",
"{",
"parseLine__multipleLineMode",
"(",
"line",
")",
";",
"}",
"else",
"{",
"parseLine__singleLineMode",
"(",
"line",
")",
";",
"}",
"}"
] |
Parse the given line and update the internal state of the parser.
@param line
the line to parse.
@throws SyntaxErrorException
if there is a syntax problem in the line.
|
[
"Parse",
"the",
"given",
"line",
"and",
"update",
"the",
"internal",
"state",
"of",
"the",
"parser",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java#L513-L523
|
2,523 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java
|
LineByLinePropertyParser.fireMultipleLinePropertyParsedEvent
|
private void fireMultipleLinePropertyParsedEvent(String name, String[] value)
{
MultipleLinePropertyParsedEvent _event = new MultipleLinePropertyParsedEvent(name, value);
for (PropertiesParsingListener _listener : getListeners())
{
_listener.onMultipleLinePropertyParsed(_event);
}
}
|
java
|
private void fireMultipleLinePropertyParsedEvent(String name, String[] value)
{
MultipleLinePropertyParsedEvent _event = new MultipleLinePropertyParsedEvent(name, value);
for (PropertiesParsingListener _listener : getListeners())
{
_listener.onMultipleLinePropertyParsed(_event);
}
}
|
[
"private",
"void",
"fireMultipleLinePropertyParsedEvent",
"(",
"String",
"name",
",",
"String",
"[",
"]",
"value",
")",
"{",
"MultipleLinePropertyParsedEvent",
"_event",
"=",
"new",
"MultipleLinePropertyParsedEvent",
"(",
"name",
",",
"value",
")",
";",
"for",
"(",
"PropertiesParsingListener",
"_listener",
":",
"getListeners",
"(",
")",
")",
"{",
"_listener",
".",
"onMultipleLinePropertyParsed",
"(",
"_event",
")",
";",
"}",
"}"
] |
Notify listeners that a multiple line property has been parsed.
@param name
property name.
@param value
property value.
|
[
"Notify",
"listeners",
"that",
"a",
"multiple",
"line",
"property",
"has",
"been",
"parsed",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java#L553-L560
|
2,524 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java
|
LineByLinePropertyParser.fireSingleLinePropertyParsedEvent
|
private void fireSingleLinePropertyParsedEvent(String name, String value)
{
SingleLinePropertyParsedEvent _event = new SingleLinePropertyParsedEvent(name, value);
for (PropertiesParsingListener _listener : getListeners())
{
_listener.onSingleLinePropertyParsed(_event);
}
}
|
java
|
private void fireSingleLinePropertyParsedEvent(String name, String value)
{
SingleLinePropertyParsedEvent _event = new SingleLinePropertyParsedEvent(name, value);
for (PropertiesParsingListener _listener : getListeners())
{
_listener.onSingleLinePropertyParsed(_event);
}
}
|
[
"private",
"void",
"fireSingleLinePropertyParsedEvent",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"SingleLinePropertyParsedEvent",
"_event",
"=",
"new",
"SingleLinePropertyParsedEvent",
"(",
"name",
",",
"value",
")",
";",
"for",
"(",
"PropertiesParsingListener",
"_listener",
":",
"getListeners",
"(",
")",
")",
"{",
"_listener",
".",
"onSingleLinePropertyParsed",
"(",
"_event",
")",
";",
"}",
"}"
] |
Notify listeners that a single line property has been parsed.
@param name
property name.
@param value
property value.
|
[
"Notify",
"listeners",
"that",
"a",
"single",
"line",
"property",
"has",
"been",
"parsed",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java#L570-L577
|
2,525 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java
|
LineByLinePropertyParser.parseLine__multipleLineMode
|
private void parseLine__multipleLineMode(String line)
{
boolean _leftTrim = (FinalState.IS_MULTIPLE_LINE_LEFT_TRIM == getParserOutcome());
parseLine__multipleLineMode__appendLineUnlessEndTag(line, _leftTrim);
}
|
java
|
private void parseLine__multipleLineMode(String line)
{
boolean _leftTrim = (FinalState.IS_MULTIPLE_LINE_LEFT_TRIM == getParserOutcome());
parseLine__multipleLineMode__appendLineUnlessEndTag(line, _leftTrim);
}
|
[
"private",
"void",
"parseLine__multipleLineMode",
"(",
"String",
"line",
")",
"{",
"boolean",
"_leftTrim",
"=",
"(",
"FinalState",
".",
"IS_MULTIPLE_LINE_LEFT_TRIM",
"==",
"getParserOutcome",
"(",
")",
")",
";",
"parseLine__multipleLineMode__appendLineUnlessEndTag",
"(",
"line",
",",
"_leftTrim",
")",
";",
"}"
] |
Line parsing when inside a multiple line property definition.
@param line
|
[
"Line",
"parsing",
"when",
"inside",
"a",
"multiple",
"line",
"property",
"definition",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java#L667-L671
|
2,526 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java
|
LineByLinePropertyParser.parseLine__singleLineMode
|
private void parseLine__singleLineMode(String line) throws SyntaxErrorException
{
// reset
setPropertyNameStart(POSITION__NOT_SET);
setPropertyNameEnd(POSITION__NOT_SET);
setRestOfLineStart(POSITION__NOT_SET);
int _nextStateIndex = 0;
State _currentState = null;
char[] _nextChar = new char[1];
for (int _i = 0; _i <= line.length(); _i++)
{
setCurrentChar(_i);
_currentState = getAutomaton()[_nextStateIndex];
_currentState.execute();
if (line.length() == _i || !_currentState.isFollowable()) break;
_nextChar[0] = line.charAt(_i);
String _charToParse = new String(_nextChar);
try
{
_nextStateIndex = _currentState.chooseNext(_charToParse);
}
catch (SyntaxErrorException _exception)
{
throw new SyntaxErrorException("Error at pos " + _i + " in line :'" + line + "'");
}
}
// sanity check : final state and not error
if (null == _currentState || !_currentState.isFinal())
{
throw new SyntaxErrorException("Undefined error at pos in line :'" + line + "'");
}
// do the thing.
if (null != getParserOutcome())
{
if (isParserOutcomeSingleLine())
{
boolean _leftTrim = (FinalState.IS_SINGLE_LINE_LEFT_TRIM == getParserOutcome());
parseLine__extractSingleLineProperty(line, _leftTrim);
}
else if (isParserOutcomeMultipleLine())
{
String _propertyName = line.substring(getPropertyNameStart(), getPropertyNameEnd());
setMultipleLinePropertyName(_propertyName);
setMultipleLinePropertyValue(new ArrayList<String>());
String _endTag = line.substring(getRestOfLineStart()).trim();
if (!getEndTagChecker().matcher(_endTag).matches())
{
throw new SyntaxErrorException(
"End tag MUST match the rule : '" + CharacterPattern.END_TAG + "', got '" + _endTag + "'");
}
setMultipleLineEndTag(_endTag);
}
}
}
|
java
|
private void parseLine__singleLineMode(String line) throws SyntaxErrorException
{
// reset
setPropertyNameStart(POSITION__NOT_SET);
setPropertyNameEnd(POSITION__NOT_SET);
setRestOfLineStart(POSITION__NOT_SET);
int _nextStateIndex = 0;
State _currentState = null;
char[] _nextChar = new char[1];
for (int _i = 0; _i <= line.length(); _i++)
{
setCurrentChar(_i);
_currentState = getAutomaton()[_nextStateIndex];
_currentState.execute();
if (line.length() == _i || !_currentState.isFollowable()) break;
_nextChar[0] = line.charAt(_i);
String _charToParse = new String(_nextChar);
try
{
_nextStateIndex = _currentState.chooseNext(_charToParse);
}
catch (SyntaxErrorException _exception)
{
throw new SyntaxErrorException("Error at pos " + _i + " in line :'" + line + "'");
}
}
// sanity check : final state and not error
if (null == _currentState || !_currentState.isFinal())
{
throw new SyntaxErrorException("Undefined error at pos in line :'" + line + "'");
}
// do the thing.
if (null != getParserOutcome())
{
if (isParserOutcomeSingleLine())
{
boolean _leftTrim = (FinalState.IS_SINGLE_LINE_LEFT_TRIM == getParserOutcome());
parseLine__extractSingleLineProperty(line, _leftTrim);
}
else if (isParserOutcomeMultipleLine())
{
String _propertyName = line.substring(getPropertyNameStart(), getPropertyNameEnd());
setMultipleLinePropertyName(_propertyName);
setMultipleLinePropertyValue(new ArrayList<String>());
String _endTag = line.substring(getRestOfLineStart()).trim();
if (!getEndTagChecker().matcher(_endTag).matches())
{
throw new SyntaxErrorException(
"End tag MUST match the rule : '" + CharacterPattern.END_TAG + "', got '" + _endTag + "'");
}
setMultipleLineEndTag(_endTag);
}
}
}
|
[
"private",
"void",
"parseLine__singleLineMode",
"(",
"String",
"line",
")",
"throws",
"SyntaxErrorException",
"{",
"// reset",
"setPropertyNameStart",
"(",
"POSITION__NOT_SET",
")",
";",
"setPropertyNameEnd",
"(",
"POSITION__NOT_SET",
")",
";",
"setRestOfLineStart",
"(",
"POSITION__NOT_SET",
")",
";",
"int",
"_nextStateIndex",
"=",
"0",
";",
"State",
"_currentState",
"=",
"null",
";",
"char",
"[",
"]",
"_nextChar",
"=",
"new",
"char",
"[",
"1",
"]",
";",
"for",
"(",
"int",
"_i",
"=",
"0",
";",
"_i",
"<=",
"line",
".",
"length",
"(",
")",
";",
"_i",
"++",
")",
"{",
"setCurrentChar",
"(",
"_i",
")",
";",
"_currentState",
"=",
"getAutomaton",
"(",
")",
"[",
"_nextStateIndex",
"]",
";",
"_currentState",
".",
"execute",
"(",
")",
";",
"if",
"(",
"line",
".",
"length",
"(",
")",
"==",
"_i",
"||",
"!",
"_currentState",
".",
"isFollowable",
"(",
")",
")",
"break",
";",
"_nextChar",
"[",
"0",
"]",
"=",
"line",
".",
"charAt",
"(",
"_i",
")",
";",
"String",
"_charToParse",
"=",
"new",
"String",
"(",
"_nextChar",
")",
";",
"try",
"{",
"_nextStateIndex",
"=",
"_currentState",
".",
"chooseNext",
"(",
"_charToParse",
")",
";",
"}",
"catch",
"(",
"SyntaxErrorException",
"_exception",
")",
"{",
"throw",
"new",
"SyntaxErrorException",
"(",
"\"Error at pos \"",
"+",
"_i",
"+",
"\" in line :'\"",
"+",
"line",
"+",
"\"'\"",
")",
";",
"}",
"}",
"// sanity check : final state and not error",
"if",
"(",
"null",
"==",
"_currentState",
"||",
"!",
"_currentState",
".",
"isFinal",
"(",
")",
")",
"{",
"throw",
"new",
"SyntaxErrorException",
"(",
"\"Undefined error at pos in line :'\"",
"+",
"line",
"+",
"\"'\"",
")",
";",
"}",
"// do the thing.",
"if",
"(",
"null",
"!=",
"getParserOutcome",
"(",
")",
")",
"{",
"if",
"(",
"isParserOutcomeSingleLine",
"(",
")",
")",
"{",
"boolean",
"_leftTrim",
"=",
"(",
"FinalState",
".",
"IS_SINGLE_LINE_LEFT_TRIM",
"==",
"getParserOutcome",
"(",
")",
")",
";",
"parseLine__extractSingleLineProperty",
"(",
"line",
",",
"_leftTrim",
")",
";",
"}",
"else",
"if",
"(",
"isParserOutcomeMultipleLine",
"(",
")",
")",
"{",
"String",
"_propertyName",
"=",
"line",
".",
"substring",
"(",
"getPropertyNameStart",
"(",
")",
",",
"getPropertyNameEnd",
"(",
")",
")",
";",
"setMultipleLinePropertyName",
"(",
"_propertyName",
")",
";",
"setMultipleLinePropertyValue",
"(",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"String",
"_endTag",
"=",
"line",
".",
"substring",
"(",
"getRestOfLineStart",
"(",
")",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"getEndTagChecker",
"(",
")",
".",
"matcher",
"(",
"_endTag",
")",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"SyntaxErrorException",
"(",
"\"End tag MUST match the rule : '\"",
"+",
"CharacterPattern",
".",
"END_TAG",
"+",
"\"', got '\"",
"+",
"_endTag",
"+",
"\"'\"",
")",
";",
"}",
"setMultipleLineEndTag",
"(",
"_endTag",
")",
";",
"}",
"}",
"}"
] |
Default line parsing, if a heredoc syntax is detected, next lines will be parsed in multiple line mode.
@param line
the line to parse.
@throws SyntaxErrorException
when the parsing fails.
|
[
"Default",
"line",
"parsing",
"if",
"a",
"heredoc",
"syntax",
"is",
"detected",
"next",
"lines",
"will",
"be",
"parsed",
"in",
"multiple",
"line",
"mode",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/parser/properties/LineByLinePropertyParser.java#L708-L764
|
2,527 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/HtmlTool.java
|
HtmlTool.removeAttribute
|
public final void removeAttribute(final Element root, final String selector,
final String attribute) {
final Iterable<Element> elements; // Elements selected
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(attribute, "Received a null pointer as attribute");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.removeAttr(attribute);
}
}
|
java
|
public final void removeAttribute(final Element root, final String selector,
final String attribute) {
final Iterable<Element> elements; // Elements selected
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(attribute, "Received a null pointer as attribute");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.removeAttr(attribute);
}
}
|
[
"public",
"final",
"void",
"removeAttribute",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"selector",
",",
"final",
"String",
"attribute",
")",
"{",
"final",
"Iterable",
"<",
"Element",
">",
"elements",
";",
"// Elements selected",
"checkNotNull",
"(",
"root",
",",
"\"Received a null pointer as root element\"",
")",
";",
"checkNotNull",
"(",
"selector",
",",
"\"Received a null pointer as selector\"",
")",
";",
"checkNotNull",
"(",
"attribute",
",",
"\"Received a null pointer as attribute\"",
")",
";",
"// Selects and iterates over the elements",
"elements",
"=",
"root",
".",
"select",
"(",
"selector",
")",
";",
"for",
"(",
"final",
"Element",
"element",
":",
"elements",
")",
"{",
"element",
".",
"removeAttr",
"(",
"attribute",
")",
";",
"}",
"}"
] |
Finds a set of elements through a CSS selector and removes the received
attribute from them, if they have it.
@param root
root element for the selection
@param selector
CSS selector for the elements with the attribute to remove
@param attribute
attribute to remove
|
[
"Finds",
"a",
"set",
"of",
"elements",
"through",
"a",
"CSS",
"selector",
"and",
"removes",
"the",
"received",
"attribute",
"from",
"them",
"if",
"they",
"have",
"it",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/HtmlTool.java#L84-L97
|
2,528 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/HtmlTool.java
|
HtmlTool.retag
|
public final void retag(final Element root, final String selector,
final String tag) {
final Iterable<Element> elements; // Elements selected
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(tag, "Received a null pointer as tag");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.tagName(tag);
}
}
|
java
|
public final void retag(final Element root, final String selector,
final String tag) {
final Iterable<Element> elements; // Elements selected
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(tag, "Received a null pointer as tag");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.tagName(tag);
}
}
|
[
"public",
"final",
"void",
"retag",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"selector",
",",
"final",
"String",
"tag",
")",
"{",
"final",
"Iterable",
"<",
"Element",
">",
"elements",
";",
"// Elements selected",
"checkNotNull",
"(",
"root",
",",
"\"Received a null pointer as root element\"",
")",
";",
"checkNotNull",
"(",
"selector",
",",
"\"Received a null pointer as selector\"",
")",
";",
"checkNotNull",
"(",
"tag",
",",
"\"Received a null pointer as tag\"",
")",
";",
"// Selects and iterates over the elements",
"elements",
"=",
"root",
".",
"select",
"(",
"selector",
")",
";",
"for",
"(",
"final",
"Element",
"element",
":",
"elements",
")",
"{",
"element",
".",
"tagName",
"(",
"tag",
")",
";",
"}",
"}"
] |
Finds a set of elements through a CSS selector and changes their tags.
@param root
root element for the selection
@param selector
CSS selector for the elements to retag
@param tag
new tag for the elements
|
[
"Finds",
"a",
"set",
"of",
"elements",
"through",
"a",
"CSS",
"selector",
"and",
"changes",
"their",
"tags",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/HtmlTool.java#L142-L155
|
2,529 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/HtmlTool.java
|
HtmlTool.swapTagWithParent
|
public final void swapTagWithParent(final Element root,
final String selector) {
final Iterable<Element> elements; // Selected elements
Element parent; // Parent element
String text; // Preserved text
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
parent = element.parent();
// Takes the text out of the element
text = element.text();
element.text("");
// Swaps elements
parent.replaceWith(element);
element.appendChild(parent);
// Sets the text into what was the parent element
parent.text(text);
}
}
|
java
|
public final void swapTagWithParent(final Element root,
final String selector) {
final Iterable<Element> elements; // Selected elements
Element parent; // Parent element
String text; // Preserved text
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
parent = element.parent();
// Takes the text out of the element
text = element.text();
element.text("");
// Swaps elements
parent.replaceWith(element);
element.appendChild(parent);
// Sets the text into what was the parent element
parent.text(text);
}
}
|
[
"public",
"final",
"void",
"swapTagWithParent",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"selector",
")",
"{",
"final",
"Iterable",
"<",
"Element",
">",
"elements",
";",
"// Selected elements",
"Element",
"parent",
";",
"// Parent element",
"String",
"text",
";",
"// Preserved text",
"checkNotNull",
"(",
"root",
",",
"\"Received a null pointer as root element\"",
")",
";",
"checkNotNull",
"(",
"selector",
",",
"\"Received a null pointer as selector\"",
")",
";",
"// Selects and iterates over the elements",
"elements",
"=",
"root",
".",
"select",
"(",
"selector",
")",
";",
"for",
"(",
"final",
"Element",
"element",
":",
"elements",
")",
"{",
"parent",
"=",
"element",
".",
"parent",
"(",
")",
";",
"// Takes the text out of the element",
"text",
"=",
"element",
".",
"text",
"(",
")",
";",
"element",
".",
"text",
"(",
"\"\"",
")",
";",
"// Swaps elements",
"parent",
".",
"replaceWith",
"(",
"element",
")",
";",
"element",
".",
"appendChild",
"(",
"parent",
")",
";",
"// Sets the text into what was the parent element",
"parent",
".",
"text",
"(",
"text",
")",
";",
"}",
"}"
] |
Finds a set of elements through a CSS selector and swaps its tag with
that from its parent.
@param root
body element with source divisions to upgrade
@param selector
CSS selector for the elements to swap with its parent
|
[
"Finds",
"a",
"set",
"of",
"elements",
"through",
"a",
"CSS",
"selector",
"and",
"swaps",
"its",
"tag",
"with",
"that",
"from",
"its",
"parent",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/HtmlTool.java#L166-L191
|
2,530 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/HtmlTool.java
|
HtmlTool.wrap
|
public final void wrap(final Element root, final String selector,
final String wrapper) {
final Iterable<Element> elements; // Selected elements
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(wrapper, "Received a null pointer as HTML wrap");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.wrap(wrapper);
}
}
|
java
|
public final void wrap(final Element root, final String selector,
final String wrapper) {
final Iterable<Element> elements; // Selected elements
checkNotNull(root, "Received a null pointer as root element");
checkNotNull(selector, "Received a null pointer as selector");
checkNotNull(wrapper, "Received a null pointer as HTML wrap");
// Selects and iterates over the elements
elements = root.select(selector);
for (final Element element : elements) {
element.wrap(wrapper);
}
}
|
[
"public",
"final",
"void",
"wrap",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"selector",
",",
"final",
"String",
"wrapper",
")",
"{",
"final",
"Iterable",
"<",
"Element",
">",
"elements",
";",
"// Selected elements",
"checkNotNull",
"(",
"root",
",",
"\"Received a null pointer as root element\"",
")",
";",
"checkNotNull",
"(",
"selector",
",",
"\"Received a null pointer as selector\"",
")",
";",
"checkNotNull",
"(",
"wrapper",
",",
"\"Received a null pointer as HTML wrap\"",
")",
";",
"// Selects and iterates over the elements",
"elements",
"=",
"root",
".",
"select",
"(",
"selector",
")",
";",
"for",
"(",
"final",
"Element",
"element",
":",
"elements",
")",
"{",
"element",
".",
"wrap",
"(",
"wrapper",
")",
";",
"}",
"}"
] |
Finds a set of elements through a CSS selector and wraps them with the
received wrapper element.
@param root
root element for the selection
@param selector
CSS selector for the elements to wrap
@param wrapper
HTML to use for wrapping the selected elements
|
[
"Finds",
"a",
"set",
"of",
"elements",
"through",
"a",
"CSS",
"selector",
"and",
"wraps",
"them",
"with",
"the",
"received",
"wrapper",
"element",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/HtmlTool.java#L227-L240
|
2,531 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/paper/UnitConverter.java
|
UnitConverter.getCachedInstance
|
public static UnitConverter getCachedInstance(int pixelPerInch)
{
Integer _key = new Integer(pixelPerInch);
if (!theCache.containsKey(_key))
{
theCache.put(_key, new UnitConverter(pixelPerInch));
}
return theCache.get(_key);
}
|
java
|
public static UnitConverter getCachedInstance(int pixelPerInch)
{
Integer _key = new Integer(pixelPerInch);
if (!theCache.containsKey(_key))
{
theCache.put(_key, new UnitConverter(pixelPerInch));
}
return theCache.get(_key);
}
|
[
"public",
"static",
"UnitConverter",
"getCachedInstance",
"(",
"int",
"pixelPerInch",
")",
"{",
"Integer",
"_key",
"=",
"new",
"Integer",
"(",
"pixelPerInch",
")",
";",
"if",
"(",
"!",
"theCache",
".",
"containsKey",
"(",
"_key",
")",
")",
"{",
"theCache",
".",
"put",
"(",
"_key",
",",
"new",
"UnitConverter",
"(",
"pixelPerInch",
")",
")",
";",
"}",
"return",
"theCache",
".",
"get",
"(",
"_key",
")",
";",
"}"
] |
Retrieve from the cache, or create if not cached yet, a unit converter setted for the given pixel per inch value.
@param pixelPerInch pixel per inch value.
@return an instance tuned for the specified pixel density.
|
[
"Retrieve",
"from",
"the",
"cache",
"or",
"create",
"if",
"not",
"cached",
"yet",
"a",
"unit",
"converter",
"setted",
"for",
"the",
"given",
"pixel",
"per",
"inch",
"value",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/paper/UnitConverter.java#L50-L58
|
2,532 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/AdaptedActionFactory.java
|
AdaptedActionFactory.updateReadyness
|
private void updateReadyness()
{
StringBuffer _buffer = new StringBuffer();
if (null == myMessageProvider)
{
_buffer.append(NO_MESSAGE_PROVIDER);
}
if (null == myIconProvider)
{
if (_buffer.length() > 0)
{
_buffer.append(COMMA);
}
_buffer.append(NO_ICON_PROVIDER);
}
if (_buffer.length() > 0)
{
_buffer.append(DOT);
}
myReasonWhyNotReady = _buffer.toString();
myIsReady = (_buffer.length() == 0);
}
|
java
|
private void updateReadyness()
{
StringBuffer _buffer = new StringBuffer();
if (null == myMessageProvider)
{
_buffer.append(NO_MESSAGE_PROVIDER);
}
if (null == myIconProvider)
{
if (_buffer.length() > 0)
{
_buffer.append(COMMA);
}
_buffer.append(NO_ICON_PROVIDER);
}
if (_buffer.length() > 0)
{
_buffer.append(DOT);
}
myReasonWhyNotReady = _buffer.toString();
myIsReady = (_buffer.length() == 0);
}
|
[
"private",
"void",
"updateReadyness",
"(",
")",
"{",
"StringBuffer",
"_buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"null",
"==",
"myMessageProvider",
")",
"{",
"_buffer",
".",
"append",
"(",
"NO_MESSAGE_PROVIDER",
")",
";",
"}",
"if",
"(",
"null",
"==",
"myIconProvider",
")",
"{",
"if",
"(",
"_buffer",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"_buffer",
".",
"append",
"(",
"COMMA",
")",
";",
"}",
"_buffer",
".",
"append",
"(",
"NO_ICON_PROVIDER",
")",
";",
"}",
"if",
"(",
"_buffer",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"_buffer",
".",
"append",
"(",
"DOT",
")",
";",
"}",
"myReasonWhyNotReady",
"=",
"_buffer",
".",
"toString",
"(",
")",
";",
"myIsReady",
"=",
"(",
"_buffer",
".",
"length",
"(",
")",
"==",
"0",
")",
";",
"}"
] |
Do the self diagnostic, and update the status.
|
[
"Do",
"the",
"self",
"diagnostic",
"and",
"update",
"the",
"status",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/AdaptedActionFactory.java#L127-L149
|
2,533 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/RadioButton.java
|
RadioButton.create
|
public static RadioButton create(String name, String value, String idSuffix, String label, boolean isSelected,
boolean isDisabled)
{
RadioButton _result = new RadioButton();
_result.setName(name);
_result.setValue(value);
if (IS_NOT_EMPTY.test(idSuffix))
{
_result.setIdSuffix(idSuffix);
}
_result.setLabel(label);
_result.setSelected(isSelected);
_result.setDisabled(isDisabled);
return _result;
}
|
java
|
public static RadioButton create(String name, String value, String idSuffix, String label, boolean isSelected,
boolean isDisabled)
{
RadioButton _result = new RadioButton();
_result.setName(name);
_result.setValue(value);
if (IS_NOT_EMPTY.test(idSuffix))
{
_result.setIdSuffix(idSuffix);
}
_result.setLabel(label);
_result.setSelected(isSelected);
_result.setDisabled(isDisabled);
return _result;
}
|
[
"public",
"static",
"RadioButton",
"create",
"(",
"String",
"name",
",",
"String",
"value",
",",
"String",
"idSuffix",
",",
"String",
"label",
",",
"boolean",
"isSelected",
",",
"boolean",
"isDisabled",
")",
"{",
"RadioButton",
"_result",
"=",
"new",
"RadioButton",
"(",
")",
";",
"_result",
".",
"setName",
"(",
"name",
")",
";",
"_result",
".",
"setValue",
"(",
"value",
")",
";",
"if",
"(",
"IS_NOT_EMPTY",
".",
"test",
"(",
"idSuffix",
")",
")",
"{",
"_result",
".",
"setIdSuffix",
"(",
"idSuffix",
")",
";",
"}",
"_result",
".",
"setLabel",
"(",
"label",
")",
";",
"_result",
".",
"setSelected",
"(",
"isSelected",
")",
";",
"_result",
".",
"setDisabled",
"(",
"isDisabled",
")",
";",
"return",
"_result",
";",
"}"
] |
Create a fully specified radio button.
@param name
name of the radio button.
@param value
value of the radio button.
@param idSuffix
suffix to add to compute the id attribute.
@param label
label of the button.
@param isSelected
selected attribute.
@param isDisabled
disabled attribute.
@return a fully defined {@link RadioButton}.
|
[
"Create",
"a",
"fully",
"specified",
"radio",
"button",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/RadioButton.java#L82-L97
|
2,534 |
etourdot/xincproc
|
xpointer/src/main/java/org/etourdot/xincproc/xpointer/XPointerEngine.java
|
XPointerEngine.execute
|
public String execute(final String pointerStr, final Source source)
{
try
{
final StringWriter stringWriter = new StringWriter();
final Serializer serializer = processor.newSerializer(stringWriter);
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
executeToDestination(pointerStr, source, serializer);
return stringWriter.toString();
}
catch (final XPointerException e)
{
final String message = e.getLocalizedMessage();
if (xPointerErrorHandler != null)
{
xPointerErrorHandler.reportError(message);
}
else
{
LOG.error(message, e);
}
}
return "";
}
|
java
|
public String execute(final String pointerStr, final Source source)
{
try
{
final StringWriter stringWriter = new StringWriter();
final Serializer serializer = processor.newSerializer(stringWriter);
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
executeToDestination(pointerStr, source, serializer);
return stringWriter.toString();
}
catch (final XPointerException e)
{
final String message = e.getLocalizedMessage();
if (xPointerErrorHandler != null)
{
xPointerErrorHandler.reportError(message);
}
else
{
LOG.error(message, e);
}
}
return "";
}
|
[
"public",
"String",
"execute",
"(",
"final",
"String",
"pointerStr",
",",
"final",
"Source",
"source",
")",
"{",
"try",
"{",
"final",
"StringWriter",
"stringWriter",
"=",
"new",
"StringWriter",
"(",
")",
";",
"final",
"Serializer",
"serializer",
"=",
"processor",
".",
"newSerializer",
"(",
"stringWriter",
")",
";",
"serializer",
".",
"setOutputProperty",
"(",
"Serializer",
".",
"Property",
".",
"OMIT_XML_DECLARATION",
",",
"\"yes\"",
")",
";",
"executeToDestination",
"(",
"pointerStr",
",",
"source",
",",
"serializer",
")",
";",
"return",
"stringWriter",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"XPointerException",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"e",
".",
"getLocalizedMessage",
"(",
")",
";",
"if",
"(",
"xPointerErrorHandler",
"!=",
"null",
")",
"{",
"xPointerErrorHandler",
".",
"reportError",
"(",
"message",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"message",
",",
"e",
")",
";",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
Execute xpointer expression on a xml source returning a xml string
@param pointerStr xpointer expression
@param source xml source
@return serialized xml result or an empty string (not null)
|
[
"Execute",
"xpointer",
"expression",
"on",
"a",
"xml",
"source",
"returning",
"a",
"xml",
"string"
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xpointer/src/main/java/org/etourdot/xincproc/xpointer/XPointerEngine.java#L157-L180
|
2,535 |
etourdot/xincproc
|
xpointer/src/main/java/org/etourdot/xincproc/xpointer/XPointerEngine.java
|
XPointerEngine.verifyXPathExpression
|
public String verifyXPathExpression(final Iterable<XmlNsScheme> xmlNsSchemes, final String xpathExpression)
{
LOG.trace("verifyXPathExpression: {}", xpathExpression);
final XPathCompiler xPathCompiler = processor.newXPathCompiler();
for (final XmlNsScheme xmlNsScheme : xmlNsSchemes)
{
final String localPart = xmlNsScheme.getQName().getLocalPart();
final String namespaceUri = xmlNsScheme.getQName().getNamespaceURI();
LOG.trace("declareNamespace {}:{}", localPart, namespaceUri);
xPathCompiler.declareNamespace(localPart, namespaceUri);
}
try
{
xPathCompiler.compile(xpathExpression);
}
catch (final SaxonApiException e)
{
return e.getCause().getMessage();
}
return "";
}
|
java
|
public String verifyXPathExpression(final Iterable<XmlNsScheme> xmlNsSchemes, final String xpathExpression)
{
LOG.trace("verifyXPathExpression: {}", xpathExpression);
final XPathCompiler xPathCompiler = processor.newXPathCompiler();
for (final XmlNsScheme xmlNsScheme : xmlNsSchemes)
{
final String localPart = xmlNsScheme.getQName().getLocalPart();
final String namespaceUri = xmlNsScheme.getQName().getNamespaceURI();
LOG.trace("declareNamespace {}:{}", localPart, namespaceUri);
xPathCompiler.declareNamespace(localPart, namespaceUri);
}
try
{
xPathCompiler.compile(xpathExpression);
}
catch (final SaxonApiException e)
{
return e.getCause().getMessage();
}
return "";
}
|
[
"public",
"String",
"verifyXPathExpression",
"(",
"final",
"Iterable",
"<",
"XmlNsScheme",
">",
"xmlNsSchemes",
",",
"final",
"String",
"xpathExpression",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"verifyXPathExpression: {}\"",
",",
"xpathExpression",
")",
";",
"final",
"XPathCompiler",
"xPathCompiler",
"=",
"processor",
".",
"newXPathCompiler",
"(",
")",
";",
"for",
"(",
"final",
"XmlNsScheme",
"xmlNsScheme",
":",
"xmlNsSchemes",
")",
"{",
"final",
"String",
"localPart",
"=",
"xmlNsScheme",
".",
"getQName",
"(",
")",
".",
"getLocalPart",
"(",
")",
";",
"final",
"String",
"namespaceUri",
"=",
"xmlNsScheme",
".",
"getQName",
"(",
")",
".",
"getNamespaceURI",
"(",
")",
";",
"LOG",
".",
"trace",
"(",
"\"declareNamespace {}:{}\"",
",",
"localPart",
",",
"namespaceUri",
")",
";",
"xPathCompiler",
".",
"declareNamespace",
"(",
"localPart",
",",
"namespaceUri",
")",
";",
"}",
"try",
"{",
"xPathCompiler",
".",
"compile",
"(",
"xpathExpression",
")",
";",
"}",
"catch",
"(",
"final",
"SaxonApiException",
"e",
")",
"{",
"return",
"e",
".",
"getCause",
"(",
")",
".",
"getMessage",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Utility method for verifying xpath expression
@param xmlNsSchemes namespaces list
@param xpathExpression xpath expression to test
@return empty string if expression is right, error otherwise
|
[
"Utility",
"method",
"for",
"verifying",
"xpath",
"expression"
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xpointer/src/main/java/org/etourdot/xincproc/xpointer/XPointerEngine.java#L225-L245
|
2,536 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java
|
XIncludeContext.newContext
|
public static XIncludeContext newContext(final XIncludeContext contextToCopy)
{
final XIncludeContext newContext = new XIncludeContext(contextToCopy.configuration);
newContext.currentBaseURI = contextToCopy.currentBaseURI;
newContext.basesURIDeque.addAll(contextToCopy.basesURIDeque);
newContext.language = contextToCopy.language;
newContext.xincludeDeque.addAll(contextToCopy.xincludeDeque);
newContext.docType = DocType.copy(contextToCopy.docType);
return newContext;
}
|
java
|
public static XIncludeContext newContext(final XIncludeContext contextToCopy)
{
final XIncludeContext newContext = new XIncludeContext(contextToCopy.configuration);
newContext.currentBaseURI = contextToCopy.currentBaseURI;
newContext.basesURIDeque.addAll(contextToCopy.basesURIDeque);
newContext.language = contextToCopy.language;
newContext.xincludeDeque.addAll(contextToCopy.xincludeDeque);
newContext.docType = DocType.copy(contextToCopy.docType);
return newContext;
}
|
[
"public",
"static",
"XIncludeContext",
"newContext",
"(",
"final",
"XIncludeContext",
"contextToCopy",
")",
"{",
"final",
"XIncludeContext",
"newContext",
"=",
"new",
"XIncludeContext",
"(",
"contextToCopy",
".",
"configuration",
")",
";",
"newContext",
".",
"currentBaseURI",
"=",
"contextToCopy",
".",
"currentBaseURI",
";",
"newContext",
".",
"basesURIDeque",
".",
"addAll",
"(",
"contextToCopy",
".",
"basesURIDeque",
")",
";",
"newContext",
".",
"language",
"=",
"contextToCopy",
".",
"language",
";",
"newContext",
".",
"xincludeDeque",
".",
"addAll",
"(",
"contextToCopy",
".",
"xincludeDeque",
")",
";",
"newContext",
".",
"docType",
"=",
"DocType",
".",
"copy",
"(",
"contextToCopy",
".",
"docType",
")",
";",
"return",
"newContext",
";",
"}"
] |
Create a new context by deep copy of an existant one.
@param contextToCopy the context to copy
@return the XIncludeContext
|
[
"Create",
"a",
"new",
"context",
"by",
"deep",
"copy",
"of",
"an",
"existant",
"one",
"."
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java#L58-L67
|
2,537 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java
|
XIncludeContext.updateContextWithElementAttributes
|
public void updateContextWithElementAttributes(final Attributes attributes)
throws XIncludeFatalException
{
extractCurrentBaseURI(attributes);
if (ofNullable(this.currentBaseURI).isPresent())
{
addBaseURIPath(this.currentBaseURI);
}
}
|
java
|
public void updateContextWithElementAttributes(final Attributes attributes)
throws XIncludeFatalException
{
extractCurrentBaseURI(attributes);
if (ofNullable(this.currentBaseURI).isPresent())
{
addBaseURIPath(this.currentBaseURI);
}
}
|
[
"public",
"void",
"updateContextWithElementAttributes",
"(",
"final",
"Attributes",
"attributes",
")",
"throws",
"XIncludeFatalException",
"{",
"extractCurrentBaseURI",
"(",
"attributes",
")",
";",
"if",
"(",
"ofNullable",
"(",
"this",
".",
"currentBaseURI",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"addBaseURIPath",
"(",
"this",
".",
"currentBaseURI",
")",
";",
"}",
"}"
] |
Update context with element attributes.
@param attributes the attributes
@throws XIncludeFatalException if attribute xml:base is invalid
|
[
"Update",
"context",
"with",
"element",
"attributes",
"."
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java#L85-L93
|
2,538 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java
|
XIncludeContext.addInInclusionChain
|
public void addInInclusionChain(final URI path, final String pointer)
throws XIncludeFatalException
{
final String xincludePath = path.toASCIIString() + ((null != pointer) ? ('#' + pointer) : "");
if (this.xincludeDeque.contains(xincludePath))
{
throw new XIncludeFatalException("Inclusion Loop on path: " + xincludePath);
}
this.xincludeDeque.addLast(xincludePath);
}
|
java
|
public void addInInclusionChain(final URI path, final String pointer)
throws XIncludeFatalException
{
final String xincludePath = path.toASCIIString() + ((null != pointer) ? ('#' + pointer) : "");
if (this.xincludeDeque.contains(xincludePath))
{
throw new XIncludeFatalException("Inclusion Loop on path: " + xincludePath);
}
this.xincludeDeque.addLast(xincludePath);
}
|
[
"public",
"void",
"addInInclusionChain",
"(",
"final",
"URI",
"path",
",",
"final",
"String",
"pointer",
")",
"throws",
"XIncludeFatalException",
"{",
"final",
"String",
"xincludePath",
"=",
"path",
".",
"toASCIIString",
"(",
")",
"+",
"(",
"(",
"null",
"!=",
"pointer",
")",
"?",
"(",
"'",
"'",
"+",
"pointer",
")",
":",
"\"\"",
")",
";",
"if",
"(",
"this",
".",
"xincludeDeque",
".",
"contains",
"(",
"xincludePath",
")",
")",
"{",
"throw",
"new",
"XIncludeFatalException",
"(",
"\"Inclusion Loop on path: \"",
"+",
"xincludePath",
")",
";",
"}",
"this",
".",
"xincludeDeque",
".",
"addLast",
"(",
"xincludePath",
")",
";",
"}"
] |
Add in inclusion chain.
@param path the path
@param pointer the pointer
@throws XIncludeFatalException the x include fatal exception
|
[
"Add",
"in",
"inclusion",
"chain",
"."
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/sax/XIncludeContext.java#L174-L183
|
2,539 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeFinder.java
|
NodeFinder.find
|
public Node find(String nodeName)
{
// Sanity check
if (IS_EMPTY.test(nodeName))
{
throw new IllegalArgumentException("The node name should not be empty");
}
Node _result = null;
while (hasMoreAvailableElement() && (null == _result))
{
int _position = getPosition();
Node _current = getSource().item(_position);
_position++;
setPosition(_position);
if (nodeName.equals(_current.getNodeName()))
{
_result = _current;
}
}
return _result;
}
|
java
|
public Node find(String nodeName)
{
// Sanity check
if (IS_EMPTY.test(nodeName))
{
throw new IllegalArgumentException("The node name should not be empty");
}
Node _result = null;
while (hasMoreAvailableElement() && (null == _result))
{
int _position = getPosition();
Node _current = getSource().item(_position);
_position++;
setPosition(_position);
if (nodeName.equals(_current.getNodeName()))
{
_result = _current;
}
}
return _result;
}
|
[
"public",
"Node",
"find",
"(",
"String",
"nodeName",
")",
"{",
"// Sanity check",
"if",
"(",
"IS_EMPTY",
".",
"test",
"(",
"nodeName",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The node name should not be empty\"",
")",
";",
"}",
"Node",
"_result",
"=",
"null",
";",
"while",
"(",
"hasMoreAvailableElement",
"(",
")",
"&&",
"(",
"null",
"==",
"_result",
")",
")",
"{",
"int",
"_position",
"=",
"getPosition",
"(",
")",
";",
"Node",
"_current",
"=",
"getSource",
"(",
")",
".",
"item",
"(",
"_position",
")",
";",
"_position",
"++",
";",
"setPosition",
"(",
"_position",
")",
";",
"if",
"(",
"nodeName",
".",
"equals",
"(",
"_current",
".",
"getNodeName",
"(",
")",
")",
")",
"{",
"_result",
"=",
"_current",
";",
"}",
"}",
"return",
"_result",
";",
"}"
] |
Find the next node having the specified node name.
@param nodeName
name to look for.
@return <code>null</code> if there are no more node to scan and there was no matching node.
|
[
"Find",
"the",
"next",
"node",
"having",
"the",
"specified",
"node",
"name",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeFinder.java#L153-L174
|
2,540 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Option.java
|
Option.create
|
public static Option create(String value, String label, boolean isSelected)
{
Option _result = new Option();
_result.setValue(value);
_result.setLabel(label);
_result.setSelected(isSelected);
return _result;
}
|
java
|
public static Option create(String value, String label, boolean isSelected)
{
Option _result = new Option();
_result.setValue(value);
_result.setLabel(label);
_result.setSelected(isSelected);
return _result;
}
|
[
"public",
"static",
"Option",
"create",
"(",
"String",
"value",
",",
"String",
"label",
",",
"boolean",
"isSelected",
")",
"{",
"Option",
"_result",
"=",
"new",
"Option",
"(",
")",
";",
"_result",
".",
"setValue",
"(",
"value",
")",
";",
"_result",
".",
"setLabel",
"(",
"label",
")",
";",
"_result",
".",
"setSelected",
"(",
"isSelected",
")",
";",
"return",
"_result",
";",
"}"
] |
Create a fully specified option.
@param value value attribute.
@param label label attribute.
@param isSelected selected attribute.
@return a fully defined {@link Option}.
|
[
"Create",
"a",
"fully",
"specified",
"option",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Option.java#L68-L75
|
2,541 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Option.java
|
Option.getHtmlCode
|
public String getHtmlCode()
{
Object[] _params =
{
SgmlUtils.generateAttribute(HtmlUtils.AttributeNames.VALUE, getValue())
};
MessageFormat _format = (isSelected()) ? FORMAT__SELECTED : FORMAT__NOT_SELECTED;
return _format.format(_params);
}
|
java
|
public String getHtmlCode()
{
Object[] _params =
{
SgmlUtils.generateAttribute(HtmlUtils.AttributeNames.VALUE, getValue())
};
MessageFormat _format = (isSelected()) ? FORMAT__SELECTED : FORMAT__NOT_SELECTED;
return _format.format(_params);
}
|
[
"public",
"String",
"getHtmlCode",
"(",
")",
"{",
"Object",
"[",
"]",
"_params",
"=",
"{",
"SgmlUtils",
".",
"generateAttribute",
"(",
"HtmlUtils",
".",
"AttributeNames",
".",
"VALUE",
",",
"getValue",
"(",
")",
")",
"}",
";",
"MessageFormat",
"_format",
"=",
"(",
"isSelected",
"(",
")",
")",
"?",
"FORMAT__SELECTED",
":",
"FORMAT__NOT_SELECTED",
";",
"return",
"_format",
".",
"format",
"(",
"_params",
")",
";",
"}"
] |
Generate the html code for the option.
@return the HTML code of the option.
|
[
"Generate",
"the",
"html",
"code",
"for",
"the",
"option",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Option.java#L158-L166
|
2,542 |
lindar-open/well-rested-client
|
src/main/java/com/lindar/wellrested/vo/Result.java
|
Result.orElseDoAndReturnDefault
|
public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
}
|
java
|
public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
if (isSuccessAndNotNull()) {
return data;
}
consumer.accept(this);
return defaultVal;
}
|
[
"public",
"T",
"orElseDoAndReturnDefault",
"(",
"Consumer",
"<",
"Result",
"<",
"T",
">",
">",
"consumer",
",",
"T",
"defaultVal",
")",
"{",
"if",
"(",
"isSuccessAndNotNull",
"(",
")",
")",
"{",
"return",
"data",
";",
"}",
"consumer",
".",
"accept",
"(",
"this",
")",
";",
"return",
"defaultVal",
";",
"}"
] |
The consumer function receives the entire result object as parameter in case you want to log or manage the error message or code in any way.
@param consumer
@param defaultVal
@return
|
[
"The",
"consumer",
"function",
"receives",
"the",
"entire",
"result",
"object",
"as",
"parameter",
"in",
"case",
"you",
"want",
"to",
"log",
"or",
"manage",
"the",
"error",
"message",
"or",
"code",
"in",
"any",
"way",
"."
] |
d87542f747cd624e3ce0cdc8230f51836326596b
|
https://github.com/lindar-open/well-rested-client/blob/d87542f747cd624e3ce0cdc8230f51836326596b/src/main/java/com/lindar/wellrested/vo/Result.java#L138-L144
|
2,543 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/EncodingUtils.java
|
EncodingUtils.getCharset
|
public static Charset getCharset(final InputStream inputStream) throws IOException
{
final Charset resultCharset;
final byte[] buffer = new byte[192];
final int reading = ByteStreams.read(inputStream, buffer, 0, 192);
if (4 > reading)
{
resultCharset = Charset.forName(EncodingUtils.DEFAULT_ENCODING);
}
else
{
final long computed = (0xFF000000 & (buffer[0] << 24)) |
(0x00FF0000 & (buffer[1] << 16)) |
(0x0000FF00 & (buffer[2] << 8)) |
(0x000000FF & buffer[3]);
if (0x0000FEFFL == computed || 0xFFFE0000L == computed)
{
resultCharset = Charset.forName("UCS-4");
}
else if (0x0000003CL == computed)
{
resultCharset = Charset.forName("UCS-4BE");
}
else if (0x3C000000L == computed)
{
resultCharset = Charset.forName("UCS-4LE");
}
else if (0x003C003FL == computed)
{
resultCharset = Charset.forName("UTF-16BE");
}
else if (0x3C003F00L == computed)
{
resultCharset = Charset.forName("UTF-16LE");
}
else if (0x3C3F786DL == computed || 0x4C6FA794L == computed)
{
resultCharset = EncodingUtils.getXmlCharsetEncoding(buffer);
}
else if (0xFEFF0000L == (computed & 0xFFFF0000L))
{
resultCharset = Charset.forName("UTF-16");
}
else if (0xFFFE0000L == (computed & 0xFFFF0000L))
{
resultCharset = Charset.forName("UTF-16");
}
else
{
resultCharset = Charset.forName(EncodingUtils.DEFAULT_ENCODING);
}
}
return resultCharset;
}
|
java
|
public static Charset getCharset(final InputStream inputStream) throws IOException
{
final Charset resultCharset;
final byte[] buffer = new byte[192];
final int reading = ByteStreams.read(inputStream, buffer, 0, 192);
if (4 > reading)
{
resultCharset = Charset.forName(EncodingUtils.DEFAULT_ENCODING);
}
else
{
final long computed = (0xFF000000 & (buffer[0] << 24)) |
(0x00FF0000 & (buffer[1] << 16)) |
(0x0000FF00 & (buffer[2] << 8)) |
(0x000000FF & buffer[3]);
if (0x0000FEFFL == computed || 0xFFFE0000L == computed)
{
resultCharset = Charset.forName("UCS-4");
}
else if (0x0000003CL == computed)
{
resultCharset = Charset.forName("UCS-4BE");
}
else if (0x3C000000L == computed)
{
resultCharset = Charset.forName("UCS-4LE");
}
else if (0x003C003FL == computed)
{
resultCharset = Charset.forName("UTF-16BE");
}
else if (0x3C003F00L == computed)
{
resultCharset = Charset.forName("UTF-16LE");
}
else if (0x3C3F786DL == computed || 0x4C6FA794L == computed)
{
resultCharset = EncodingUtils.getXmlCharsetEncoding(buffer);
}
else if (0xFEFF0000L == (computed & 0xFFFF0000L))
{
resultCharset = Charset.forName("UTF-16");
}
else if (0xFFFE0000L == (computed & 0xFFFF0000L))
{
resultCharset = Charset.forName("UTF-16");
}
else
{
resultCharset = Charset.forName(EncodingUtils.DEFAULT_ENCODING);
}
}
return resultCharset;
}
|
[
"public",
"static",
"Charset",
"getCharset",
"(",
"final",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"final",
"Charset",
"resultCharset",
";",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"192",
"]",
";",
"final",
"int",
"reading",
"=",
"ByteStreams",
".",
"read",
"(",
"inputStream",
",",
"buffer",
",",
"0",
",",
"192",
")",
";",
"if",
"(",
"4",
">",
"reading",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"EncodingUtils",
".",
"DEFAULT_ENCODING",
")",
";",
"}",
"else",
"{",
"final",
"long",
"computed",
"=",
"(",
"0xFF000000",
"&",
"(",
"buffer",
"[",
"0",
"]",
"<<",
"24",
")",
")",
"|",
"(",
"0x00FF0000",
"&",
"(",
"buffer",
"[",
"1",
"]",
"<<",
"16",
")",
")",
"|",
"(",
"0x0000FF00",
"&",
"(",
"buffer",
"[",
"2",
"]",
"<<",
"8",
")",
")",
"|",
"(",
"0x000000FF",
"&",
"buffer",
"[",
"3",
"]",
")",
";",
"if",
"(",
"0x0000FEFF",
"L",
"==",
"computed",
"||",
"0xFFFE0000",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UCS-4\"",
")",
";",
"}",
"else",
"if",
"(",
"0x0000003C",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UCS-4BE\"",
")",
";",
"}",
"else",
"if",
"(",
"0x3C000000",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UCS-4LE\"",
")",
";",
"}",
"else",
"if",
"(",
"0x003C003F",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UTF-16BE\"",
")",
";",
"}",
"else",
"if",
"(",
"0x3C003F00",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UTF-16LE\"",
")",
";",
"}",
"else",
"if",
"(",
"0x3C3F786D",
"L",
"==",
"computed",
"||",
"0x4C6FA794",
"L",
"==",
"computed",
")",
"{",
"resultCharset",
"=",
"EncodingUtils",
".",
"getXmlCharsetEncoding",
"(",
"buffer",
")",
";",
"}",
"else",
"if",
"(",
"0xFEFF0000",
"L",
"==",
"(",
"computed",
"&",
"0xFFFF0000",
"L",
")",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UTF-16\"",
")",
";",
"}",
"else",
"if",
"(",
"0xFFFE0000",
"L",
"==",
"(",
"computed",
"&",
"0xFFFF0000",
"L",
")",
")",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"\"UTF-16\"",
")",
";",
"}",
"else",
"{",
"resultCharset",
"=",
"Charset",
".",
"forName",
"(",
"EncodingUtils",
".",
"DEFAULT_ENCODING",
")",
";",
"}",
"}",
"return",
"resultCharset",
";",
"}"
] |
Gets charset of an inputstream.
@param inputStream the input stream to analyse
@return the charset identify
@throws IOException if inputstream is unreadable
|
[
"Gets",
"charset",
"of",
"an",
"inputstream",
"."
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/EncodingUtils.java#L45-L98
|
2,544 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java
|
ComponentFactory.createFluidFlowPanel
|
public static FluidFlowPanelModel createFluidFlowPanel(int horizontalGap, int verticalGap)
{
FlowLayout _flowLayout = new FlowLayout(FlowLayout.LEFT, horizontalGap, verticalGap);
return FluidFlowPanelModel.createFluidFlowPanel(_flowLayout);
}
|
java
|
public static FluidFlowPanelModel createFluidFlowPanel(int horizontalGap, int verticalGap)
{
FlowLayout _flowLayout = new FlowLayout(FlowLayout.LEFT, horizontalGap, verticalGap);
return FluidFlowPanelModel.createFluidFlowPanel(_flowLayout);
}
|
[
"public",
"static",
"FluidFlowPanelModel",
"createFluidFlowPanel",
"(",
"int",
"horizontalGap",
",",
"int",
"verticalGap",
")",
"{",
"FlowLayout",
"_flowLayout",
"=",
"new",
"FlowLayout",
"(",
"FlowLayout",
".",
"LEFT",
",",
"horizontalGap",
",",
"verticalGap",
")",
";",
"return",
"FluidFlowPanelModel",
".",
"createFluidFlowPanel",
"(",
"_flowLayout",
")",
";",
"}"
] |
Create a scrollable panel.
@param horizontalGap
the horizontal gap.
@param verticalGap
the vertical gap.
@return a scrollable panel.
@since 15.02.00
|
[
"Create",
"a",
"scrollable",
"panel",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java#L62-L66
|
2,545 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java
|
ComponentFactory.createPanelWithHorizontalLayout
|
public static JPanel createPanelWithHorizontalLayout()
{
JPanel _panel = new JPanel();
_panel.setLayout(new BoxLayout(_panel, BoxLayout.X_AXIS));
return _panel;
}
|
java
|
public static JPanel createPanelWithHorizontalLayout()
{
JPanel _panel = new JPanel();
_panel.setLayout(new BoxLayout(_panel, BoxLayout.X_AXIS));
return _panel;
}
|
[
"public",
"static",
"JPanel",
"createPanelWithHorizontalLayout",
"(",
")",
"{",
"JPanel",
"_panel",
"=",
"new",
"JPanel",
"(",
")",
";",
"_panel",
".",
"setLayout",
"(",
"new",
"BoxLayout",
"(",
"_panel",
",",
"BoxLayout",
".",
"X_AXIS",
")",
")",
";",
"return",
"_panel",
";",
"}"
] |
Create a panel that lays out components horizontally.
@return a panel with an horizontal box layout.
@since 15.02.00
|
[
"Create",
"a",
"panel",
"that",
"lays",
"out",
"components",
"horizontally",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java#L74-L79
|
2,546 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java
|
ComponentFactory.createPanelWithVerticalLayout
|
public static JPanel createPanelWithVerticalLayout()
{
JPanel _panel = new JPanel();
_panel.setLayout(new BoxLayout(_panel, BoxLayout.Y_AXIS));
return _panel;
}
|
java
|
public static JPanel createPanelWithVerticalLayout()
{
JPanel _panel = new JPanel();
_panel.setLayout(new BoxLayout(_panel, BoxLayout.Y_AXIS));
return _panel;
}
|
[
"public",
"static",
"JPanel",
"createPanelWithVerticalLayout",
"(",
")",
"{",
"JPanel",
"_panel",
"=",
"new",
"JPanel",
"(",
")",
";",
"_panel",
".",
"setLayout",
"(",
"new",
"BoxLayout",
"(",
"_panel",
",",
"BoxLayout",
".",
"Y_AXIS",
")",
")",
";",
"return",
"_panel",
";",
"}"
] |
Create a panel that lays out components vertically.
@return a panel with a vertical layout.
@since 15.02.00
|
[
"Create",
"a",
"panel",
"that",
"lays",
"out",
"components",
"vertically",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java#L87-L92
|
2,547 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java
|
ComponentFactory.getImageIcon
|
public static Icon getImageIcon(ClassLoader objectLoader, String fileName) throws UrlProviderException
{
return getImageIcon(new ClassLoaderUrlProvider(objectLoader), fileName);
}
|
java
|
public static Icon getImageIcon(ClassLoader objectLoader, String fileName) throws UrlProviderException
{
return getImageIcon(new ClassLoaderUrlProvider(objectLoader), fileName);
}
|
[
"public",
"static",
"Icon",
"getImageIcon",
"(",
"ClassLoader",
"objectLoader",
",",
"String",
"fileName",
")",
"throws",
"UrlProviderException",
"{",
"return",
"getImageIcon",
"(",
"new",
"ClassLoaderUrlProvider",
"(",
"objectLoader",
")",
",",
"fileName",
")",
";",
"}"
] |
Create an Image icon from a String.
@param objectLoader
This method use <i>objectLoader.getResource() </i> to retrieve the icon.
@param fileName
the name of the file.
@return an Icon.
@throws UrlProviderException if there is a problem to deal with.
|
[
"Create",
"an",
"Image",
"icon",
"from",
"a",
"String",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java#L104-L107
|
2,548 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java
|
ComponentFactory.getImageIcon
|
public static Icon getImageIcon(UrlProvider urlProvider, String fileName) throws UrlProviderException
{
URL _icon = urlProvider.getUrl(fileName);
return new ImageIcon(_icon);
}
|
java
|
public static Icon getImageIcon(UrlProvider urlProvider, String fileName) throws UrlProviderException
{
URL _icon = urlProvider.getUrl(fileName);
return new ImageIcon(_icon);
}
|
[
"public",
"static",
"Icon",
"getImageIcon",
"(",
"UrlProvider",
"urlProvider",
",",
"String",
"fileName",
")",
"throws",
"UrlProviderException",
"{",
"URL",
"_icon",
"=",
"urlProvider",
".",
"getUrl",
"(",
"fileName",
")",
";",
"return",
"new",
"ImageIcon",
"(",
"_icon",
")",
";",
"}"
] |
Create an Image based icon from a String.
@param urlProvider
The URL provider.
@param fileName
the name of the file.
@return an Icon.
@throws UrlProviderException if there is a problem to deal with.
|
[
"Create",
"an",
"Image",
"based",
"icon",
"from",
"a",
"String",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/ComponentFactory.java#L119-L123
|
2,549 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/HtmlUtils.java
|
HtmlUtils.encloseInParagraphe
|
public static String encloseInParagraphe(String value)
{
Object[] _params =
{
value
};
return FORMAT_PARAGRAPH.format(_params);
}
|
java
|
public static String encloseInParagraphe(String value)
{
Object[] _params =
{
value
};
return FORMAT_PARAGRAPH.format(_params);
}
|
[
"public",
"static",
"String",
"encloseInParagraphe",
"(",
"String",
"value",
")",
"{",
"Object",
"[",
"]",
"_params",
"=",
"{",
"value",
"}",
";",
"return",
"FORMAT_PARAGRAPH",
".",
"format",
"(",
"_params",
")",
";",
"}"
] |
Create a HTML paragraph from the given text.
@param value the value to enclose in paragraph.
@return a HTML paragraphe.
|
[
"Create",
"a",
"HTML",
"paragraph",
"from",
"the",
"given",
"text",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/HtmlUtils.java#L200-L207
|
2,550 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/HtmlUtils.java
|
HtmlUtils.generateAttribute
|
public static String generateAttribute(String attributeName, String value)
{
return SgmlUtils.generateAttribute(attributeName, value);
}
|
java
|
public static String generateAttribute(String attributeName, String value)
{
return SgmlUtils.generateAttribute(attributeName, value);
}
|
[
"public",
"static",
"String",
"generateAttribute",
"(",
"String",
"attributeName",
",",
"String",
"value",
")",
"{",
"return",
"SgmlUtils",
".",
"generateAttribute",
"(",
"attributeName",
",",
"value",
")",
";",
"}"
] |
Generate the HTML code for an attribute.
@param attributeName the name of the attribute.
@param value the value of the attribute.
@return the HTML attribute.
|
[
"Generate",
"the",
"HTML",
"code",
"for",
"an",
"attribute",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/HtmlUtils.java#L216-L219
|
2,551 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java
|
DataTools.matchSequence
|
public static final boolean matchSequence(byte[] sequence, byte[] buffer, int offset)
{
boolean _result = (sequence.length < (buffer.length - offset));
if (_result)
{
for (int _index = 0; _index < sequence.length; _index++)
{
if (buffer[_index] != sequence[_index])
{
_result = false;
break;
}
}
}
return _result;
}
|
java
|
public static final boolean matchSequence(byte[] sequence, byte[] buffer, int offset)
{
boolean _result = (sequence.length < (buffer.length - offset));
if (_result)
{
for (int _index = 0; _index < sequence.length; _index++)
{
if (buffer[_index] != sequence[_index])
{
_result = false;
break;
}
}
}
return _result;
}
|
[
"public",
"static",
"final",
"boolean",
"matchSequence",
"(",
"byte",
"[",
"]",
"sequence",
",",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
")",
"{",
"boolean",
"_result",
"=",
"(",
"sequence",
".",
"length",
"<",
"(",
"buffer",
".",
"length",
"-",
"offset",
")",
")",
";",
"if",
"(",
"_result",
")",
"{",
"for",
"(",
"int",
"_index",
"=",
"0",
";",
"_index",
"<",
"sequence",
".",
"length",
";",
"_index",
"++",
")",
"{",
"if",
"(",
"buffer",
"[",
"_index",
"]",
"!=",
"sequence",
"[",
"_index",
"]",
")",
"{",
"_result",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"return",
"_result",
";",
"}"
] |
Verify that each byte of a buffer match the corresponding byte of a given sequence, starting from an offset.
@param sequence
the sequence of bytes to match.
@param buffer
the buffer to test.
@param offset
the offset.
@return <code>true</code> if the first bytes of buffer starting from offset are the same as the provided sequence.
|
[
"Verify",
"that",
"each",
"byte",
"of",
"a",
"buffer",
"match",
"the",
"corresponding",
"byte",
"of",
"a",
"given",
"sequence",
"starting",
"from",
"an",
"offset",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java#L51-L66
|
2,552 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java
|
DataTools.appendByteAsPaddedHexString
|
@Deprecated
public static StringBuffer appendByteAsPaddedHexString(byte value, StringBuffer buffer)
{
return buffer.append(printHexBinary(new byte[] {value}).toLowerCase());
}
|
java
|
@Deprecated
public static StringBuffer appendByteAsPaddedHexString(byte value, StringBuffer buffer)
{
return buffer.append(printHexBinary(new byte[] {value}).toLowerCase());
}
|
[
"@",
"Deprecated",
"public",
"static",
"StringBuffer",
"appendByteAsPaddedHexString",
"(",
"byte",
"value",
",",
"StringBuffer",
"buffer",
")",
"{",
"return",
"buffer",
".",
"append",
"(",
"printHexBinary",
"(",
"new",
"byte",
"[",
"]",
"{",
"value",
"}",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] |
Convert a byte into a padded hexadecimal string.
@param value
the value to convert.
@param buffer
the buffer to append the result into.
@return the updated buffer.
@deprecated use <code>buffer.append(javax.xml.bind.DatatypeConverter.printHexBinary(new byte[] {value}).toLowerCase())</code>
|
[
"Convert",
"a",
"byte",
"into",
"a",
"padded",
"hexadecimal",
"string",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java#L128-L132
|
2,553 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java
|
DataTools.appendBytesAsPaddedHexString
|
@Deprecated
public static StringBuffer appendBytesAsPaddedHexString(byte[] values, StringBuffer buffer)
{
return buffer.append(printHexBinary(values).toLowerCase());
}
|
java
|
@Deprecated
public static StringBuffer appendBytesAsPaddedHexString(byte[] values, StringBuffer buffer)
{
return buffer.append(printHexBinary(values).toLowerCase());
}
|
[
"@",
"Deprecated",
"public",
"static",
"StringBuffer",
"appendBytesAsPaddedHexString",
"(",
"byte",
"[",
"]",
"values",
",",
"StringBuffer",
"buffer",
")",
"{",
"return",
"buffer",
".",
"append",
"(",
"printHexBinary",
"(",
"values",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] |
Convert a sequence of bytes into a padded hexadecimal string.
@param values
the sequence to convert.
@param buffer
the buffer to append the result into.
@return the updated buffer.
@deprecated use <code>buffer.append(javax.xml.bind.DatatypeConverter.printHexBinary(value).toLowerCase())</code>
|
[
"Convert",
"a",
"sequence",
"of",
"bytes",
"into",
"a",
"padded",
"hexadecimal",
"string",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java#L159-L163
|
2,554 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/NamedElement.java
|
NamedElement.refreshId
|
private void refreshId()
{
if (null == getName())
{
setId(null);
}
else
{
if (null == getIdSuffix())
{
setId(getName());
}
else
{
setId(getName() + getIdSuffix());
}
}
}
|
java
|
private void refreshId()
{
if (null == getName())
{
setId(null);
}
else
{
if (null == getIdSuffix())
{
setId(getName());
}
else
{
setId(getName() + getIdSuffix());
}
}
}
|
[
"private",
"void",
"refreshId",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"getName",
"(",
")",
")",
"{",
"setId",
"(",
"null",
")",
";",
"}",
"else",
"{",
"if",
"(",
"null",
"==",
"getIdSuffix",
"(",
")",
")",
"{",
"setId",
"(",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"setId",
"(",
"getName",
"(",
")",
"+",
"getIdSuffix",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Re-compute the id of the element.
|
[
"Re",
"-",
"compute",
"the",
"id",
"of",
"the",
"element",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/NamedElement.java#L115-L132
|
2,555 |
sporniket/core
|
sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java
|
QuickDiff.outputReportLine
|
private void outputReportLine(List<String> report, MessageFormat template, String[] textLines, int currentLine)
{
Object[] _args =
{
currentLine, textLines[currentLine]
};
report.add(template.format(_args));
}
|
java
|
private void outputReportLine(List<String> report, MessageFormat template, String[] textLines, int currentLine)
{
Object[] _args =
{
currentLine, textLines[currentLine]
};
report.add(template.format(_args));
}
|
[
"private",
"void",
"outputReportLine",
"(",
"List",
"<",
"String",
">",
"report",
",",
"MessageFormat",
"template",
",",
"String",
"[",
"]",
"textLines",
",",
"int",
"currentLine",
")",
"{",
"Object",
"[",
"]",
"_args",
"=",
"{",
"currentLine",
",",
"textLines",
"[",
"currentLine",
"]",
"}",
";",
"report",
".",
"add",
"(",
"template",
".",
"format",
"(",
"_args",
")",
")",
";",
"}"
] |
Add a report line the designated line.
@param report
The report buffer.
@param template
The template to use (to distinguish between text on left and text on right).
@param textLines
The source text as an array of lines.
@param currentLine
The line to output.
|
[
"Add",
"a",
"report",
"line",
"the",
"designated",
"line",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java#L253-L260
|
2,556 |
sporniket/core
|
sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java
|
QuickDiff.outputRangeOfTextInReport
|
private void outputRangeOfTextInReport(List<String> report, MessageFormat template, String[] textLines, int startLine,
int endLine)
{
for (int _temp = startLine; _temp < endLine; _temp++)
{
outputReportLine(report, template, textLines, _temp);
}
}
|
java
|
private void outputRangeOfTextInReport(List<String> report, MessageFormat template, String[] textLines, int startLine,
int endLine)
{
for (int _temp = startLine; _temp < endLine; _temp++)
{
outputReportLine(report, template, textLines, _temp);
}
}
|
[
"private",
"void",
"outputRangeOfTextInReport",
"(",
"List",
"<",
"String",
">",
"report",
",",
"MessageFormat",
"template",
",",
"String",
"[",
"]",
"textLines",
",",
"int",
"startLine",
",",
"int",
"endLine",
")",
"{",
"for",
"(",
"int",
"_temp",
"=",
"startLine",
";",
"_temp",
"<",
"endLine",
";",
"_temp",
"++",
")",
"{",
"outputReportLine",
"(",
"report",
",",
"template",
",",
"textLines",
",",
"_temp",
")",
";",
"}",
"}"
] |
Add a report line for each designated line.
@param textLines
The source text as an array of lines.
@param report
The report buffer.
@param template
The template to use (to distinguish between text on left and text on right).
@param startLine
First line to output (inclusive)
@param endLine
Last line to output (exclusive)
|
[
"Add",
"a",
"report",
"line",
"for",
"each",
"designated",
"line",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java#L276-L283
|
2,557 |
sporniket/core
|
sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java
|
QuickDiff.findNextMatchingLine
|
private int findNextMatchingLine(String[] textLines, int startingLine, String textToMatch)
{
int _foundLeft = -1;
{
int _tempLine = startingLine + 1;
while (_tempLine < textLines.length)
{
String _tempText = getTextLine(textLines, _tempLine);
if (_tempText.equals(textToMatch))
{
_foundLeft = _tempLine;
break;
}
++_tempLine;
}
}
return _foundLeft;
}
|
java
|
private int findNextMatchingLine(String[] textLines, int startingLine, String textToMatch)
{
int _foundLeft = -1;
{
int _tempLine = startingLine + 1;
while (_tempLine < textLines.length)
{
String _tempText = getTextLine(textLines, _tempLine);
if (_tempText.equals(textToMatch))
{
_foundLeft = _tempLine;
break;
}
++_tempLine;
}
}
return _foundLeft;
}
|
[
"private",
"int",
"findNextMatchingLine",
"(",
"String",
"[",
"]",
"textLines",
",",
"int",
"startingLine",
",",
"String",
"textToMatch",
")",
"{",
"int",
"_foundLeft",
"=",
"-",
"1",
";",
"{",
"int",
"_tempLine",
"=",
"startingLine",
"+",
"1",
";",
"while",
"(",
"_tempLine",
"<",
"textLines",
".",
"length",
")",
"{",
"String",
"_tempText",
"=",
"getTextLine",
"(",
"textLines",
",",
"_tempLine",
")",
";",
"if",
"(",
"_tempText",
".",
"equals",
"(",
"textToMatch",
")",
")",
"{",
"_foundLeft",
"=",
"_tempLine",
";",
"break",
";",
"}",
"++",
"_tempLine",
";",
"}",
"}",
"return",
"_foundLeft",
";",
"}"
] |
Find the matching line, if any.
@param textLines
The source text as an array of lines.
@param startingLine
The line number from which to begin looking for the <code>textToMatch</code>.
@param textToMatch
The text to look for.
@return the line number that is the <code>textToMatch</code>.
|
[
"Find",
"the",
"matching",
"line",
"if",
"any",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java#L296-L313
|
2,558 |
sporniket/core
|
sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java
|
QuickDiff.getTextLine
|
private String getTextLine(String[] textLines, int line)
{
return (isIgnoreTrailingWhiteSpaces()) ? textLines[line].trim() : textLines[line];
}
|
java
|
private String getTextLine(String[] textLines, int line)
{
return (isIgnoreTrailingWhiteSpaces()) ? textLines[line].trim() : textLines[line];
}
|
[
"private",
"String",
"getTextLine",
"(",
"String",
"[",
"]",
"textLines",
",",
"int",
"line",
")",
"{",
"return",
"(",
"isIgnoreTrailingWhiteSpaces",
"(",
")",
")",
"?",
"textLines",
"[",
"line",
"]",
".",
"trim",
"(",
")",
":",
"textLines",
"[",
"line",
"]",
";",
"}"
] |
Return the specified line from the text.
@param textLines
The source text as an array of lines.
@param line
The line to return.
@return the line as is, or trimed, according to {@link #isIgnoreTrailingWhiteSpaces()}.
|
[
"Return",
"the",
"specified",
"line",
"from",
"the",
"text",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java#L324-L327
|
2,559 |
sporniket/core
|
sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java
|
QuickDiff.reportDiff
|
public static String[] reportDiff(String[] textOnLeft, String[] textOnRight, boolean ignoreEmptyLines,
boolean ignoreTrailingWhiteSpaces)
{
QuickDiff _instance = new QuickDiff();
_instance.setIgnoreEmptyLines(ignoreEmptyLines);
_instance.setIgnoreTrailingWhiteSpaces(ignoreTrailingWhiteSpaces);
return _instance.reportDiff(textOnLeft, textOnRight);
}
|
java
|
public static String[] reportDiff(String[] textOnLeft, String[] textOnRight, boolean ignoreEmptyLines,
boolean ignoreTrailingWhiteSpaces)
{
QuickDiff _instance = new QuickDiff();
_instance.setIgnoreEmptyLines(ignoreEmptyLines);
_instance.setIgnoreTrailingWhiteSpaces(ignoreTrailingWhiteSpaces);
return _instance.reportDiff(textOnLeft, textOnRight);
}
|
[
"public",
"static",
"String",
"[",
"]",
"reportDiff",
"(",
"String",
"[",
"]",
"textOnLeft",
",",
"String",
"[",
"]",
"textOnRight",
",",
"boolean",
"ignoreEmptyLines",
",",
"boolean",
"ignoreTrailingWhiteSpaces",
")",
"{",
"QuickDiff",
"_instance",
"=",
"new",
"QuickDiff",
"(",
")",
";",
"_instance",
".",
"setIgnoreEmptyLines",
"(",
"ignoreEmptyLines",
")",
";",
"_instance",
".",
"setIgnoreTrailingWhiteSpaces",
"(",
"ignoreTrailingWhiteSpaces",
")",
";",
"return",
"_instance",
".",
"reportDiff",
"(",
"textOnLeft",
",",
"textOnRight",
")",
";",
"}"
] |
Macro to compute a diff report.
@param textOnLeft
The text on left as an array of lines.
@param textOnRight
The text on right as an array of lines.
@param ignoreEmptyLines
Set to <code>true</code> if you want to skip empty lines.
@param ignoreTrailingWhiteSpaces
Set to <code>true</code> if lines are to be compared without leading and trailing whitespaces (will use
{@link String#trim()}).
@return The diff report as an array of lines.
|
[
"Macro",
"to",
"compute",
"a",
"diff",
"report",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-strings/src/main/java/com/sporniket/strings/QuickDiff.java#L343-L351
|
2,560 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java
|
CollectionTools.getObject
|
public static Object getObject(final ResourceBundle source, final String key, final Object defaultValue)
{
try
{
return source.getObject(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
java
|
public static Object getObject(final ResourceBundle source, final String key, final Object defaultValue)
{
try
{
return source.getObject(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
[
"public",
"static",
"Object",
"getObject",
"(",
"final",
"ResourceBundle",
"source",
",",
"final",
"String",
"key",
",",
"final",
"Object",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"source",
".",
"getObject",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Return an object from a ResourceBundle.
@param source
ResourceBundle from which extract the value
@param key
The key to retrieve the value
@param defaultValue
When the wanted value doesn't exist, return this one
@return The wanted object or defaulValue
|
[
"Return",
"an",
"object",
"from",
"a",
"ResourceBundle",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java#L54-L64
|
2,561 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java
|
CollectionTools.getObject
|
public static Object getObject(final Map<String, Object> source, final String key, final Object defaultValue)
{
try
{
return source.get(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
java
|
public static Object getObject(final Map<String, Object> source, final String key, final Object defaultValue)
{
try
{
return source.get(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
[
"public",
"static",
"Object",
"getObject",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
",",
"final",
"String",
"key",
",",
"final",
"Object",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"source",
".",
"get",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Return an object from a Map.
@param source
Map from which extract the value
@param key
The key to retrieve the value
@param defaultValue
When the wanted value doesn't exist, return this one
@return The wanted object or defaulValue
|
[
"Return",
"an",
"object",
"from",
"a",
"Map",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java#L77-L87
|
2,562 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java
|
CollectionTools.getString
|
public static String getString(final ResourceBundle source, final String key, final String defaultValue)
{
try
{
return source.getString(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
java
|
public static String getString(final ResourceBundle source, final String key, final String defaultValue)
{
try
{
return source.getString(key);
}
catch (Exception _exception)
{
return defaultValue;
}
}
|
[
"public",
"static",
"String",
"getString",
"(",
"final",
"ResourceBundle",
"source",
",",
"final",
"String",
"key",
",",
"final",
"String",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"source",
".",
"getString",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Return an string from a ResourceBundle.
@param source
ResourceBundle from which extract the value
@param key
The key to retrieve the value
@param defaultValue
When the wanted value doesn't exist, return this one
@return The wanted object or defaulValue
|
[
"Return",
"an",
"string",
"from",
"a",
"ResourceBundle",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/CollectionTools.java#L100-L110
|
2,563 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/sgml/SgmlUtils.java
|
SgmlUtils.generateAttribute
|
public static String generateAttribute(String attributeName, String value)
{
Object[] _args =
{
attributeName, SGML_VALUE_ENCODER.apply(value)
};
return MESSAGE_FORMAT__ATTRIBUT.format(_args);
}
|
java
|
public static String generateAttribute(String attributeName, String value)
{
Object[] _args =
{
attributeName, SGML_VALUE_ENCODER.apply(value)
};
return MESSAGE_FORMAT__ATTRIBUT.format(_args);
}
|
[
"public",
"static",
"String",
"generateAttribute",
"(",
"String",
"attributeName",
",",
"String",
"value",
")",
"{",
"Object",
"[",
"]",
"_args",
"=",
"{",
"attributeName",
",",
"SGML_VALUE_ENCODER",
".",
"apply",
"(",
"value",
")",
"}",
";",
"return",
"MESSAGE_FORMAT__ATTRIBUT",
".",
"format",
"(",
"_args",
")",
";",
"}"
] |
Generate an attribute of the specified name and value.
@param attributeName
name of the attribute.
@param value
value of the attribute.
@return the SGML code for an attribute.
|
[
"Generate",
"an",
"attribute",
"of",
"the",
"specified",
"name",
"and",
"value",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/sgml/SgmlUtils.java#L77-L84
|
2,564 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java
|
NodeListProcessor.addDefaultProcessor
|
public void addDefaultProcessor(NodeProcessor processor)
{
if (null == processor)
{
throw new IllegalArgumentException("Processor should not be null.");
}
getActionPool().put(NODE_NAME__DEFAULT, processor);
}
|
java
|
public void addDefaultProcessor(NodeProcessor processor)
{
if (null == processor)
{
throw new IllegalArgumentException("Processor should not be null.");
}
getActionPool().put(NODE_NAME__DEFAULT, processor);
}
|
[
"public",
"void",
"addDefaultProcessor",
"(",
"NodeProcessor",
"processor",
")",
"{",
"if",
"(",
"null",
"==",
"processor",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Processor should not be null.\"",
")",
";",
"}",
"getActionPool",
"(",
")",
".",
"put",
"(",
"NODE_NAME__DEFAULT",
",",
"processor",
")",
";",
"}"
] |
Add a default processing that will be applied when no specific processor is found.
@param processor
the default processor.
|
[
"Add",
"a",
"default",
"processing",
"that",
"will",
"be",
"applied",
"when",
"no",
"specific",
"processor",
"is",
"found",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java#L103-L110
|
2,565 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java
|
NodeListProcessor.addProcessor
|
public void addProcessor(String nodeName, NodeProcessor processor)
{
if (null == processor)
{
throw new IllegalArgumentException("Processor should not be null.");
}
if (IS_EMPTY.test(nodeName))
{
throw new IllegalArgumentException("The node name should not be empty.");
}
getActionPool().put(nodeName, processor);
}
|
java
|
public void addProcessor(String nodeName, NodeProcessor processor)
{
if (null == processor)
{
throw new IllegalArgumentException("Processor should not be null.");
}
if (IS_EMPTY.test(nodeName))
{
throw new IllegalArgumentException("The node name should not be empty.");
}
getActionPool().put(nodeName, processor);
}
|
[
"public",
"void",
"addProcessor",
"(",
"String",
"nodeName",
",",
"NodeProcessor",
"processor",
")",
"{",
"if",
"(",
"null",
"==",
"processor",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Processor should not be null.\"",
")",
";",
"}",
"if",
"(",
"IS_EMPTY",
".",
"test",
"(",
"nodeName",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The node name should not be empty.\"",
")",
";",
"}",
"getActionPool",
"(",
")",
".",
"put",
"(",
"nodeName",
",",
"processor",
")",
";",
"}"
] |
Add a specific processing that will be applied to nodes having the matching name.
@param nodeName
the name of nodes that will be processed.
@param processor
the processor.
|
[
"Add",
"a",
"specific",
"processing",
"that",
"will",
"be",
"applied",
"to",
"nodes",
"having",
"the",
"matching",
"name",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java#L120-L131
|
2,566 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java
|
NodeListProcessor.doProcessNext
|
private void doProcessNext()
{
int _position = getPosition();
Node _current = getSource().item(_position);
if (getActionPool().containsKey(_current.getNodeName()))
{
getActionPool().get(_current.getNodeName()).execute(_current, _position);
}
else if (getActionPool().containsKey(NODE_NAME__DEFAULT))
{
getActionPool().get(NODE_NAME__DEFAULT).execute(_current, _position);
}
// else do nothing...
// done
_position++;
setPosition(_position);
}
|
java
|
private void doProcessNext()
{
int _position = getPosition();
Node _current = getSource().item(_position);
if (getActionPool().containsKey(_current.getNodeName()))
{
getActionPool().get(_current.getNodeName()).execute(_current, _position);
}
else if (getActionPool().containsKey(NODE_NAME__DEFAULT))
{
getActionPool().get(NODE_NAME__DEFAULT).execute(_current, _position);
}
// else do nothing...
// done
_position++;
setPosition(_position);
}
|
[
"private",
"void",
"doProcessNext",
"(",
")",
"{",
"int",
"_position",
"=",
"getPosition",
"(",
")",
";",
"Node",
"_current",
"=",
"getSource",
"(",
")",
".",
"item",
"(",
"_position",
")",
";",
"if",
"(",
"getActionPool",
"(",
")",
".",
"containsKey",
"(",
"_current",
".",
"getNodeName",
"(",
")",
")",
")",
"{",
"getActionPool",
"(",
")",
".",
"get",
"(",
"_current",
".",
"getNodeName",
"(",
")",
")",
".",
"execute",
"(",
"_current",
",",
"_position",
")",
";",
"}",
"else",
"if",
"(",
"getActionPool",
"(",
")",
".",
"containsKey",
"(",
"NODE_NAME__DEFAULT",
")",
")",
"{",
"getActionPool",
"(",
")",
".",
"get",
"(",
"NODE_NAME__DEFAULT",
")",
".",
"execute",
"(",
"_current",
",",
"_position",
")",
";",
"}",
"// else do nothing...",
"// done",
"_position",
"++",
";",
"setPosition",
"(",
"_position",
")",
";",
"}"
] |
Perform the processing on the next available node.
|
[
"Perform",
"the",
"processing",
"on",
"the",
"next",
"available",
"node",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/NodeListProcessor.java#L136-L154
|
2,567 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/FluidFlowPanelModel.java
|
FluidFlowPanelModel.createFluidFlowPanel
|
public static final FluidFlowPanelModel createFluidFlowPanel(FlowLayout flowLayout)
{
JPanel _panel = new JPanel(flowLayout);
PanelSizeUpdaterOnViewPortResize _updater = new PanelSizeUpdaterOnViewPortResize(_panel);
_panel.addContainerListener(_updater);
JScrollPane _scroller = new JScrollPane(_panel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
_scroller.addComponentListener(_updater);
return new FluidFlowPanelModel(_panel, _scroller);
}
|
java
|
public static final FluidFlowPanelModel createFluidFlowPanel(FlowLayout flowLayout)
{
JPanel _panel = new JPanel(flowLayout);
PanelSizeUpdaterOnViewPortResize _updater = new PanelSizeUpdaterOnViewPortResize(_panel);
_panel.addContainerListener(_updater);
JScrollPane _scroller = new JScrollPane(_panel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
_scroller.addComponentListener(_updater);
return new FluidFlowPanelModel(_panel, _scroller);
}
|
[
"public",
"static",
"final",
"FluidFlowPanelModel",
"createFluidFlowPanel",
"(",
"FlowLayout",
"flowLayout",
")",
"{",
"JPanel",
"_panel",
"=",
"new",
"JPanel",
"(",
"flowLayout",
")",
";",
"PanelSizeUpdaterOnViewPortResize",
"_updater",
"=",
"new",
"PanelSizeUpdaterOnViewPortResize",
"(",
"_panel",
")",
";",
"_panel",
".",
"addContainerListener",
"(",
"_updater",
")",
";",
"JScrollPane",
"_scroller",
"=",
"new",
"JScrollPane",
"(",
"_panel",
",",
"JScrollPane",
".",
"VERTICAL_SCROLLBAR_ALWAYS",
",",
"JScrollPane",
".",
"HORIZONTAL_SCROLLBAR_NEVER",
")",
";",
"_scroller",
".",
"addComponentListener",
"(",
"_updater",
")",
";",
"return",
"new",
"FluidFlowPanelModel",
"(",
"_panel",
",",
"_scroller",
")",
";",
"}"
] |
The macro that create a scrollable panel with a fluid flow layout.
@param flowLayout
the flow layout to use by this panel.
@return the component.
|
[
"The",
"macro",
"that",
"create",
"a",
"scrollable",
"panel",
"with",
"a",
"fluid",
"flow",
"layout",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/swing/FluidFlowPanelModel.java#L204-L213
|
2,568 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/AdaptedAction.java
|
AdaptedAction.retrieveIcon
|
private ImageIcon retrieveIcon(IconLocationType location)
{
try
{
return myIconProvider.retrieveIcon(location);
}
catch (Exception _exception)
{
System.err.println(_exception.getMessage());
}
return null;
}
|
java
|
private ImageIcon retrieveIcon(IconLocationType location)
{
try
{
return myIconProvider.retrieveIcon(location);
}
catch (Exception _exception)
{
System.err.println(_exception.getMessage());
}
return null;
}
|
[
"private",
"ImageIcon",
"retrieveIcon",
"(",
"IconLocationType",
"location",
")",
"{",
"try",
"{",
"return",
"myIconProvider",
".",
"retrieveIcon",
"(",
"location",
")",
";",
"}",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"_exception",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Load the icon file.
@param location
Path to the file.
|
[
"Load",
"the",
"icon",
"file",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/AdaptedAction.java#L180-L191
|
2,569 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java
|
TextLoader.getInstance
|
public static TextLoader getInstance(Encoding encoding)
{
if (null == encoding)
{
return getInstance();
}
else
{
if (!INSTANCE_BY_ENCODING.containsKey(encoding.getIsoName()))
{
TextLoader _newInstance = new TextLoader(encoding);
INSTANCE_BY_ENCODING.put(encoding.getIsoName(), _newInstance);
}
return INSTANCE_BY_ENCODING.get(encoding.getIsoName());
}
}
|
java
|
public static TextLoader getInstance(Encoding encoding)
{
if (null == encoding)
{
return getInstance();
}
else
{
if (!INSTANCE_BY_ENCODING.containsKey(encoding.getIsoName()))
{
TextLoader _newInstance = new TextLoader(encoding);
INSTANCE_BY_ENCODING.put(encoding.getIsoName(), _newInstance);
}
return INSTANCE_BY_ENCODING.get(encoding.getIsoName());
}
}
|
[
"public",
"static",
"TextLoader",
"getInstance",
"(",
"Encoding",
"encoding",
")",
"{",
"if",
"(",
"null",
"==",
"encoding",
")",
"{",
"return",
"getInstance",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"INSTANCE_BY_ENCODING",
".",
"containsKey",
"(",
"encoding",
".",
"getIsoName",
"(",
")",
")",
")",
"{",
"TextLoader",
"_newInstance",
"=",
"new",
"TextLoader",
"(",
"encoding",
")",
";",
"INSTANCE_BY_ENCODING",
".",
"put",
"(",
"encoding",
".",
"getIsoName",
"(",
")",
",",
"_newInstance",
")",
";",
"}",
"return",
"INSTANCE_BY_ENCODING",
".",
"get",
"(",
"encoding",
".",
"getIsoName",
"(",
")",
")",
";",
"}",
"}"
] |
Get a default instance for the given encoding.
@param encoding the encoding to use.
@return the instance for the encoding.
|
[
"Get",
"a",
"default",
"instance",
"for",
"the",
"given",
"encoding",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java#L85-L100
|
2,570 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java
|
TextLoader.append
|
public StringBuffer append(Reader source, StringBuffer buffer) throws IOException
{
BufferedReader _bufferedReader = new BufferedReader(source);
char[] _buffer = new char[getBufferSize()]; // load by chunk of 4 ko
try
{
for (int _countReadChars = 0; _countReadChars >= 0;)
{
buffer.append(_buffer, 0, _countReadChars);
_countReadChars = _bufferedReader.read(_buffer);
}
}
finally
{
_bufferedReader.close();
}
return buffer;
}
|
java
|
public StringBuffer append(Reader source, StringBuffer buffer) throws IOException
{
BufferedReader _bufferedReader = new BufferedReader(source);
char[] _buffer = new char[getBufferSize()]; // load by chunk of 4 ko
try
{
for (int _countReadChars = 0; _countReadChars >= 0;)
{
buffer.append(_buffer, 0, _countReadChars);
_countReadChars = _bufferedReader.read(_buffer);
}
}
finally
{
_bufferedReader.close();
}
return buffer;
}
|
[
"public",
"StringBuffer",
"append",
"(",
"Reader",
"source",
",",
"StringBuffer",
"buffer",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"_bufferedReader",
"=",
"new",
"BufferedReader",
"(",
"source",
")",
";",
"char",
"[",
"]",
"_buffer",
"=",
"new",
"char",
"[",
"getBufferSize",
"(",
")",
"]",
";",
"// load by chunk of 4 ko",
"try",
"{",
"for",
"(",
"int",
"_countReadChars",
"=",
"0",
";",
"_countReadChars",
">=",
"0",
";",
")",
"{",
"buffer",
".",
"append",
"(",
"_buffer",
",",
"0",
",",
"_countReadChars",
")",
";",
"_countReadChars",
"=",
"_bufferedReader",
".",
"read",
"(",
"_buffer",
")",
";",
"}",
"}",
"finally",
"{",
"_bufferedReader",
".",
"close",
"(",
")",
";",
"}",
"return",
"buffer",
";",
"}"
] |
Load a text from the specified reader and put it in the provided StringBuffer.
@param source source reader.
@param buffer buffer to load text into.
@return the buffer
@throws IOException if there is a problem to deal with.
|
[
"Load",
"a",
"text",
"from",
"the",
"specified",
"reader",
"and",
"put",
"it",
"in",
"the",
"provided",
"StringBuffer",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java#L188-L205
|
2,571 |
sporniket/core
|
sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java
|
TextLoader.loadTextFile
|
public String loadTextFile(File source) throws IOException
{
StringBuffer _result = new StringBuffer();
append(source, _result);
return _result.toString();
}
|
java
|
public String loadTextFile(File source) throws IOException
{
StringBuffer _result = new StringBuffer();
append(source, _result);
return _result.toString();
}
|
[
"public",
"String",
"loadTextFile",
"(",
"File",
"source",
")",
"throws",
"IOException",
"{",
"StringBuffer",
"_result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"append",
"(",
"source",
",",
"_result",
")",
";",
"return",
"_result",
".",
"toString",
"(",
")",
";",
"}"
] |
Load a text file.
@param source source file.
@return the text.
@throws IOException if there is a problem to deal with.
|
[
"Load",
"a",
"text",
"file",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-io/src/main/java/com/sporniket/libre/io/TextLoader.java#L258-L263
|
2,572 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Select.java
|
Select.create
|
public static Select create(String name, String idSuffix, List<Option> options, boolean allowMultipleSelection,
boolean isDisabled)
{
Select _select = new Select();
_select.setName(name);
_select.setIdSuffix(idSuffix);
_select.setDisabled(isDisabled);
_select.setMultiple(allowMultipleSelection);
_select.getOptions().addAll(options);
return _select;
}
|
java
|
public static Select create(String name, String idSuffix, List<Option> options, boolean allowMultipleSelection,
boolean isDisabled)
{
Select _select = new Select();
_select.setName(name);
_select.setIdSuffix(idSuffix);
_select.setDisabled(isDisabled);
_select.setMultiple(allowMultipleSelection);
_select.getOptions().addAll(options);
return _select;
}
|
[
"public",
"static",
"Select",
"create",
"(",
"String",
"name",
",",
"String",
"idSuffix",
",",
"List",
"<",
"Option",
">",
"options",
",",
"boolean",
"allowMultipleSelection",
",",
"boolean",
"isDisabled",
")",
"{",
"Select",
"_select",
"=",
"new",
"Select",
"(",
")",
";",
"_select",
".",
"setName",
"(",
"name",
")",
";",
"_select",
".",
"setIdSuffix",
"(",
"idSuffix",
")",
";",
"_select",
".",
"setDisabled",
"(",
"isDisabled",
")",
";",
"_select",
".",
"setMultiple",
"(",
"allowMultipleSelection",
")",
";",
"_select",
".",
"getOptions",
"(",
")",
".",
"addAll",
"(",
"options",
")",
";",
"return",
"_select",
";",
"}"
] |
Create a fully defined selector..
@param name the name of the selector.
@param idSuffix the suffix to add to compute the id attribute.
@param options a list of options.
@param allowMultipleSelection <code>true</code> to allow multiple selection.
@param isDisabled disabled attribute.
@return a fully defined {@link Select}.
|
[
"Create",
"a",
"fully",
"defined",
"selector",
".."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/html/Select.java#L76-L86
|
2,573 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcUtils.java
|
XIncProcUtils.isXInclude
|
public static boolean isXInclude(final QName qname)
{
return XINCLUDE_QNAME.getLocalPart().equals(qname.getLocalPart()) &&
(Strings.isNullOrEmpty(qname.getNamespaceURI()) ||
XINCLUDE_QNAME.getNamespaceURI().equals(qname.getNamespaceURI()));
}
|
java
|
public static boolean isXInclude(final QName qname)
{
return XINCLUDE_QNAME.getLocalPart().equals(qname.getLocalPart()) &&
(Strings.isNullOrEmpty(qname.getNamespaceURI()) ||
XINCLUDE_QNAME.getNamespaceURI().equals(qname.getNamespaceURI()));
}
|
[
"public",
"static",
"boolean",
"isXInclude",
"(",
"final",
"QName",
"qname",
")",
"{",
"return",
"XINCLUDE_QNAME",
".",
"getLocalPart",
"(",
")",
".",
"equals",
"(",
"qname",
".",
"getLocalPart",
"(",
")",
")",
"&&",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"qname",
".",
"getNamespaceURI",
"(",
")",
")",
"||",
"XINCLUDE_QNAME",
".",
"getNamespaceURI",
"(",
")",
".",
"equals",
"(",
"qname",
".",
"getNamespaceURI",
"(",
")",
")",
")",
";",
"}"
] |
Return if element is a Xinclude element or not
@param qname of the element to test
@return true if element is a xinclude element, false otherwise
|
[
"Return",
"if",
"element",
"is",
"a",
"Xinclude",
"element",
"or",
"not"
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcUtils.java#L78-L83
|
2,574 |
etourdot/xincproc
|
xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcUtils.java
|
XIncProcUtils.isFallback
|
public static boolean isFallback(final QName qname)
{
return FALLBACK_QNAME.getLocalPart().equals(qname.getLocalPart()) &&
(Strings.isNullOrEmpty(qname.getNamespaceURI()) ||
FALLBACK_QNAME.getNamespaceURI().equals(qname.getNamespaceURI()));
}
|
java
|
public static boolean isFallback(final QName qname)
{
return FALLBACK_QNAME.getLocalPart().equals(qname.getLocalPart()) &&
(Strings.isNullOrEmpty(qname.getNamespaceURI()) ||
FALLBACK_QNAME.getNamespaceURI().equals(qname.getNamespaceURI()));
}
|
[
"public",
"static",
"boolean",
"isFallback",
"(",
"final",
"QName",
"qname",
")",
"{",
"return",
"FALLBACK_QNAME",
".",
"getLocalPart",
"(",
")",
".",
"equals",
"(",
"qname",
".",
"getLocalPart",
"(",
")",
")",
"&&",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"qname",
".",
"getNamespaceURI",
"(",
")",
")",
"||",
"FALLBACK_QNAME",
".",
"getNamespaceURI",
"(",
")",
".",
"equals",
"(",
"qname",
".",
"getNamespaceURI",
"(",
")",
")",
")",
";",
"}"
] |
Return if element is a Fallback elementor not
@param qname of the element to test
@return true if element is a fallback element, false otherwise
|
[
"Return",
"if",
"element",
"is",
"a",
"Fallback",
"elementor",
"not"
] |
6e9e9352e1975957ae6821a04c248ea49c7323ec
|
https://github.com/etourdot/xincproc/blob/6e9e9352e1975957ae6821a04c248ea49c7323ec/xinclude/src/main/java/org/etourdot/xincproc/xinclude/XIncProcUtils.java#L91-L96
|
2,575 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java
|
IsoParsableDateFormatter.format
|
public static String format(Integer year, Integer month, Integer day)
{
Object[] _args =
{
year, month, day
};
return SHORT__DATE.format(_args);
}
|
java
|
public static String format(Integer year, Integer month, Integer day)
{
Object[] _args =
{
year, month, day
};
return SHORT__DATE.format(_args);
}
|
[
"public",
"static",
"String",
"format",
"(",
"Integer",
"year",
",",
"Integer",
"month",
",",
"Integer",
"day",
")",
"{",
"Object",
"[",
"]",
"_args",
"=",
"{",
"year",
",",
"month",
",",
"day",
"}",
";",
"return",
"SHORT__DATE",
".",
"format",
"(",
"_args",
")",
";",
"}"
] |
Formatter for a date.
@param year [0..9999].
@param month [1..12].
@param day day of month [1..31].
@return the ISO formatted date.
|
[
"Formatter",
"for",
"a",
"date",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java#L116-L123
|
2,576 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java
|
IsoParsableDateFormatter.format
|
public static String format(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second)
{
Object[] _args =
{
year, month, day, hour, minute, second
};
return SHORT__DATE_TIME.format(_args);
}
|
java
|
public static String format(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second)
{
Object[] _args =
{
year, month, day, hour, minute, second
};
return SHORT__DATE_TIME.format(_args);
}
|
[
"public",
"static",
"String",
"format",
"(",
"Integer",
"year",
",",
"Integer",
"month",
",",
"Integer",
"day",
",",
"Integer",
"hour",
",",
"Integer",
"minute",
",",
"Integer",
"second",
")",
"{",
"Object",
"[",
"]",
"_args",
"=",
"{",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
"}",
";",
"return",
"SHORT__DATE_TIME",
".",
"format",
"(",
"_args",
")",
";",
"}"
] |
Formatter for a date and time.
@param year [0..9999].
@param month [1..12].
@param day day of month [1..31].
@param hour [0..23].
@param minute [0..59].
@param second [0..59].
@return the ISO formatted date and time.
|
[
"Formatter",
"for",
"a",
"date",
"and",
"time",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java#L136-L143
|
2,577 |
sporniket/core
|
sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java
|
IsoParsableDateFormatter.format
|
public static String format(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second,
Integer millisecond)
{
Object[] _args =
{
year, month, day, hour, minute, second, millisecond
};
return LONG__MS.format(_args);
}
|
java
|
public static String format(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second,
Integer millisecond)
{
Object[] _args =
{
year, month, day, hour, minute, second, millisecond
};
return LONG__MS.format(_args);
}
|
[
"public",
"static",
"String",
"format",
"(",
"Integer",
"year",
",",
"Integer",
"month",
",",
"Integer",
"day",
",",
"Integer",
"hour",
",",
"Integer",
"minute",
",",
"Integer",
"second",
",",
"Integer",
"millisecond",
")",
"{",
"Object",
"[",
"]",
"_args",
"=",
"{",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
",",
"millisecond",
"}",
";",
"return",
"LONG__MS",
".",
"format",
"(",
"_args",
")",
";",
"}"
] |
Formatter for a date and time up to milliseconds.
@param year [0..9999].
@param month [1..12].
@param day day of month [1..31].
@param hour [0..23].
@param minute [0..59].
@param second [0..59].
@param millisecond [0..999].
@return the ISO formatted date and time.
|
[
"Formatter",
"for",
"a",
"date",
"and",
"time",
"up",
"to",
"milliseconds",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/date/IsoParsableDateFormatter.java#L157-L165
|
2,578 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.appendOpeningTag
|
public static StringBuffer appendOpeningTag(StringBuffer buffer, String tag)
{
return appendOpeningTag(buffer, tag, EMPTY_MAP);
}
|
java
|
public static StringBuffer appendOpeningTag(StringBuffer buffer, String tag)
{
return appendOpeningTag(buffer, tag, EMPTY_MAP);
}
|
[
"public",
"static",
"StringBuffer",
"appendOpeningTag",
"(",
"StringBuffer",
"buffer",
",",
"String",
"tag",
")",
"{",
"return",
"appendOpeningTag",
"(",
"buffer",
",",
"tag",
",",
"EMPTY_MAP",
")",
";",
"}"
] |
Add an opening tag to a StringBuffer.
If the buffer is null, a new one is created.
@param buffer
StringBuffer to fill
@param tag
the tag to open
@return the buffer
|
[
"Add",
"an",
"opening",
"tag",
"to",
"a",
"StringBuffer",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L352-L355
|
2,579 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.appendTextInsideTag
|
public static StringBuffer appendTextInsideTag(StringBuffer buffer, String text, String tag)
{
return appendTextInsideTag(buffer, text, tag, EMPTY_MAP);
}
|
java
|
public static StringBuffer appendTextInsideTag(StringBuffer buffer, String text, String tag)
{
return appendTextInsideTag(buffer, text, tag, EMPTY_MAP);
}
|
[
"public",
"static",
"StringBuffer",
"appendTextInsideTag",
"(",
"StringBuffer",
"buffer",
",",
"String",
"text",
",",
"String",
"tag",
")",
"{",
"return",
"appendTextInsideTag",
"(",
"buffer",
",",
"text",
",",
"tag",
",",
"EMPTY_MAP",
")",
";",
"}"
] |
Wrap a text inside a tag.
@param buffer
StringBuffer to fill
@param text
the text to wrap
@param tag
the tag to use
@return the buffer
|
[
"Wrap",
"a",
"text",
"inside",
"a",
"tag",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L386-L389
|
2,580 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.decodeAttributeValue
|
public static String decodeAttributeValue(String value)
{
String _result = value.replaceAll(PATTERN__ENTITY_QUOTE, VALUE__CHAR_QUOTE);
_result = _result.replaceAll(PATTERN__ENTITY_AMPERSAND, VALUE__CHAR_AMPERSAND);
return _result;
}
|
java
|
public static String decodeAttributeValue(String value)
{
String _result = value.replaceAll(PATTERN__ENTITY_QUOTE, VALUE__CHAR_QUOTE);
_result = _result.replaceAll(PATTERN__ENTITY_AMPERSAND, VALUE__CHAR_AMPERSAND);
return _result;
}
|
[
"public",
"static",
"String",
"decodeAttributeValue",
"(",
"String",
"value",
")",
"{",
"String",
"_result",
"=",
"value",
".",
"replaceAll",
"(",
"PATTERN__ENTITY_QUOTE",
",",
"VALUE__CHAR_QUOTE",
")",
";",
"_result",
"=",
"_result",
".",
"replaceAll",
"(",
"PATTERN__ENTITY_AMPERSAND",
",",
"VALUE__CHAR_AMPERSAND",
")",
";",
"return",
"_result",
";",
"}"
] |
Reverse the escaping of special chars from a value of an attribute.
@param value
the value to decode
@return the decoded value
|
[
"Reverse",
"the",
"escaping",
"of",
"special",
"chars",
"from",
"a",
"value",
"of",
"an",
"attribute",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L418-L423
|
2,581 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.encodeAttributeValue
|
public static String encodeAttributeValue(String value)
{
String _result = value.replaceAll(PATTERN__CHAR_AMPERSAND, VALUE__ENTITY_AMPERSAND);
_result = _result.replaceAll(PATTERN__CHAR_QUOTE, VALUE__ENTITY_QUOTE);
return _result;
}
|
java
|
public static String encodeAttributeValue(String value)
{
String _result = value.replaceAll(PATTERN__CHAR_AMPERSAND, VALUE__ENTITY_AMPERSAND);
_result = _result.replaceAll(PATTERN__CHAR_QUOTE, VALUE__ENTITY_QUOTE);
return _result;
}
|
[
"public",
"static",
"String",
"encodeAttributeValue",
"(",
"String",
"value",
")",
"{",
"String",
"_result",
"=",
"value",
".",
"replaceAll",
"(",
"PATTERN__CHAR_AMPERSAND",
",",
"VALUE__ENTITY_AMPERSAND",
")",
";",
"_result",
"=",
"_result",
".",
"replaceAll",
"(",
"PATTERN__CHAR_QUOTE",
",",
"VALUE__ENTITY_QUOTE",
")",
";",
"return",
"_result",
";",
"}"
] |
Convert special chars so that it is legal as an attribute value.
@param value
the value to convert.
@return the coded value.
|
[
"Convert",
"special",
"chars",
"so",
"that",
"it",
"is",
"legal",
"as",
"an",
"attribute",
"value",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L526-L531
|
2,582 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.getCdataSection
|
public static String getCdataSection(String cdataContent)
{
StringBuffer _result = new StringBuffer();
return doAppendCdataSection(_result, cdataContent).toString();
}
|
java
|
public static String getCdataSection(String cdataContent)
{
StringBuffer _result = new StringBuffer();
return doAppendCdataSection(_result, cdataContent).toString();
}
|
[
"public",
"static",
"String",
"getCdataSection",
"(",
"String",
"cdataContent",
")",
"{",
"StringBuffer",
"_result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"return",
"doAppendCdataSection",
"(",
"_result",
",",
"cdataContent",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Create a string containing a Cdata section.
@param cdataContent
the cdata content.
@return the closing tag.
|
[
"Create",
"a",
"string",
"containing",
"a",
"Cdata",
"section",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L540-L544
|
2,583 |
sporniket/core
|
sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java
|
XmlStringTools.getComment
|
public static String getComment(String comment)
{
StringBuffer _result = new StringBuffer();
return doAppendComment(_result, comment).toString();
}
|
java
|
public static String getComment(String comment)
{
StringBuffer _result = new StringBuffer();
return doAppendComment(_result, comment).toString();
}
|
[
"public",
"static",
"String",
"getComment",
"(",
"String",
"comment",
")",
"{",
"StringBuffer",
"_result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"return",
"doAppendComment",
"(",
"_result",
",",
"comment",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Create a string containing a comment.
@param comment
the comment to generate.
@return the closing tag.
|
[
"Create",
"a",
"string",
"containing",
"a",
"comment",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ml/src/main/java/com/sporniket/libre/lang/xml/XmlStringTools.java#L566-L570
|
2,584 |
sporniket/core
|
sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/Utils.java
|
Utils.retrieveActionDefinitionFromMessageProvider
|
public static UserInterfaceAction<URL> retrieveActionDefinitionFromMessageProvider(UserInterfaceAction<URL> action,
MessageProviderInterface messageProvider, String prefix, Locale locale, Object callbackProvider,
UrlProvider urlProvider)
{
// sanity check
if (null == action)
{
throw new NullPointerException("action must not be null");
}
if (null == messageProvider)
{
throw new NullPointerException("messageProvider must not be null");
}
if (null == callbackProvider)
{
throw new NullPointerException("callbackProvider must not be null");
}
String _prefix = (null != prefix) ? prefix.trim() + TOKEN_SEPARATOR : TOKEN_SEPARATOR;
// ok, do the processing
try
{
action.setCallback(FunctorFactory.instanciateFunctorAsAnInstanceMethodWrapper(callbackProvider,
messageProvider.getMessage(_prefix + TOKEN_CALLBACK, locale)));
}
catch (Exception _exception)
{
throw new ActionException(_exception);
}
try
{
String _location = messageProvider.getMessage(_prefix + TOKEN_ICON_FOR_BUTTON, locale);
if (IS_NOT_EMPTY.test(_location))
{
action.setIconForButton(urlProvider.getUrl(_location));
}
}
catch (UrlProviderException _exception)
{
// throw new ActionException(_exception);
}
try
{
String _location = messageProvider.getMessage(_prefix + TOKEN_ICON_FOR_MENU, locale);
if (IS_NOT_EMPTY.test(_location))
{
action.setIconForMenu(urlProvider.getUrl(_location));
}
}
catch (UrlProviderException _exception)
{
// throw new ActionException(_exception);
}
action.setKeyboardShortcut(messageProvider.getMessage(_prefix + TOKEN_KEYBOARD_SHORTCUT, locale));
action.setLabelDescription(messageProvider.getMessage(_prefix + TOKEN_LABEL_DESCRIPTION, locale));
action.setLabelMessage(messageProvider.getMessage(_prefix + TOKEN_LABEL_MESSAGE, locale));
// done
return action;
}
|
java
|
public static UserInterfaceAction<URL> retrieveActionDefinitionFromMessageProvider(UserInterfaceAction<URL> action,
MessageProviderInterface messageProvider, String prefix, Locale locale, Object callbackProvider,
UrlProvider urlProvider)
{
// sanity check
if (null == action)
{
throw new NullPointerException("action must not be null");
}
if (null == messageProvider)
{
throw new NullPointerException("messageProvider must not be null");
}
if (null == callbackProvider)
{
throw new NullPointerException("callbackProvider must not be null");
}
String _prefix = (null != prefix) ? prefix.trim() + TOKEN_SEPARATOR : TOKEN_SEPARATOR;
// ok, do the processing
try
{
action.setCallback(FunctorFactory.instanciateFunctorAsAnInstanceMethodWrapper(callbackProvider,
messageProvider.getMessage(_prefix + TOKEN_CALLBACK, locale)));
}
catch (Exception _exception)
{
throw new ActionException(_exception);
}
try
{
String _location = messageProvider.getMessage(_prefix + TOKEN_ICON_FOR_BUTTON, locale);
if (IS_NOT_EMPTY.test(_location))
{
action.setIconForButton(urlProvider.getUrl(_location));
}
}
catch (UrlProviderException _exception)
{
// throw new ActionException(_exception);
}
try
{
String _location = messageProvider.getMessage(_prefix + TOKEN_ICON_FOR_MENU, locale);
if (IS_NOT_EMPTY.test(_location))
{
action.setIconForMenu(urlProvider.getUrl(_location));
}
}
catch (UrlProviderException _exception)
{
// throw new ActionException(_exception);
}
action.setKeyboardShortcut(messageProvider.getMessage(_prefix + TOKEN_KEYBOARD_SHORTCUT, locale));
action.setLabelDescription(messageProvider.getMessage(_prefix + TOKEN_LABEL_DESCRIPTION, locale));
action.setLabelMessage(messageProvider.getMessage(_prefix + TOKEN_LABEL_MESSAGE, locale));
// done
return action;
}
|
[
"public",
"static",
"UserInterfaceAction",
"<",
"URL",
">",
"retrieveActionDefinitionFromMessageProvider",
"(",
"UserInterfaceAction",
"<",
"URL",
">",
"action",
",",
"MessageProviderInterface",
"messageProvider",
",",
"String",
"prefix",
",",
"Locale",
"locale",
",",
"Object",
"callbackProvider",
",",
"UrlProvider",
"urlProvider",
")",
"{",
"// sanity check",
"if",
"(",
"null",
"==",
"action",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"action must not be null\"",
")",
";",
"}",
"if",
"(",
"null",
"==",
"messageProvider",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"messageProvider must not be null\"",
")",
";",
"}",
"if",
"(",
"null",
"==",
"callbackProvider",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"callbackProvider must not be null\"",
")",
";",
"}",
"String",
"_prefix",
"=",
"(",
"null",
"!=",
"prefix",
")",
"?",
"prefix",
".",
"trim",
"(",
")",
"+",
"TOKEN_SEPARATOR",
":",
"TOKEN_SEPARATOR",
";",
"// ok, do the processing",
"try",
"{",
"action",
".",
"setCallback",
"(",
"FunctorFactory",
".",
"instanciateFunctorAsAnInstanceMethodWrapper",
"(",
"callbackProvider",
",",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_CALLBACK",
",",
"locale",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"_exception",
")",
"{",
"throw",
"new",
"ActionException",
"(",
"_exception",
")",
";",
"}",
"try",
"{",
"String",
"_location",
"=",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_ICON_FOR_BUTTON",
",",
"locale",
")",
";",
"if",
"(",
"IS_NOT_EMPTY",
".",
"test",
"(",
"_location",
")",
")",
"{",
"action",
".",
"setIconForButton",
"(",
"urlProvider",
".",
"getUrl",
"(",
"_location",
")",
")",
";",
"}",
"}",
"catch",
"(",
"UrlProviderException",
"_exception",
")",
"{",
"// throw new ActionException(_exception);",
"}",
"try",
"{",
"String",
"_location",
"=",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_ICON_FOR_MENU",
",",
"locale",
")",
";",
"if",
"(",
"IS_NOT_EMPTY",
".",
"test",
"(",
"_location",
")",
")",
"{",
"action",
".",
"setIconForMenu",
"(",
"urlProvider",
".",
"getUrl",
"(",
"_location",
")",
")",
";",
"}",
"}",
"catch",
"(",
"UrlProviderException",
"_exception",
")",
"{",
"// throw new ActionException(_exception);",
"}",
"action",
".",
"setKeyboardShortcut",
"(",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_KEYBOARD_SHORTCUT",
",",
"locale",
")",
")",
";",
"action",
".",
"setLabelDescription",
"(",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_LABEL_DESCRIPTION",
",",
"locale",
")",
")",
";",
"action",
".",
"setLabelMessage",
"(",
"messageProvider",
".",
"getMessage",
"(",
"_prefix",
"+",
"TOKEN_LABEL_MESSAGE",
",",
"locale",
")",
")",
";",
"// done",
"return",
"action",
";",
"}"
] |
Read the data of an UserInterfaceAction from a properties file.
The properties files should provide the following properties :
<ul>
<li>[prefix].callback</li>
<li>[prefix].iconForButton</li>
<li>[prefix].iconForMenu</li>
<li>[prefix].keyboardShrotcut</li>
<li>[prefix].labelDescription</li>
<li>[prefix].labelMessage</li>
</ul>
@param action
the action instance to configure, not null.
@param messageProvider
the message provider that retrieve the values.
@param prefix
the prefix.
@param locale
the locale.
@param callbackProvider
an instance that contains the method referenced as "callback".
@param urlProvider
the url provider.
@return the given action instance, configured with data extracted from the message provider.
|
[
"Read",
"the",
"data",
"of",
"an",
"UserInterfaceAction",
"from",
"a",
"properties",
"file",
"."
] |
3480ebd72a07422fcc09971be2607ee25efb2c26
|
https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-ui/src/main/java/com/sporniket/libre/ui/action/Utils.java#L87-L147
|
2,585 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.transformIcons
|
public final void transformIcons(final Element root) {
final Map<String, String> replacements; // Texts to replace and
// replacements
checkNotNull(root, "Received a null pointer as root element");
replacements = new HashMap<>();
replacements.put("img[src$=images/add.gif]",
"<span><span class=\"fa fa-plus\" aria-hidden=\"true\"></span><span class=\"sr-only\">Addition</span></span>");
replacements.put("img[src$=images/remove.gif]",
"<span><span class=\"fa fa-minus\" aria-hidden=\"true\"></span><span class=\"sr-only\">Remove</span></span>");
replacements.put("img[src$=images/fix.gif]",
"<span><span class=\"fa fa-wrench\" aria-hidden=\"true\"></span><span class=\"sr-only\">Fix</span></span>");
replacements.put("img[src$=images/update.gif]",
"<span><span class=\"fa fa-refresh\" aria-hidden=\"true\"></span><span class=\"sr-only\">Refresh</span></span>");
replacements.put("img[src$=images/icon_help_sml.gif]",
"<span><span class=\"fa fa-question\" aria-hidden=\"true\"></span><span class=\"sr-only\">Question</span></span>");
replacements.put("img[src$=images/icon_success_sml.gif]",
"<span><span class=\"navbar-icon fa fa-check\" aria-hidden=\"true\" title=\"Passed\" aria-label=\"Passed\"></span><span class=\"sr-only\">Passed</span></span>");
replacements.put("img[src$=images/icon_warning_sml.gif]",
"<span><span class=\"fa fa-exclamation\" aria-hidden=\"true\"></span><span class=\"sr-only\">Warning</span>");
replacements.put("img[src$=images/icon_error_sml.gif]",
"<span><span class=\"navbar-icon fa fa-close\" aria-hidden=\"true\" title=\"Failed\" aria-label=\"Failed\"></span><span class=\"sr-only\">Failed</span></span>");
replacements.put("img[src$=images/icon_info_sml.gif]",
"<span><span class=\"fa fa-info\" aria-hidden=\"true\"></span><span class=\"sr-only\">Info</span></span>");
replaceAll(root, replacements);
}
|
java
|
public final void transformIcons(final Element root) {
final Map<String, String> replacements; // Texts to replace and
// replacements
checkNotNull(root, "Received a null pointer as root element");
replacements = new HashMap<>();
replacements.put("img[src$=images/add.gif]",
"<span><span class=\"fa fa-plus\" aria-hidden=\"true\"></span><span class=\"sr-only\">Addition</span></span>");
replacements.put("img[src$=images/remove.gif]",
"<span><span class=\"fa fa-minus\" aria-hidden=\"true\"></span><span class=\"sr-only\">Remove</span></span>");
replacements.put("img[src$=images/fix.gif]",
"<span><span class=\"fa fa-wrench\" aria-hidden=\"true\"></span><span class=\"sr-only\">Fix</span></span>");
replacements.put("img[src$=images/update.gif]",
"<span><span class=\"fa fa-refresh\" aria-hidden=\"true\"></span><span class=\"sr-only\">Refresh</span></span>");
replacements.put("img[src$=images/icon_help_sml.gif]",
"<span><span class=\"fa fa-question\" aria-hidden=\"true\"></span><span class=\"sr-only\">Question</span></span>");
replacements.put("img[src$=images/icon_success_sml.gif]",
"<span><span class=\"navbar-icon fa fa-check\" aria-hidden=\"true\" title=\"Passed\" aria-label=\"Passed\"></span><span class=\"sr-only\">Passed</span></span>");
replacements.put("img[src$=images/icon_warning_sml.gif]",
"<span><span class=\"fa fa-exclamation\" aria-hidden=\"true\"></span><span class=\"sr-only\">Warning</span>");
replacements.put("img[src$=images/icon_error_sml.gif]",
"<span><span class=\"navbar-icon fa fa-close\" aria-hidden=\"true\" title=\"Failed\" aria-label=\"Failed\"></span><span class=\"sr-only\">Failed</span></span>");
replacements.put("img[src$=images/icon_info_sml.gif]",
"<span><span class=\"fa fa-info\" aria-hidden=\"true\"></span><span class=\"sr-only\">Info</span></span>");
replaceAll(root, replacements);
}
|
[
"public",
"final",
"void",
"transformIcons",
"(",
"final",
"Element",
"root",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"replacements",
";",
"// Texts to replace and",
"// replacements",
"checkNotNull",
"(",
"root",
",",
"\"Received a null pointer as root element\"",
")",
";",
"replacements",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/add.gif]\"",
",",
"\"<span><span class=\\\"fa fa-plus\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Addition</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/remove.gif]\"",
",",
"\"<span><span class=\\\"fa fa-minus\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Remove</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/fix.gif]\"",
",",
"\"<span><span class=\\\"fa fa-wrench\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Fix</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/update.gif]\"",
",",
"\"<span><span class=\\\"fa fa-refresh\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Refresh</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/icon_help_sml.gif]\"",
",",
"\"<span><span class=\\\"fa fa-question\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Question</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/icon_success_sml.gif]\"",
",",
"\"<span><span class=\\\"navbar-icon fa fa-check\\\" aria-hidden=\\\"true\\\" title=\\\"Passed\\\" aria-label=\\\"Passed\\\"></span><span class=\\\"sr-only\\\">Passed</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/icon_warning_sml.gif]\"",
",",
"\"<span><span class=\\\"fa fa-exclamation\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Warning</span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/icon_error_sml.gif]\"",
",",
"\"<span><span class=\\\"navbar-icon fa fa-close\\\" aria-hidden=\\\"true\\\" title=\\\"Failed\\\" aria-label=\\\"Failed\\\"></span><span class=\\\"sr-only\\\">Failed</span></span>\"",
")",
";",
"replacements",
".",
"put",
"(",
"\"img[src$=images/icon_info_sml.gif]\"",
",",
"\"<span><span class=\\\"fa fa-info\\\" aria-hidden=\\\"true\\\"></span><span class=\\\"sr-only\\\">Info</span></span>\"",
")",
";",
"replaceAll",
"(",
"root",
",",
"replacements",
")",
";",
"}"
] |
Transforms the default icons used by the Maven Site to Font Awesome
icons.
@param root
root element with the page
|
[
"Transforms",
"the",
"default",
"icons",
"used",
"by",
"the",
"Maven",
"Site",
"to",
"Font",
"Awesome",
"icons",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L252-L279
|
2,586 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportCheckstyle
|
private final void fixReportCheckstyle(final Element root) {
final Collection<Element> elements; // Found elements
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
elements.iterator().next().tagName("h1");
}
root.select("img[src=\"images/rss.png\"]").remove();
}
|
java
|
private final void fixReportCheckstyle(final Element root) {
final Collection<Element> elements; // Found elements
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
elements.iterator().next().tagName("h1");
}
root.select("img[src=\"images/rss.png\"]").remove();
}
|
[
"private",
"final",
"void",
"fixReportCheckstyle",
"(",
"final",
"Element",
"root",
")",
"{",
"final",
"Collection",
"<",
"Element",
">",
"elements",
";",
"// Found elements",
"elements",
"=",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
";",
"if",
"(",
"!",
"elements",
".",
"isEmpty",
"(",
")",
")",
"{",
"elements",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"root",
".",
"select",
"(",
"\"img[src=\\\"images/rss.png\\\"]\"",
")",
".",
"remove",
"(",
")",
";",
"}"
] |
Fixes the Checkstyle report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"Checkstyle",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L408-L416
|
2,587 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportCpd
|
private final void fixReportCpd(final Element root) {
final Collection<Element> elements; // Found elements
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
elements.iterator().next().tagName("h1");
}
}
|
java
|
private final void fixReportCpd(final Element root) {
final Collection<Element> elements; // Found elements
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
elements.iterator().next().tagName("h1");
}
}
|
[
"private",
"final",
"void",
"fixReportCpd",
"(",
"final",
"Element",
"root",
")",
"{",
"final",
"Collection",
"<",
"Element",
">",
"elements",
";",
"// Found elements",
"elements",
"=",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
";",
"if",
"(",
"!",
"elements",
".",
"isEmpty",
"(",
")",
")",
"{",
"elements",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"}"
] |
Fixes the CPD report page.
@param root
element for the body of the report page
|
[
"Fixes",
"the",
"CPD",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L424-L431
|
2,588 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportDependencyAnalysis
|
private final void fixReportDependencyAnalysis(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
java
|
private final void fixReportDependencyAnalysis(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
[
"private",
"final",
"void",
"fixReportDependencyAnalysis",
"(",
"final",
"Element",
"root",
")",
"{",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h3\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h2\"",
")",
";",
"}",
"}"
] |
Fixes the dependency analysis report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"dependency",
"analysis",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L449-L457
|
2,589 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportFailsafe
|
private final void fixReportFailsafe(final Element root) {
final Collection<Element> elements; // Found elements
final Element heading; // First h2 heading
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
heading = elements.iterator().next();
heading.tagName("h1");
heading.text("Failsafe Report");
}
}
|
java
|
private final void fixReportFailsafe(final Element root) {
final Collection<Element> elements; // Found elements
final Element heading; // First h2 heading
elements = root.getElementsByTag("h2");
if (!elements.isEmpty()) {
heading = elements.iterator().next();
heading.tagName("h1");
heading.text("Failsafe Report");
}
}
|
[
"private",
"final",
"void",
"fixReportFailsafe",
"(",
"final",
"Element",
"root",
")",
"{",
"final",
"Collection",
"<",
"Element",
">",
"elements",
";",
"// Found elements",
"final",
"Element",
"heading",
";",
"// First h2 heading",
"elements",
"=",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
";",
"if",
"(",
"!",
"elements",
".",
"isEmpty",
"(",
")",
")",
"{",
"heading",
"=",
"elements",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"heading",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"heading",
".",
"text",
"(",
"\"Failsafe Report\"",
")",
";",
"}",
"}"
] |
Fixes the Failsafe report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"Failsafe",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L465-L475
|
2,590 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportPluginManagement
|
private final void fixReportPluginManagement(final Element root) {
final Collection<Element> sections; // Sections in the body
final Element section; // Section element
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
sections = root.getElementsByTag("section");
if (!sections.isEmpty()) {
section = sections.iterator().next();
for (final Element child : section.children()) {
child.remove();
root.appendChild(child);
}
section.remove();
}
}
|
java
|
private final void fixReportPluginManagement(final Element root) {
final Collection<Element> sections; // Sections in the body
final Element section; // Section element
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
sections = root.getElementsByTag("section");
if (!sections.isEmpty()) {
section = sections.iterator().next();
for (final Element child : section.children()) {
child.remove();
root.appendChild(child);
}
section.remove();
}
}
|
[
"private",
"final",
"void",
"fixReportPluginManagement",
"(",
"final",
"Element",
"root",
")",
"{",
"final",
"Collection",
"<",
"Element",
">",
"sections",
";",
"// Sections in the body",
"final",
"Element",
"section",
";",
"// Section element",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"sections",
"=",
"root",
".",
"getElementsByTag",
"(",
"\"section\"",
")",
";",
"if",
"(",
"!",
"sections",
".",
"isEmpty",
"(",
")",
")",
"{",
"section",
"=",
"sections",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"for",
"(",
"final",
"Element",
"child",
":",
"section",
".",
"children",
"(",
")",
")",
"{",
"child",
".",
"remove",
"(",
")",
";",
"root",
".",
"appendChild",
"(",
"child",
")",
";",
"}",
"section",
".",
"remove",
"(",
")",
";",
"}",
"}"
] |
Fixes the plugin management report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"plugin",
"management",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L523-L542
|
2,591 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportProjectSummary
|
private final void fixReportProjectSummary(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
java
|
private final void fixReportProjectSummary(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
[
"private",
"final",
"void",
"fixReportProjectSummary",
"(",
"final",
"Element",
"root",
")",
"{",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h3\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h2\"",
")",
";",
"}",
"}"
] |
Fixes the project summary report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"project",
"summary",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L575-L583
|
2,592 |
Bernardo-MG/maven-site-fixer
|
src/main/java/com/bernardomg/velocity/tool/SiteTool.java
|
SiteTool.fixReportTeamList
|
private final void fixReportTeamList(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
java
|
private final void fixReportTeamList(final Element root) {
for (final Element head : root.getElementsByTag("h2")) {
head.tagName("h1");
}
for (final Element head : root.getElementsByTag("h3")) {
head.tagName("h2");
}
}
|
[
"private",
"final",
"void",
"fixReportTeamList",
"(",
"final",
"Element",
"root",
")",
"{",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h2\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h1\"",
")",
";",
"}",
"for",
"(",
"final",
"Element",
"head",
":",
"root",
".",
"getElementsByTag",
"(",
"\"h3\"",
")",
")",
"{",
"head",
".",
"tagName",
"(",
"\"h2\"",
")",
";",
"}",
"}"
] |
Fixes the team list report page.
@param root
root element for the report page to fix
|
[
"Fixes",
"the",
"team",
"list",
"report",
"page",
"."
] |
e064472faa7edb0fca11647a22d90ad72089baa3
|
https://github.com/Bernardo-MG/maven-site-fixer/blob/e064472faa7edb0fca11647a22d90ad72089baa3/src/main/java/com/bernardomg/velocity/tool/SiteTool.java#L621-L629
|
2,593 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/bin/BigFileSearcher.java
|
BigFileSearcher.onProgress
|
private void onProgress(final int workerNumber, final int workerSize, final List<Long> pointerList, final float progress) {
if (progressCache == null) {
progressCache = new ProgressCache(workerSize, (onRealtimeResultListener != null));
}
progressCache.setProgress(workerNumber, progress, pointerList);
if (onProgressListener != null) {
onProgressListener.onProgress(progressCache.getProgress());
}
if (onRealtimeResultListener != null) {
onRealtimeResultListener.onRealtimeResultListener(progressCache.getProgress(), progressCache.getResultPointers());
}
}
|
java
|
private void onProgress(final int workerNumber, final int workerSize, final List<Long> pointerList, final float progress) {
if (progressCache == null) {
progressCache = new ProgressCache(workerSize, (onRealtimeResultListener != null));
}
progressCache.setProgress(workerNumber, progress, pointerList);
if (onProgressListener != null) {
onProgressListener.onProgress(progressCache.getProgress());
}
if (onRealtimeResultListener != null) {
onRealtimeResultListener.onRealtimeResultListener(progressCache.getProgress(), progressCache.getResultPointers());
}
}
|
[
"private",
"void",
"onProgress",
"(",
"final",
"int",
"workerNumber",
",",
"final",
"int",
"workerSize",
",",
"final",
"List",
"<",
"Long",
">",
"pointerList",
",",
"final",
"float",
"progress",
")",
"{",
"if",
"(",
"progressCache",
"==",
"null",
")",
"{",
"progressCache",
"=",
"new",
"ProgressCache",
"(",
"workerSize",
",",
"(",
"onRealtimeResultListener",
"!=",
"null",
")",
")",
";",
"}",
"progressCache",
".",
"setProgress",
"(",
"workerNumber",
",",
"progress",
",",
"pointerList",
")",
";",
"if",
"(",
"onProgressListener",
"!=",
"null",
")",
"{",
"onProgressListener",
".",
"onProgress",
"(",
"progressCache",
".",
"getProgress",
"(",
")",
")",
";",
"}",
"if",
"(",
"onRealtimeResultListener",
"!=",
"null",
")",
"{",
"onRealtimeResultListener",
".",
"onRealtimeResultListener",
"(",
"progressCache",
".",
"getProgress",
"(",
")",
",",
"progressCache",
".",
"getResultPointers",
"(",
")",
")",
";",
"}",
"}"
] |
Call from each worker thread
|
[
"Call",
"from",
"each",
"worker",
"thread"
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/bin/BigFileSearcher.java#L517-L532
|
2,594 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/bin/BigFileSearcher.java
|
BigFileSearcher.optimize
|
private void optimize(long fileLength) {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final long free = Runtime.getRuntime().freeMemory() / 2;
int workerSize = availableProcessors / 2;
if (workerSize < 2) {
workerSize = 2;
}
long bufferSize = free / workerSize;
if (bufferSize > 1 * 1024 * 1024) {
bufferSize = 1 * 1024 * 1024;
}
long blockSize = fileLength / workerSize;
if (blockSize > 1 * 1024 * 1024) {
blockSize = 1 * 1024 * 1024;
}
int iBlockSize = (int) blockSize;
if (bufferSize > blockSize) {
bufferSize = blockSize;
}
int iBufferSize = (int) bufferSize;
this.setBlockSize(iBlockSize);
this.setMaxNumOfThreads(workerSize);
this.setBufferSizePerWorker(iBufferSize);
this.setSubBufferSize(256);
}
|
java
|
private void optimize(long fileLength) {
final int availableProcessors = Runtime.getRuntime().availableProcessors();
final long free = Runtime.getRuntime().freeMemory() / 2;
int workerSize = availableProcessors / 2;
if (workerSize < 2) {
workerSize = 2;
}
long bufferSize = free / workerSize;
if (bufferSize > 1 * 1024 * 1024) {
bufferSize = 1 * 1024 * 1024;
}
long blockSize = fileLength / workerSize;
if (blockSize > 1 * 1024 * 1024) {
blockSize = 1 * 1024 * 1024;
}
int iBlockSize = (int) blockSize;
if (bufferSize > blockSize) {
bufferSize = blockSize;
}
int iBufferSize = (int) bufferSize;
this.setBlockSize(iBlockSize);
this.setMaxNumOfThreads(workerSize);
this.setBufferSizePerWorker(iBufferSize);
this.setSubBufferSize(256);
}
|
[
"private",
"void",
"optimize",
"(",
"long",
"fileLength",
")",
"{",
"final",
"int",
"availableProcessors",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
";",
"final",
"long",
"free",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"freeMemory",
"(",
")",
"/",
"2",
";",
"int",
"workerSize",
"=",
"availableProcessors",
"/",
"2",
";",
"if",
"(",
"workerSize",
"<",
"2",
")",
"{",
"workerSize",
"=",
"2",
";",
"}",
"long",
"bufferSize",
"=",
"free",
"/",
"workerSize",
";",
"if",
"(",
"bufferSize",
">",
"1",
"*",
"1024",
"*",
"1024",
")",
"{",
"bufferSize",
"=",
"1",
"*",
"1024",
"*",
"1024",
";",
"}",
"long",
"blockSize",
"=",
"fileLength",
"/",
"workerSize",
";",
"if",
"(",
"blockSize",
">",
"1",
"*",
"1024",
"*",
"1024",
")",
"{",
"blockSize",
"=",
"1",
"*",
"1024",
"*",
"1024",
";",
"}",
"int",
"iBlockSize",
"=",
"(",
"int",
")",
"blockSize",
";",
"if",
"(",
"bufferSize",
">",
"blockSize",
")",
"{",
"bufferSize",
"=",
"blockSize",
";",
"}",
"int",
"iBufferSize",
"=",
"(",
"int",
")",
"bufferSize",
";",
"this",
".",
"setBlockSize",
"(",
"iBlockSize",
")",
";",
"this",
".",
"setMaxNumOfThreads",
"(",
"workerSize",
")",
";",
"this",
".",
"setBufferSizePerWorker",
"(",
"iBufferSize",
")",
";",
"this",
".",
"setSubBufferSize",
"(",
"256",
")",
";",
"}"
] |
Optimize threading and memory
@param fileLength
|
[
"Optimize",
"threading",
"and",
"memory"
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/bin/BigFileSearcher.java#L567-L599
|
2,595 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/xml/BigXmlReader.java
|
BigXmlReader.read
|
public void read(InputStream is, String encoding, final TagListener listener) {
mSaxHandler.initialize();
Reader reader = null;
try {
reader = new InputStreamReader(is, encoding);
SAXParserFactory spf = SAXParserFactory.newInstance();
// To correspond to a big entities
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
XMLReader xmlReader;
xmlReader = spf.newSAXParser().getXMLReader();
mSaxHandler.setTagEventListener(new TagEventListener() {
@Override
public void onTagStarted(String fullTagName, String tagName) {
if (listener != null) {
listener.onTagStarted(BigXmlReader.this, fullTagName, tagName);
}
}
@Override
public void onTagFinished(String fullTagName, String tagName, String value, Attributes atts) {
if (listener != null) {
listener.onTagFinished(BigXmlReader.this, fullTagName, tagName, value, atts);
}
}
});
xmlReader.setContentHandler(mSaxHandler);
InputSource iso = new InputSource(reader);
xmlReader.parse(iso);
} catch (BasicSAXHandlerException e) {
// Force stopped
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
|
java
|
public void read(InputStream is, String encoding, final TagListener listener) {
mSaxHandler.initialize();
Reader reader = null;
try {
reader = new InputStreamReader(is, encoding);
SAXParserFactory spf = SAXParserFactory.newInstance();
// To correspond to a big entities
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
XMLReader xmlReader;
xmlReader = spf.newSAXParser().getXMLReader();
mSaxHandler.setTagEventListener(new TagEventListener() {
@Override
public void onTagStarted(String fullTagName, String tagName) {
if (listener != null) {
listener.onTagStarted(BigXmlReader.this, fullTagName, tagName);
}
}
@Override
public void onTagFinished(String fullTagName, String tagName, String value, Attributes atts) {
if (listener != null) {
listener.onTagFinished(BigXmlReader.this, fullTagName, tagName, value, atts);
}
}
});
xmlReader.setContentHandler(mSaxHandler);
InputSource iso = new InputSource(reader);
xmlReader.parse(iso);
} catch (BasicSAXHandlerException e) {
// Force stopped
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
|
[
"public",
"void",
"read",
"(",
"InputStream",
"is",
",",
"String",
"encoding",
",",
"final",
"TagListener",
"listener",
")",
"{",
"mSaxHandler",
".",
"initialize",
"(",
")",
";",
"Reader",
"reader",
"=",
"null",
";",
"try",
"{",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"is",
",",
"encoding",
")",
";",
"SAXParserFactory",
"spf",
"=",
"SAXParserFactory",
".",
"newInstance",
"(",
")",
";",
"// To correspond to a big entities",
"spf",
".",
"setFeature",
"(",
"XMLConstants",
".",
"FEATURE_SECURE_PROCESSING",
",",
"false",
")",
";",
"XMLReader",
"xmlReader",
";",
"xmlReader",
"=",
"spf",
".",
"newSAXParser",
"(",
")",
".",
"getXMLReader",
"(",
")",
";",
"mSaxHandler",
".",
"setTagEventListener",
"(",
"new",
"TagEventListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onTagStarted",
"(",
"String",
"fullTagName",
",",
"String",
"tagName",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"listener",
".",
"onTagStarted",
"(",
"BigXmlReader",
".",
"this",
",",
"fullTagName",
",",
"tagName",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onTagFinished",
"(",
"String",
"fullTagName",
",",
"String",
"tagName",
",",
"String",
"value",
",",
"Attributes",
"atts",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"listener",
".",
"onTagFinished",
"(",
"BigXmlReader",
".",
"this",
",",
"fullTagName",
",",
"tagName",
",",
"value",
",",
"atts",
")",
";",
"}",
"}",
"}",
")",
";",
"xmlReader",
".",
"setContentHandler",
"(",
"mSaxHandler",
")",
";",
"InputSource",
"iso",
"=",
"new",
"InputSource",
"(",
"reader",
")",
";",
"xmlReader",
".",
"parse",
"(",
"iso",
")",
";",
"}",
"catch",
"(",
"BasicSAXHandlerException",
"e",
")",
"{",
"// Force stopped",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Read big XML file from specific stream
@param is
stream of xml like fileinputstream
@param encoding
@param listener
listener callbacks when each xml element starts and ends
|
[
"Read",
"big",
"XML",
"file",
"from",
"specific",
"stream"
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/xml/BigXmlReader.java#L94-L145
|
2,596 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/xml/BasicSAXHandler.java
|
BasicSAXHandler.initialize
|
public void initialize() {
mIsForceStop = false;
mTagStack.clear();
mTagValueCache.clear();
mTagAttrCache.clear();
mCurrentTagKey = null;
}
|
java
|
public void initialize() {
mIsForceStop = false;
mTagStack.clear();
mTagValueCache.clear();
mTagAttrCache.clear();
mCurrentTagKey = null;
}
|
[
"public",
"void",
"initialize",
"(",
")",
"{",
"mIsForceStop",
"=",
"false",
";",
"mTagStack",
".",
"clear",
"(",
")",
";",
"mTagValueCache",
".",
"clear",
"(",
")",
";",
"mTagAttrCache",
".",
"clear",
"(",
")",
";",
"mCurrentTagKey",
"=",
"null",
";",
"}"
] |
Initialize internal variables
|
[
"Initialize",
"internal",
"variables"
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/xml/BasicSAXHandler.java#L75-L81
|
2,597 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/xml/BasicSAXHandler.java
|
BasicSAXHandler.pushTag
|
private void pushTag(String qName) {
final String currentTag = getCurrentTag();
if ("".equals(currentTag)) {
mTagStack.push(qName);
} else {
mTagStack.push(getCurrentTag() + "." + qName);
}
}
|
java
|
private void pushTag(String qName) {
final String currentTag = getCurrentTag();
if ("".equals(currentTag)) {
mTagStack.push(qName);
} else {
mTagStack.push(getCurrentTag() + "." + qName);
}
}
|
[
"private",
"void",
"pushTag",
"(",
"String",
"qName",
")",
"{",
"final",
"String",
"currentTag",
"=",
"getCurrentTag",
"(",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"currentTag",
")",
")",
"{",
"mTagStack",
".",
"push",
"(",
"qName",
")",
";",
"}",
"else",
"{",
"mTagStack",
".",
"push",
"(",
"getCurrentTag",
"(",
")",
"+",
"\".\"",
"+",
"qName",
")",
";",
"}",
"}"
] |
Make current scanning full tag name like "root.element.child"
@param qName
|
[
"Make",
"current",
"scanning",
"full",
"tag",
"name",
"like",
"root",
".",
"element",
".",
"child"
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/xml/BasicSAXHandler.java#L167-L174
|
2,598 |
riversun/bigdoc
|
src/main/java/org/riversun/bigdoc/bin/BinFileSearcher.java
|
BinFileSearcher.searchPartially
|
public List<Long> searchPartially(File f, byte[] searchBytes, long startPosition, long maxSizeToRead) {
if (USE_NIO) {
return searchPartiallyUsingNIO(f, searchBytes, startPosition, maxSizeToRead, null);
} else {
return searchPartiallyUsingLegacy(f, searchBytes, startPosition, maxSizeToRead, null);
}
}
|
java
|
public List<Long> searchPartially(File f, byte[] searchBytes, long startPosition, long maxSizeToRead) {
if (USE_NIO) {
return searchPartiallyUsingNIO(f, searchBytes, startPosition, maxSizeToRead, null);
} else {
return searchPartiallyUsingLegacy(f, searchBytes, startPosition, maxSizeToRead, null);
}
}
|
[
"public",
"List",
"<",
"Long",
">",
"searchPartially",
"(",
"File",
"f",
",",
"byte",
"[",
"]",
"searchBytes",
",",
"long",
"startPosition",
",",
"long",
"maxSizeToRead",
")",
"{",
"if",
"(",
"USE_NIO",
")",
"{",
"return",
"searchPartiallyUsingNIO",
"(",
"f",
",",
"searchBytes",
",",
"startPosition",
",",
"maxSizeToRead",
",",
"null",
")",
";",
"}",
"else",
"{",
"return",
"searchPartiallyUsingLegacy",
"(",
"f",
",",
"searchBytes",
",",
"startPosition",
",",
"maxSizeToRead",
",",
"null",
")",
";",
"}",
"}"
] |
Search for a sequence of bytes from the file within the specified size
range starting at the specified position .
@param f
@param searchBytes
a sequence of bytes you want to find
@param startPosition
'0' means the beginning of the file
@param maxSizeToRead
max size to read.'-1' means read until the end.
@return
|
[
"Search",
"for",
"a",
"sequence",
"of",
"bytes",
"from",
"the",
"file",
"within",
"the",
"specified",
"size",
"range",
"starting",
"at",
"the",
"specified",
"position",
"."
] |
46bd7c9a8667be23acdb1ad8286027e4b08cff3a
|
https://github.com/riversun/bigdoc/blob/46bd7c9a8667be23acdb1ad8286027e4b08cff3a/src/main/java/org/riversun/bigdoc/bin/BinFileSearcher.java#L220-L226
|
2,599 |
windy1/google-places-api-java
|
src/main/java/se/walkercrou/places/Prediction.java
|
Prediction.parse
|
public static List<Prediction> parse(GooglePlaces client, String rawJson) {
JSONObject json = new JSONObject(rawJson);
checkStatus(json.getString(STRING_STATUS), json.optString(STRING_ERROR_MESSAGE));
List<Prediction> predictions = new ArrayList<>();
JSONArray jsonPredictions = json.getJSONArray(ARRAY_PREDICTIONS);
for (int i = 0; i < jsonPredictions.length(); i++) {
JSONObject jsonPrediction = jsonPredictions.getJSONObject(i);
String placeId = jsonPrediction.getString(STRING_PLACE_ID);
String description = jsonPrediction.getString(STRING_DESCRIPTION);
JSONArray jsonTerms = jsonPrediction.getJSONArray(ARRAY_TERMS);
List<DescriptionTerm> terms = new ArrayList<>();
for (int a = 0; a < jsonTerms.length(); a++) {
JSONObject jsonTerm = jsonTerms.getJSONObject(a);
String value = jsonTerm.getString(STRING_VALUE);
int offset = jsonTerm.getInt(INTEGER_OFFSET);
terms.add(new DescriptionTerm(value, offset));
}
JSONArray jsonTypes = jsonPrediction.optJSONArray(ARRAY_TYPES);
List<String> types = new ArrayList<>();
if (jsonTypes != null) {
for (int b = 0; b < jsonTypes.length(); b++) {
types.add(jsonTypes.getString(b));
}
}
JSONArray substrArray = jsonPrediction.getJSONArray(ARRAY_MATCHED_SUBSTRINGS);
JSONObject substr = substrArray.getJSONObject(0);
int substrOffset = substr.getInt(INTEGER_OFFSET);
int substrLength = substr.getInt(INTEGER_LENGTH);
predictions.add(new Prediction().setPlaceId(placeId).setDescription(description).addTerms(terms).addTypes(types)
.setSubstringLength(substrLength).setSubstringOffset(substrOffset).setClient(client));
}
return predictions;
}
|
java
|
public static List<Prediction> parse(GooglePlaces client, String rawJson) {
JSONObject json = new JSONObject(rawJson);
checkStatus(json.getString(STRING_STATUS), json.optString(STRING_ERROR_MESSAGE));
List<Prediction> predictions = new ArrayList<>();
JSONArray jsonPredictions = json.getJSONArray(ARRAY_PREDICTIONS);
for (int i = 0; i < jsonPredictions.length(); i++) {
JSONObject jsonPrediction = jsonPredictions.getJSONObject(i);
String placeId = jsonPrediction.getString(STRING_PLACE_ID);
String description = jsonPrediction.getString(STRING_DESCRIPTION);
JSONArray jsonTerms = jsonPrediction.getJSONArray(ARRAY_TERMS);
List<DescriptionTerm> terms = new ArrayList<>();
for (int a = 0; a < jsonTerms.length(); a++) {
JSONObject jsonTerm = jsonTerms.getJSONObject(a);
String value = jsonTerm.getString(STRING_VALUE);
int offset = jsonTerm.getInt(INTEGER_OFFSET);
terms.add(new DescriptionTerm(value, offset));
}
JSONArray jsonTypes = jsonPrediction.optJSONArray(ARRAY_TYPES);
List<String> types = new ArrayList<>();
if (jsonTypes != null) {
for (int b = 0; b < jsonTypes.length(); b++) {
types.add(jsonTypes.getString(b));
}
}
JSONArray substrArray = jsonPrediction.getJSONArray(ARRAY_MATCHED_SUBSTRINGS);
JSONObject substr = substrArray.getJSONObject(0);
int substrOffset = substr.getInt(INTEGER_OFFSET);
int substrLength = substr.getInt(INTEGER_LENGTH);
predictions.add(new Prediction().setPlaceId(placeId).setDescription(description).addTerms(terms).addTypes(types)
.setSubstringLength(substrLength).setSubstringOffset(substrOffset).setClient(client));
}
return predictions;
}
|
[
"public",
"static",
"List",
"<",
"Prediction",
">",
"parse",
"(",
"GooglePlaces",
"client",
",",
"String",
"rawJson",
")",
"{",
"JSONObject",
"json",
"=",
"new",
"JSONObject",
"(",
"rawJson",
")",
";",
"checkStatus",
"(",
"json",
".",
"getString",
"(",
"STRING_STATUS",
")",
",",
"json",
".",
"optString",
"(",
"STRING_ERROR_MESSAGE",
")",
")",
";",
"List",
"<",
"Prediction",
">",
"predictions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"JSONArray",
"jsonPredictions",
"=",
"json",
".",
"getJSONArray",
"(",
"ARRAY_PREDICTIONS",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jsonPredictions",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"JSONObject",
"jsonPrediction",
"=",
"jsonPredictions",
".",
"getJSONObject",
"(",
"i",
")",
";",
"String",
"placeId",
"=",
"jsonPrediction",
".",
"getString",
"(",
"STRING_PLACE_ID",
")",
";",
"String",
"description",
"=",
"jsonPrediction",
".",
"getString",
"(",
"STRING_DESCRIPTION",
")",
";",
"JSONArray",
"jsonTerms",
"=",
"jsonPrediction",
".",
"getJSONArray",
"(",
"ARRAY_TERMS",
")",
";",
"List",
"<",
"DescriptionTerm",
">",
"terms",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"a",
"=",
"0",
";",
"a",
"<",
"jsonTerms",
".",
"length",
"(",
")",
";",
"a",
"++",
")",
"{",
"JSONObject",
"jsonTerm",
"=",
"jsonTerms",
".",
"getJSONObject",
"(",
"a",
")",
";",
"String",
"value",
"=",
"jsonTerm",
".",
"getString",
"(",
"STRING_VALUE",
")",
";",
"int",
"offset",
"=",
"jsonTerm",
".",
"getInt",
"(",
"INTEGER_OFFSET",
")",
";",
"terms",
".",
"add",
"(",
"new",
"DescriptionTerm",
"(",
"value",
",",
"offset",
")",
")",
";",
"}",
"JSONArray",
"jsonTypes",
"=",
"jsonPrediction",
".",
"optJSONArray",
"(",
"ARRAY_TYPES",
")",
";",
"List",
"<",
"String",
">",
"types",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"jsonTypes",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"b",
"=",
"0",
";",
"b",
"<",
"jsonTypes",
".",
"length",
"(",
")",
";",
"b",
"++",
")",
"{",
"types",
".",
"add",
"(",
"jsonTypes",
".",
"getString",
"(",
"b",
")",
")",
";",
"}",
"}",
"JSONArray",
"substrArray",
"=",
"jsonPrediction",
".",
"getJSONArray",
"(",
"ARRAY_MATCHED_SUBSTRINGS",
")",
";",
"JSONObject",
"substr",
"=",
"substrArray",
".",
"getJSONObject",
"(",
"0",
")",
";",
"int",
"substrOffset",
"=",
"substr",
".",
"getInt",
"(",
"INTEGER_OFFSET",
")",
";",
"int",
"substrLength",
"=",
"substr",
".",
"getInt",
"(",
"INTEGER_LENGTH",
")",
";",
"predictions",
".",
"add",
"(",
"new",
"Prediction",
"(",
")",
".",
"setPlaceId",
"(",
"placeId",
")",
".",
"setDescription",
"(",
"description",
")",
".",
"addTerms",
"(",
"terms",
")",
".",
"addTypes",
"(",
"types",
")",
".",
"setSubstringLength",
"(",
"substrLength",
")",
".",
"setSubstringOffset",
"(",
"substrOffset",
")",
".",
"setClient",
"(",
"client",
")",
")",
";",
"}",
"return",
"predictions",
";",
"}"
] |
Returns a list of predictions from JSON.
@param client of request
@param rawJson to parse
@return list of predictions
|
[
"Returns",
"a",
"list",
"of",
"predictions",
"from",
"JSON",
"."
] |
a5f2a18a7d1ca03fc0480637eae255fe92fc8b86
|
https://github.com/windy1/google-places-api-java/blob/a5f2a18a7d1ca03fc0480637eae255fe92fc8b86/src/main/java/se/walkercrou/places/Prediction.java#L34-L72
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.