repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/Integrator.java | Integrator.checkPlugin | private boolean checkPlugin(final String currentPlugin) {
final Features pluginFeatures = pluginTable.get(currentPlugin);
final Iterator<PluginRequirement> iter = pluginFeatures.getRequireListIter();
// check whether dependcy is satisfied
while (iter.hasNext()) {
boolean anyPluginFound = false;
final PluginRequirement requirement = iter.next();
final Iterator<String> requiredPluginIter = requirement.getPlugins();
while (requiredPluginIter.hasNext()) {
// Iterate over all alternatives in plugin requirement.
final String requiredPlugin = requiredPluginIter.next();
if (pluginTable.containsKey(requiredPlugin)) {
if (!loadedPlugin.contains(requiredPlugin)) {
// required plug-in is not loaded
loadPlugin(requiredPlugin);
}
// As soon as any plugin is found, it's OK.
anyPluginFound = true;
}
}
if (!anyPluginFound && requirement.getRequired()) {
// not contain any plugin required by current plugin
final String msg = MessageUtils.getMessage("DOTJ020W", requirement.toString(), currentPlugin).toString();
throw new RuntimeException(msg);
}
}
return true;
} | java | private boolean checkPlugin(final String currentPlugin) {
final Features pluginFeatures = pluginTable.get(currentPlugin);
final Iterator<PluginRequirement> iter = pluginFeatures.getRequireListIter();
// check whether dependcy is satisfied
while (iter.hasNext()) {
boolean anyPluginFound = false;
final PluginRequirement requirement = iter.next();
final Iterator<String> requiredPluginIter = requirement.getPlugins();
while (requiredPluginIter.hasNext()) {
// Iterate over all alternatives in plugin requirement.
final String requiredPlugin = requiredPluginIter.next();
if (pluginTable.containsKey(requiredPlugin)) {
if (!loadedPlugin.contains(requiredPlugin)) {
// required plug-in is not loaded
loadPlugin(requiredPlugin);
}
// As soon as any plugin is found, it's OK.
anyPluginFound = true;
}
}
if (!anyPluginFound && requirement.getRequired()) {
// not contain any plugin required by current plugin
final String msg = MessageUtils.getMessage("DOTJ020W", requirement.toString(), currentPlugin).toString();
throw new RuntimeException(msg);
}
}
return true;
} | [
"private",
"boolean",
"checkPlugin",
"(",
"final",
"String",
"currentPlugin",
")",
"{",
"final",
"Features",
"pluginFeatures",
"=",
"pluginTable",
".",
"get",
"(",
"currentPlugin",
")",
";",
"final",
"Iterator",
"<",
"PluginRequirement",
">",
"iter",
"=",
"plugi... | Check whether the plugin can be loaded.
@param currentPlugin plugin ID
@return {@code true} if plugin can be loaded, otherwise {@code false} | [
"Check",
"whether",
"the",
"plugin",
"can",
"be",
"loaded",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L742-L769 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/Integrator.java | Integrator.mergePlugins | private void mergePlugins() {
final Element root = pluginsDoc.createElement(ELEM_PLUGINS);
pluginsDoc.appendChild(root);
if (!descSet.isEmpty()) {
final URI b = new File(ditaDir, CONFIG_DIR + File.separator + "plugins.xml").toURI();
for (final File descFile : descSet) {
logger.debug("Read plug-in configuration " + descFile.getPath());
final Element plugin = parseDesc(descFile);
if (plugin != null) {
final URI base = getRelativePath(b, descFile.toURI());
plugin.setAttributeNS(XML_NS_URI, XML_NS_PREFIX + ":base", base.toString());
root.appendChild(pluginsDoc.importNode(plugin, true));
}
}
}
} | java | private void mergePlugins() {
final Element root = pluginsDoc.createElement(ELEM_PLUGINS);
pluginsDoc.appendChild(root);
if (!descSet.isEmpty()) {
final URI b = new File(ditaDir, CONFIG_DIR + File.separator + "plugins.xml").toURI();
for (final File descFile : descSet) {
logger.debug("Read plug-in configuration " + descFile.getPath());
final Element plugin = parseDesc(descFile);
if (plugin != null) {
final URI base = getRelativePath(b, descFile.toURI());
plugin.setAttributeNS(XML_NS_URI, XML_NS_PREFIX + ":base", base.toString());
root.appendChild(pluginsDoc.importNode(plugin, true));
}
}
}
} | [
"private",
"void",
"mergePlugins",
"(",
")",
"{",
"final",
"Element",
"root",
"=",
"pluginsDoc",
".",
"createElement",
"(",
"ELEM_PLUGINS",
")",
";",
"pluginsDoc",
".",
"appendChild",
"(",
"root",
")",
";",
"if",
"(",
"!",
"descSet",
".",
"isEmpty",
"(",
... | Merge plugin configuration files. | [
"Merge",
"plugin",
"configuration",
"files",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L797-L812 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/Integrator.java | Integrator.parseDesc | private Element parseDesc(final File descFile) {
try {
parser.setPluginDir(descFile.getParentFile());
final Element root = parser.parse(descFile.getAbsoluteFile());
final Features f = parser.getFeatures();
final String id = f.getPluginId();
validatePlugin(f);
extensionPoints.addAll(f.getExtensionPoints().keySet());
pluginTable.put(id, f);
return root;
} catch (final RuntimeException e) {
throw e;
} catch (final SAXParseException e) {
final RuntimeException ex = new RuntimeException("Failed to parse " + descFile.getAbsolutePath() + ": " + e.getMessage(), e);
throw ex;
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | java | private Element parseDesc(final File descFile) {
try {
parser.setPluginDir(descFile.getParentFile());
final Element root = parser.parse(descFile.getAbsoluteFile());
final Features f = parser.getFeatures();
final String id = f.getPluginId();
validatePlugin(f);
extensionPoints.addAll(f.getExtensionPoints().keySet());
pluginTable.put(id, f);
return root;
} catch (final RuntimeException e) {
throw e;
} catch (final SAXParseException e) {
final RuntimeException ex = new RuntimeException("Failed to parse " + descFile.getAbsolutePath() + ": " + e.getMessage(), e);
throw ex;
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | [
"private",
"Element",
"parseDesc",
"(",
"final",
"File",
"descFile",
")",
"{",
"try",
"{",
"parser",
".",
"setPluginDir",
"(",
"descFile",
".",
"getParentFile",
"(",
")",
")",
";",
"final",
"Element",
"root",
"=",
"parser",
".",
"parse",
"(",
"descFile",
... | Parse plugin configuration file
@param descFile plugin configuration | [
"Parse",
"plugin",
"configuration",
"file"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L830-L848 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/Integrator.java | Integrator.validatePlugin | private void validatePlugin(final Features f) {
final String id = f.getPluginId();
if (!ID_PATTERN.matcher(id).matches()) {
final String msg = "Plug-in ID '" + id + "' doesn't follow syntax rules.";
throw new IllegalArgumentException(msg);
}
final List<String> version = f.getFeature("package.version");
if (version != null && !version.isEmpty() && !VERSION_PATTERN.matcher(version.get(0)).matches()) {
final String msg = "Plug-in version '" + version.get(0) + "' doesn't follow syntax rules.";
throw new IllegalArgumentException(msg);
}
} | java | private void validatePlugin(final Features f) {
final String id = f.getPluginId();
if (!ID_PATTERN.matcher(id).matches()) {
final String msg = "Plug-in ID '" + id + "' doesn't follow syntax rules.";
throw new IllegalArgumentException(msg);
}
final List<String> version = f.getFeature("package.version");
if (version != null && !version.isEmpty() && !VERSION_PATTERN.matcher(version.get(0)).matches()) {
final String msg = "Plug-in version '" + version.get(0) + "' doesn't follow syntax rules.";
throw new IllegalArgumentException(msg);
}
} | [
"private",
"void",
"validatePlugin",
"(",
"final",
"Features",
"f",
")",
"{",
"final",
"String",
"id",
"=",
"f",
".",
"getPluginId",
"(",
")",
";",
"if",
"(",
"!",
"ID_PATTERN",
".",
"matcher",
"(",
"id",
")",
".",
"matches",
"(",
")",
")",
"{",
"f... | Validate plug-in configuration.
Follow OSGi symbolic name syntax rules:
<pre>
digit ::= [0..9]
alpha ::= [a..zA..Z]
alphanum ::= alpha | digit
token ::= ( alphanum | '_' | '-' )+
symbolic-name ::= token('.'token)*
</pre>
Follow OSGi bundle version syntax rules:
<pre>
version ::= major( '.' minor ( '.' micro ( '.' qualifier )? )? )?
major ::= number
minor ::=number
micro ::=number
qualifier ::= ( alphanum | '_' | '-' )+
</pre>
@param f Features to validate | [
"Validate",
"plug",
"-",
"in",
"configuration",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L875-L886 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/Integrator.java | Integrator.getValue | static String getValue(final Map<String, Features> featureTable, final String extension) {
final List<String> buf = new ArrayList<>();
for (final Features f : featureTable.values()) {
final List<String> v = f.getFeature(extension);
if (v != null) {
buf.addAll(v);
}
}
if (buf.isEmpty()) {
return null;
} else {
return StringUtils.join(buf, ",");
}
} | java | static String getValue(final Map<String, Features> featureTable, final String extension) {
final List<String> buf = new ArrayList<>();
for (final Features f : featureTable.values()) {
final List<String> v = f.getFeature(extension);
if (v != null) {
buf.addAll(v);
}
}
if (buf.isEmpty()) {
return null;
} else {
return StringUtils.join(buf, ",");
}
} | [
"static",
"String",
"getValue",
"(",
"final",
"Map",
"<",
"String",
",",
"Features",
">",
"featureTable",
",",
"final",
"String",
"extension",
")",
"{",
"final",
"List",
"<",
"String",
">",
"buf",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(... | Get all and combine extension values
@param featureTable plugin features
@param extension extension ID
@return combined extension value, {@code null} if no value available | [
"Get",
"all",
"and",
"combine",
"extension",
"values"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L914-L927 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.toList | public static <T> List<T> toList(final NodeList nodes) {
final List<T> res = new ArrayList<>(nodes.getLength());
for (int i = 0; i < nodes.getLength(); i++) {
res.add((T) nodes.item(i));
}
return res;
} | java | public static <T> List<T> toList(final NodeList nodes) {
final List<T> res = new ArrayList<>(nodes.getLength());
for (int i = 0; i < nodes.getLength(); i++) {
res.add((T) nodes.item(i));
}
return res;
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"final",
"NodeList",
"nodes",
")",
"{",
"final",
"List",
"<",
"T",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
"nodes",
".",
"getLength",
"(",
")",
")",
";",
"for",
"(",... | Convert DOM NodeList to List. | [
"Convert",
"DOM",
"NodeList",
"to",
"List",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L67-L73 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getPrefix | public static String getPrefix(final String qname) {
final int sep = qname.indexOf(':');
return sep != -1 ? qname.substring(0, sep) : DEFAULT_NS_PREFIX;
} | java | public static String getPrefix(final String qname) {
final int sep = qname.indexOf(':');
return sep != -1 ? qname.substring(0, sep) : DEFAULT_NS_PREFIX;
} | [
"public",
"static",
"String",
"getPrefix",
"(",
"final",
"String",
"qname",
")",
"{",
"final",
"int",
"sep",
"=",
"qname",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"return",
"sep",
"!=",
"-",
"1",
"?",
"qname",
".",
"substring",
"(",
"0",
",",
"sep... | Get prefix from QName. | [
"Get",
"prefix",
"from",
"QName",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L87-L90 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElements | public static List<Element> getChildElements(final Element elem, final DitaClass cls, final boolean deep) {
final NodeList children = deep ? elem.getElementsByTagName("*") : elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (cls.matches(child)) {
res.add((Element) child);
}
}
return res;
} | java | public static List<Element> getChildElements(final Element elem, final DitaClass cls, final boolean deep) {
final NodeList children = deep ? elem.getElementsByTagName("*") : elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (cls.matches(child)) {
res.add((Element) child);
}
}
return res;
} | [
"public",
"static",
"List",
"<",
"Element",
">",
"getChildElements",
"(",
"final",
"Element",
"elem",
",",
"final",
"DitaClass",
"cls",
",",
"final",
"boolean",
"deep",
")",
"{",
"final",
"NodeList",
"children",
"=",
"deep",
"?",
"elem",
".",
"getElementsByT... | List descendant elements by DITA class.
@param elem root element
@param cls DITA class to match elements
@param deep {@code true} to read descendants, {@code false} to read only direct children
@return list of matching elements | [
"List",
"descendant",
"elements",
"by",
"DITA",
"class",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L100-L110 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElement | public static Optional<Element> getChildElement(final Element elem, final String ns, final String name) {
final NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
if (Objects.equals(child.getNamespaceURI(), ns) && name.equals(child.getLocalName())) {
return Optional.of((Element) child);
}
}
}
return Optional.empty();
} | java | public static Optional<Element> getChildElement(final Element elem, final String ns, final String name) {
final NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
if (Objects.equals(child.getNamespaceURI(), ns) && name.equals(child.getLocalName())) {
return Optional.of((Element) child);
}
}
}
return Optional.empty();
} | [
"public",
"static",
"Optional",
"<",
"Element",
">",
"getChildElement",
"(",
"final",
"Element",
"elem",
",",
"final",
"String",
"ns",
",",
"final",
"String",
"name",
")",
"{",
"final",
"NodeList",
"children",
"=",
"elem",
".",
"getChildNodes",
"(",
")",
"... | Get first child element by element name.
@param elem root element
@param ns namespace URI, {@code null} for empty namespace
@param name element name to match element
@return matching element | [
"Get",
"first",
"child",
"element",
"by",
"element",
"name",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L120-L131 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElement | public static Optional<Element> getChildElement(final Element elem, final DitaClass cls) {
final NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (cls.matches(child)) {
return Optional.of((Element) child);
}
}
return Optional.empty();
} | java | public static Optional<Element> getChildElement(final Element elem, final DitaClass cls) {
final NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (cls.matches(child)) {
return Optional.of((Element) child);
}
}
return Optional.empty();
} | [
"public",
"static",
"Optional",
"<",
"Element",
">",
"getChildElement",
"(",
"final",
"Element",
"elem",
",",
"final",
"DitaClass",
"cls",
")",
"{",
"final",
"NodeList",
"children",
"=",
"elem",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
... | Get first child element by DITA class.
@param elem root element
@param cls DITA class to match element
@return matching element | [
"Get",
"first",
"child",
"element",
"by",
"DITA",
"class",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L140-L149 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElements | public static List<Element> getChildElements(final Element elem, final String ns, final String name) {
final NodeList children = elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
if (Objects.equals(child.getNamespaceURI(), ns) && name.equals(child.getLocalName())) {
res.add((Element) child);
}
}
}
return res;
} | java | public static List<Element> getChildElements(final Element elem, final String ns, final String name) {
final NodeList children = elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
if (Objects.equals(child.getNamespaceURI(), ns) && name.equals(child.getLocalName())) {
res.add((Element) child);
}
}
}
return res;
} | [
"public",
"static",
"List",
"<",
"Element",
">",
"getChildElements",
"(",
"final",
"Element",
"elem",
",",
"final",
"String",
"ns",
",",
"final",
"String",
"name",
")",
"{",
"final",
"NodeList",
"children",
"=",
"elem",
".",
"getChildNodes",
"(",
")",
";",... | List child elements by element name.
@param ns namespace URL, {@code null} for empty namespace
@param elem root element
@param name element local name to match elements
@return list of matching elements | [
"List",
"child",
"elements",
"by",
"element",
"name",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L159-L171 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElements | public static List<Element> getChildElements(final Element elem, final DitaClass cls) {
return getChildElements(elem, cls, false);
} | java | public static List<Element> getChildElements(final Element elem, final DitaClass cls) {
return getChildElements(elem, cls, false);
} | [
"public",
"static",
"List",
"<",
"Element",
">",
"getChildElements",
"(",
"final",
"Element",
"elem",
",",
"final",
"DitaClass",
"cls",
")",
"{",
"return",
"getChildElements",
"(",
"elem",
",",
"cls",
",",
"false",
")",
";",
"}"
] | List child elements by DITA class.
@param elem root element
@param cls DITA class to match elements
@return list of matching elements | [
"List",
"child",
"elements",
"by",
"DITA",
"class",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L180-L182 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElements | public static List<Element> getChildElements(final Element elem, final boolean deep) {
final NodeList children = deep ? elem.getElementsByTagName("*") : elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
res.add((Element) child);
}
}
return res;
} | java | public static List<Element> getChildElements(final Element elem, final boolean deep) {
final NodeList children = deep ? elem.getElementsByTagName("*") : elem.getChildNodes();
final List<Element> res = new ArrayList<>(children.getLength());
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
res.add((Element) child);
}
}
return res;
} | [
"public",
"static",
"List",
"<",
"Element",
">",
"getChildElements",
"(",
"final",
"Element",
"elem",
",",
"final",
"boolean",
"deep",
")",
"{",
"final",
"NodeList",
"children",
"=",
"deep",
"?",
"elem",
".",
"getElementsByTagName",
"(",
"\"*\"",
")",
":",
... | List child elements elements.
@param elem root element
@param deep {@code true} to read descendants, {@code false} to read only direct children
@return list of matching elements | [
"List",
"child",
"elements",
"elements",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L201-L211 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getElementNode | public static Element getElementNode(final Element element, final DitaClass classValue) {
final NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
final Element child = (Element) node;
if (classValue.matches(child)) {
return child;
}
}
}
return null;
} | java | public static Element getElementNode(final Element element, final DitaClass classValue) {
final NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
final Element child = (Element) node;
if (classValue.matches(child)) {
return child;
}
}
}
return null;
} | [
"public",
"static",
"Element",
"getElementNode",
"(",
"final",
"Element",
"element",
",",
"final",
"DitaClass",
"classValue",
")",
"{",
"final",
"NodeList",
"list",
"=",
"element",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",... | Get specific element node from child nodes.
@param element parent node
@param classValue DITA class to search for
@return element node, {@code null} if not found | [
"Get",
"specific",
"element",
"node",
"from",
"child",
"nodes",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L241-L253 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getText | public static String getText(final Node root) {
if (root == null) {
return "";
} else {
final StringBuilder result = new StringBuilder(1024);
if (root.hasChildNodes()) {
final NodeList list = root.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node childNode = list.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
final Element e = (Element) childNode;
final String value = e.getAttribute(ATTRIBUTE_NAME_CLASS);
if (!excludeList.contains(value)) {
final String s = getText(e);
result.append(s);
}
} else if (childNode.getNodeType() == Node.TEXT_NODE) {
result.append(childNode.getNodeValue());
}
}
} else if (root.getNodeType() == Node.TEXT_NODE) {
result.append(root.getNodeValue());
}
return result.toString();
}
} | java | public static String getText(final Node root) {
if (root == null) {
return "";
} else {
final StringBuilder result = new StringBuilder(1024);
if (root.hasChildNodes()) {
final NodeList list = root.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node childNode = list.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
final Element e = (Element) childNode;
final String value = e.getAttribute(ATTRIBUTE_NAME_CLASS);
if (!excludeList.contains(value)) {
final String s = getText(e);
result.append(s);
}
} else if (childNode.getNodeType() == Node.TEXT_NODE) {
result.append(childNode.getNodeValue());
}
}
} else if (root.getNodeType() == Node.TEXT_NODE) {
result.append(root.getNodeValue());
}
return result.toString();
}
} | [
"public",
"static",
"String",
"getText",
"(",
"final",
"Node",
"root",
")",
"{",
"if",
"(",
"root",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"1024",
")",
";",... | Get text value of a node.
@param root root node
@return text value | [
"Get",
"text",
"value",
"of",
"a",
"node",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L274-L299 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.searchForNode | public static Element searchForNode(final Element root, final String searchKey, final String attrName,
final DitaClass classValue) {
if (root == null) {
return null;
}
final Queue<Element> queue = new LinkedList<>();
queue.offer(root);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element) node);
}
}
if (pe.getAttribute(ATTRIBUTE_NAME_CLASS) == null || !classValue.matches(pe)) {
continue;
}
final Attr value = pe.getAttributeNode(attrName);
if (value == null) {
continue;
}
if (searchKey.equals(value.getValue())) {
return pe;
}
}
return null;
} | java | public static Element searchForNode(final Element root, final String searchKey, final String attrName,
final DitaClass classValue) {
if (root == null) {
return null;
}
final Queue<Element> queue = new LinkedList<>();
queue.offer(root);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element) node);
}
}
if (pe.getAttribute(ATTRIBUTE_NAME_CLASS) == null || !classValue.matches(pe)) {
continue;
}
final Attr value = pe.getAttributeNode(attrName);
if (value == null) {
continue;
}
if (searchKey.equals(value.getValue())) {
return pe;
}
}
return null;
} | [
"public",
"static",
"Element",
"searchForNode",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"searchKey",
",",
"final",
"String",
"attrName",
",",
"final",
"DitaClass",
"classValue",
")",
"{",
"if",
"(",
"root",
"==",
"null",
")",
"{",
"return",
... | Search for the special kind of node by specialized value. Equivalent to XPath
<pre>$root//*[contains(@class, $classValue)][@*[name() = $attrName and . = $searchKey]]</pre>
@param root place may have the node.
@param searchKey keyword for search.
@param attrName attribute name for search.
@param classValue class value for search.
@return matching element, {@code null} if not found | [
"Search",
"for",
"the",
"special",
"kind",
"of",
"node",
"by",
"specialized",
"value",
".",
"Equivalent",
"to",
"XPath"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L312-L340 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.addOrSetAttribute | public static void addOrSetAttribute(final AttributesImpl atts, final String uri, final String localName,
final String qName, final String type, final String value) {
final int i = atts.getIndex(qName);
if (i != -1) {
atts.setAttribute(i, uri, localName, qName, type, value);
} else {
atts.addAttribute(uri, localName, qName, type, value);
}
} | java | public static void addOrSetAttribute(final AttributesImpl atts, final String uri, final String localName,
final String qName, final String type, final String value) {
final int i = atts.getIndex(qName);
if (i != -1) {
atts.setAttribute(i, uri, localName, qName, type, value);
} else {
atts.addAttribute(uri, localName, qName, type, value);
}
} | [
"public",
"static",
"void",
"addOrSetAttribute",
"(",
"final",
"AttributesImpl",
"atts",
",",
"final",
"String",
"uri",
",",
"final",
"String",
"localName",
",",
"final",
"String",
"qName",
",",
"final",
"String",
"type",
",",
"final",
"String",
"value",
")",
... | Add or set attribute.
@param atts attributes
@param uri namespace URI
@param localName local name
@param qName qualified name
@param type attribute type
@param value attribute value | [
"Add",
"or",
"set",
"attribute",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L352-L360 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.removeAttribute | public static void removeAttribute(final AttributesImpl atts, final String qName) {
final int i = atts.getIndex(qName);
if (i != -1) {
atts.removeAttribute(i);
}
} | java | public static void removeAttribute(final AttributesImpl atts, final String qName) {
final int i = atts.getIndex(qName);
if (i != -1) {
atts.removeAttribute(i);
}
} | [
"public",
"static",
"void",
"removeAttribute",
"(",
"final",
"AttributesImpl",
"atts",
",",
"final",
"String",
"qName",
")",
"{",
"final",
"int",
"i",
"=",
"atts",
".",
"getIndex",
"(",
"qName",
")",
";",
"if",
"(",
"i",
"!=",
"-",
"1",
")",
"{",
"at... | Remove an attribute from the list. Do nothing if attribute does not exist.
@param atts attributes
@param qName QName of the attribute to remove | [
"Remove",
"an",
"attribute",
"from",
"the",
"list",
".",
"Do",
"nothing",
"if",
"attribute",
"does",
"not",
"exist",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L417-L422 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getStringValue | public static String getStringValue(final Element element) {
final StringBuilder buf = new StringBuilder();
final NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node n = children.item(i);
switch (n.getNodeType()) {
case Node.TEXT_NODE:
buf.append(n.getNodeValue());
break;
case Node.ELEMENT_NODE:
buf.append(getStringValue((Element) n));
break;
}
}
return buf.toString();
} | java | public static String getStringValue(final Element element) {
final StringBuilder buf = new StringBuilder();
final NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node n = children.item(i);
switch (n.getNodeType()) {
case Node.TEXT_NODE:
buf.append(n.getNodeValue());
break;
case Node.ELEMENT_NODE:
buf.append(getStringValue((Element) n));
break;
}
}
return buf.toString();
} | [
"public",
"static",
"String",
"getStringValue",
"(",
"final",
"Element",
"element",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"NodeList",
"children",
"=",
"element",
".",
"getChildNodes",
"(",
")",
";",
"... | Get element node string value.
@param element element to get string value for
@return concatenated text node descendant values | [
"Get",
"element",
"node",
"string",
"value",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L430-L445 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.transform | public void transform(final URI input, final List<XMLFilter> filters) throws DITAOTException {
assert input.isAbsolute();
if (!input.getScheme().equals("file")) {
throw new IllegalArgumentException("Only file URI scheme supported: " + input);
}
transform(new File(input), filters);
} | java | public void transform(final URI input, final List<XMLFilter> filters) throws DITAOTException {
assert input.isAbsolute();
if (!input.getScheme().equals("file")) {
throw new IllegalArgumentException("Only file URI scheme supported: " + input);
}
transform(new File(input), filters);
} | [
"public",
"void",
"transform",
"(",
"final",
"URI",
"input",
",",
"final",
"List",
"<",
"XMLFilter",
">",
"filters",
")",
"throws",
"DITAOTException",
"{",
"assert",
"input",
".",
"isAbsolute",
"(",
")",
";",
"if",
"(",
"!",
"input",
".",
"getScheme",
"(... | Transform file with XML filters. Only file URIs are supported.
@param input absolute URI to transform and replace
@param filters XML filters to transform file with, may be an empty list | [
"Transform",
"file",
"with",
"XML",
"filters",
".",
"Only",
"file",
"URIs",
"are",
"supported",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L453-L460 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.close | public static void close(final Source input) throws IOException {
if (input != null && input instanceof StreamSource) {
final StreamSource s = (StreamSource) input;
final InputStream i = s.getInputStream();
if (i != null) {
i.close();
} else {
final Reader w = s.getReader();
if (w != null) {
w.close();
}
}
}
} | java | public static void close(final Source input) throws IOException {
if (input != null && input instanceof StreamSource) {
final StreamSource s = (StreamSource) input;
final InputStream i = s.getInputStream();
if (i != null) {
i.close();
} else {
final Reader w = s.getReader();
if (w != null) {
w.close();
}
}
}
} | [
"public",
"static",
"void",
"close",
"(",
"final",
"Source",
"input",
")",
"throws",
"IOException",
"{",
"if",
"(",
"input",
"!=",
"null",
"&&",
"input",
"instanceof",
"StreamSource",
")",
"{",
"final",
"StreamSource",
"s",
"=",
"(",
"StreamSource",
")",
"... | Close source. | [
"Close",
"source",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L600-L613 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.close | public static void close(final Result result) throws IOException {
if (result != null && result instanceof StreamResult) {
final StreamResult r = (StreamResult) result;
final OutputStream o = r.getOutputStream();
if (o != null) {
o.close();
} else {
final Writer w = r.getWriter();
if (w != null) {
w.close();
}
}
}
} | java | public static void close(final Result result) throws IOException {
if (result != null && result instanceof StreamResult) {
final StreamResult r = (StreamResult) result;
final OutputStream o = r.getOutputStream();
if (o != null) {
o.close();
} else {
final Writer w = r.getWriter();
if (w != null) {
w.close();
}
}
}
} | [
"public",
"static",
"void",
"close",
"(",
"final",
"Result",
"result",
")",
"throws",
"IOException",
"{",
"if",
"(",
"result",
"!=",
"null",
"&&",
"result",
"instanceof",
"StreamResult",
")",
"{",
"final",
"StreamResult",
"r",
"=",
"(",
"StreamResult",
")",
... | Close result. | [
"Close",
"result",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L616-L629 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getXMLReader | public static XMLReader getXMLReader() throws SAXException {
XMLReader reader;
if (System.getProperty(SAX_DRIVER_PROPERTY) != null) {
return XMLReaderFactory.createXMLReader();
}
try {
Class.forName(SAX_DRIVER_DEFAULT_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_DEFAULT_CLASS);
} catch (final ClassNotFoundException e) {
try {
Class.forName(SAX_DRIVER_SUN_HACK_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_SUN_HACK_CLASS);
} catch (final ClassNotFoundException ex) {
try {
Class.forName(SAX_DRIVER_CRIMSON_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_CRIMSON_CLASS);
} catch (final ClassNotFoundException exc) {
reader = XMLReaderFactory.createXMLReader();
}
}
}
if (Configuration.DEBUG) {
reader = new DebugXMLReader(reader);
}
return reader;
} | java | public static XMLReader getXMLReader() throws SAXException {
XMLReader reader;
if (System.getProperty(SAX_DRIVER_PROPERTY) != null) {
return XMLReaderFactory.createXMLReader();
}
try {
Class.forName(SAX_DRIVER_DEFAULT_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_DEFAULT_CLASS);
} catch (final ClassNotFoundException e) {
try {
Class.forName(SAX_DRIVER_SUN_HACK_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_SUN_HACK_CLASS);
} catch (final ClassNotFoundException ex) {
try {
Class.forName(SAX_DRIVER_CRIMSON_CLASS);
reader = XMLReaderFactory.createXMLReader(SAX_DRIVER_CRIMSON_CLASS);
} catch (final ClassNotFoundException exc) {
reader = XMLReaderFactory.createXMLReader();
}
}
}
if (Configuration.DEBUG) {
reader = new DebugXMLReader(reader);
}
return reader;
} | [
"public",
"static",
"XMLReader",
"getXMLReader",
"(",
")",
"throws",
"SAXException",
"{",
"XMLReader",
"reader",
";",
"if",
"(",
"System",
".",
"getProperty",
"(",
"SAX_DRIVER_PROPERTY",
")",
"!=",
"null",
")",
"{",
"return",
"XMLReaderFactory",
".",
"createXMLR... | Get preferred SAX parser.
Preferred XML readers are in order:
<ol>
<li>{@link Constants#SAX_DRIVER_DEFAULT_CLASS Xerces}</li>
<li>{@link Constants#SAX_DRIVER_SUN_HACK_CLASS Sun's Xerces}</li>
<li>{@link Constants#SAX_DRIVER_CRIMSON_CLASS Crimson}</li>
</ol>
@return XML parser instance.
@throws org.xml.sax.SAXException if instantiating XMLReader failed | [
"Get",
"preferred",
"SAX",
"parser",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L695-L720 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getDocumentBuilder | public static DocumentBuilder getDocumentBuilder() {
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
} catch (final ParserConfigurationException e) {
throw new RuntimeException(e);
}
if (Configuration.DEBUG) {
builder = new DebugDocumentBuilder(builder);
}
return builder;
} | java | public static DocumentBuilder getDocumentBuilder() {
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
} catch (final ParserConfigurationException e) {
throw new RuntimeException(e);
}
if (Configuration.DEBUG) {
builder = new DebugDocumentBuilder(builder);
}
return builder;
} | [
"public",
"static",
"DocumentBuilder",
"getDocumentBuilder",
"(",
")",
"{",
"DocumentBuilder",
"builder",
";",
"try",
"{",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"ParserConfigurationException",
"e",
")",
... | Get DOM parser.
@return DOM document builder instance.
@throws RuntimeException if instantiating DocumentBuilder failed | [
"Get",
"DOM",
"parser",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L728-L739 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getCascadeValue | public static String getCascadeValue(final Element elem, final String attrName) {
Element current = elem;
while (current != null) {
final Attr attr = current.getAttributeNode(attrName);
if (attr != null) {
return attr.getValue();
}
final Node parent = current.getParentNode();
if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
current = (Element) parent;
} else {
break;
}
}
return null;
} | java | public static String getCascadeValue(final Element elem, final String attrName) {
Element current = elem;
while (current != null) {
final Attr attr = current.getAttributeNode(attrName);
if (attr != null) {
return attr.getValue();
}
final Node parent = current.getParentNode();
if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
current = (Element) parent;
} else {
break;
}
}
return null;
} | [
"public",
"static",
"String",
"getCascadeValue",
"(",
"final",
"Element",
"elem",
",",
"final",
"String",
"attrName",
")",
"{",
"Element",
"current",
"=",
"elem",
";",
"while",
"(",
"current",
"!=",
"null",
")",
"{",
"final",
"Attr",
"attr",
"=",
"current"... | Get cascaded attribute value.
@param elem attribute parent element
@param attrName attribute name
@return attribute value, {@code null} if not set | [
"Get",
"cascaded",
"attribute",
"value",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L1020-L1035 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.ancestors | public static Stream<Element> ancestors(final Element element) {
final Stream.Builder<Element> builder = Stream.builder();
for (Node current = element.getParentNode(); current != null; current = current.getParentNode()) {
if (current.getNodeType() == Node.ELEMENT_NODE) {
builder.accept((Element) current);
}
}
return builder.build();
} | java | public static Stream<Element> ancestors(final Element element) {
final Stream.Builder<Element> builder = Stream.builder();
for (Node current = element.getParentNode(); current != null; current = current.getParentNode()) {
if (current.getNodeType() == Node.ELEMENT_NODE) {
builder.accept((Element) current);
}
}
return builder.build();
} | [
"public",
"static",
"Stream",
"<",
"Element",
">",
"ancestors",
"(",
"final",
"Element",
"element",
")",
"{",
"final",
"Stream",
".",
"Builder",
"<",
"Element",
">",
"builder",
"=",
"Stream",
".",
"builder",
"(",
")",
";",
"for",
"(",
"Node",
"current",
... | Stream of element ancestor elements.
@param element start element
@return stream of ancestor elements | [
"Stream",
"of",
"element",
"ancestor",
"elements",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L1042-L1050 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/ModuleFactory.java | ModuleFactory.createModule | public AbstractPipelineModule createModule(final Class<? extends AbstractPipelineModule> moduleClass)
throws DITAOTException {
try {
return moduleClass.newInstance();
} catch (final Exception e) {
final MessageBean msgBean = MessageUtils.getMessage("DOTJ005F", moduleClass.getName());
final String msg = msgBean.toString();
throw new DITAOTException(msgBean, e,msg);
}
} | java | public AbstractPipelineModule createModule(final Class<? extends AbstractPipelineModule> moduleClass)
throws DITAOTException {
try {
return moduleClass.newInstance();
} catch (final Exception e) {
final MessageBean msgBean = MessageUtils.getMessage("DOTJ005F", moduleClass.getName());
final String msg = msgBean.toString();
throw new DITAOTException(msgBean, e,msg);
}
} | [
"public",
"AbstractPipelineModule",
"createModule",
"(",
"final",
"Class",
"<",
"?",
"extends",
"AbstractPipelineModule",
">",
"moduleClass",
")",
"throws",
"DITAOTException",
"{",
"try",
"{",
"return",
"moduleClass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch... | Create the ModuleElem class instance according to moduleName.
@param moduleClass module class
@return AbstractPipelineModule
@throws DITAOTException DITAOTException
@since 1.6 | [
"Create",
"the",
"ModuleElem",
"class",
"instance",
"according",
"to",
"moduleName",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/ModuleFactory.java#L52-L62 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/CatalogUtils.java | CatalogUtils.getCatalogResolver | public static synchronized CatalogResolver getCatalogResolver() {
if (catalogResolver == null) {
final CatalogManager manager = new CatalogManager();
manager.setIgnoreMissingProperties(true);
manager.setUseStaticCatalog(false); // We'll use a private catalog.
manager.setPreferPublic(true);
final File catalogFilePath = new File(ditaDir, Configuration.pluginResourceDirs.get("org.dita.base") + File.separator + FILE_NAME_CATALOG);
manager.setCatalogFiles(catalogFilePath.toURI().toASCIIString());
//manager.setVerbosity(10);
catalogResolver = new CatalogResolver(manager);
}
return catalogResolver;
} | java | public static synchronized CatalogResolver getCatalogResolver() {
if (catalogResolver == null) {
final CatalogManager manager = new CatalogManager();
manager.setIgnoreMissingProperties(true);
manager.setUseStaticCatalog(false); // We'll use a private catalog.
manager.setPreferPublic(true);
final File catalogFilePath = new File(ditaDir, Configuration.pluginResourceDirs.get("org.dita.base") + File.separator + FILE_NAME_CATALOG);
manager.setCatalogFiles(catalogFilePath.toURI().toASCIIString());
//manager.setVerbosity(10);
catalogResolver = new CatalogResolver(manager);
}
return catalogResolver;
} | [
"public",
"static",
"synchronized",
"CatalogResolver",
"getCatalogResolver",
"(",
")",
"{",
"if",
"(",
"catalogResolver",
"==",
"null",
")",
"{",
"final",
"CatalogManager",
"manager",
"=",
"new",
"CatalogManager",
"(",
")",
";",
"manager",
".",
"setIgnoreMissingPr... | Get CatalogResolver.
@return CatalogResolver | [
"Get",
"CatalogResolver",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/CatalogUtils.java#L50-L63 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.setup | public void setup(final LinkedHashMap<URI, URI> changeTable, final Map<URI, URI> conflictTable,
final Element rootTopicref,
final ChunkFilenameGenerator chunkFilenameGenerator) {
this.changeTable = changeTable;
this.rootTopicref = rootTopicref;
this.conflictTable = conflictTable;
this.chunkFilenameGenerator = chunkFilenameGenerator;
} | java | public void setup(final LinkedHashMap<URI, URI> changeTable, final Map<URI, URI> conflictTable,
final Element rootTopicref,
final ChunkFilenameGenerator chunkFilenameGenerator) {
this.changeTable = changeTable;
this.rootTopicref = rootTopicref;
this.conflictTable = conflictTable;
this.chunkFilenameGenerator = chunkFilenameGenerator;
} | [
"public",
"void",
"setup",
"(",
"final",
"LinkedHashMap",
"<",
"URI",
",",
"URI",
">",
"changeTable",
",",
"final",
"Map",
"<",
"URI",
",",
"URI",
">",
"conflictTable",
",",
"final",
"Element",
"rootTopicref",
",",
"final",
"ChunkFilenameGenerator",
"chunkFile... | Set up the class.
@param changeTable changeTable
@param conflictTable conflictTable
@param rootTopicref chunking topicref | [
"Set",
"up",
"the",
"class",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L110-L117 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.generateOutputFile | URI generateOutputFile(final URI ref) {
final FileInfo srcFi = job.getFileInfo(ref);
final URI newSrc = srcFi.src.resolve(generateFilename());
final URI tmp = tempFileNameScheme.generateTempFileName(newSrc);
if (job.getFileInfo(tmp) == null) {
job.add(new FileInfo.Builder()
.result(newSrc)
.uri(tmp)
.build());
}
return job.tempDirURI.resolve(tmp);
} | java | URI generateOutputFile(final URI ref) {
final FileInfo srcFi = job.getFileInfo(ref);
final URI newSrc = srcFi.src.resolve(generateFilename());
final URI tmp = tempFileNameScheme.generateTempFileName(newSrc);
if (job.getFileInfo(tmp) == null) {
job.add(new FileInfo.Builder()
.result(newSrc)
.uri(tmp)
.build());
}
return job.tempDirURI.resolve(tmp);
} | [
"URI",
"generateOutputFile",
"(",
"final",
"URI",
"ref",
")",
"{",
"final",
"FileInfo",
"srcFi",
"=",
"job",
".",
"getFileInfo",
"(",
"ref",
")",
";",
"final",
"URI",
"newSrc",
"=",
"srcFi",
".",
"src",
".",
"resolve",
"(",
"generateFilename",
"(",
")",
... | Generate output file.
@return absolute temporary file | [
"Generate",
"output",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L334-L347 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.createTopicMeta | Element createTopicMeta(final Element topic) {
final Document doc = rootTopicref.getOwnerDocument();
final Element topicmeta = doc.createElement(MAP_TOPICMETA.localName);
topicmeta.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICMETA.toString());
// iterate the node.
if (topic != null) {
final Element title = getElementNode(topic, TOPIC_TITLE);
final Element titlealts = getElementNode(topic, TOPIC_TITLEALTS);
final Element navtitle = titlealts != null ? getElementNode(titlealts, TOPIC_NAVTITLE) : null;
final Element shortDesc = getElementNode(topic, TOPIC_SHORTDESC);
final Element navtitleNode = doc.createElement(TOPIC_NAVTITLE.localName);
navtitleNode.setAttribute(ATTRIBUTE_NAME_CLASS, TOPIC_NAVTITLE.toString());
// append navtitle node
if (navtitle != null) {
final String text = getText(navtitle);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
} else {
final String text = getText(title);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
}
// append gentext pi
final Node pi = doc.createProcessingInstruction("ditaot", "gentext");
topicmeta.appendChild(pi);
// append linktext
final Element linkTextNode = doc.createElement(TOPIC_LINKTEXT.localName);
linkTextNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_LINKTEXT.toString());
final String text = getText(title);
final Text textNode = doc.createTextNode(text);
linkTextNode.appendChild(textNode);
topicmeta.appendChild(linkTextNode);
// append genshortdesc pi
final Node pii = doc.createProcessingInstruction("ditaot", "genshortdesc");
topicmeta.appendChild(pii);
// append shortdesc
final Element shortDescNode = doc.createElement(TOPIC_SHORTDESC.localName);
shortDescNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_SHORTDESC.toString());
final String shortDescText = getText(shortDesc);
final Text shortDescTextNode = doc.createTextNode(shortDescText);
shortDescNode.appendChild(shortDescTextNode);
topicmeta.appendChild(shortDescNode);
}
return topicmeta;
} | java | Element createTopicMeta(final Element topic) {
final Document doc = rootTopicref.getOwnerDocument();
final Element topicmeta = doc.createElement(MAP_TOPICMETA.localName);
topicmeta.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICMETA.toString());
// iterate the node.
if (topic != null) {
final Element title = getElementNode(topic, TOPIC_TITLE);
final Element titlealts = getElementNode(topic, TOPIC_TITLEALTS);
final Element navtitle = titlealts != null ? getElementNode(titlealts, TOPIC_NAVTITLE) : null;
final Element shortDesc = getElementNode(topic, TOPIC_SHORTDESC);
final Element navtitleNode = doc.createElement(TOPIC_NAVTITLE.localName);
navtitleNode.setAttribute(ATTRIBUTE_NAME_CLASS, TOPIC_NAVTITLE.toString());
// append navtitle node
if (navtitle != null) {
final String text = getText(navtitle);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
} else {
final String text = getText(title);
final Text titleText = doc.createTextNode(text);
navtitleNode.appendChild(titleText);
topicmeta.appendChild(navtitleNode);
}
// append gentext pi
final Node pi = doc.createProcessingInstruction("ditaot", "gentext");
topicmeta.appendChild(pi);
// append linktext
final Element linkTextNode = doc.createElement(TOPIC_LINKTEXT.localName);
linkTextNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_LINKTEXT.toString());
final String text = getText(title);
final Text textNode = doc.createTextNode(text);
linkTextNode.appendChild(textNode);
topicmeta.appendChild(linkTextNode);
// append genshortdesc pi
final Node pii = doc.createProcessingInstruction("ditaot", "genshortdesc");
topicmeta.appendChild(pii);
// append shortdesc
final Element shortDescNode = doc.createElement(TOPIC_SHORTDESC.localName);
shortDescNode.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_SHORTDESC.toString());
final String shortDescText = getText(shortDesc);
final Text shortDescTextNode = doc.createTextNode(shortDescText);
shortDescNode.appendChild(shortDescTextNode);
topicmeta.appendChild(shortDescNode);
}
return topicmeta;
} | [
"Element",
"createTopicMeta",
"(",
"final",
"Element",
"topic",
")",
"{",
"final",
"Document",
"doc",
"=",
"rootTopicref",
".",
"getOwnerDocument",
"(",
")",
";",
"final",
"Element",
"topicmeta",
"=",
"doc",
".",
"createElement",
"(",
"MAP_TOPICMETA",
".",
"lo... | Create topicmeta node.
@param topic document element of a topic file.
@return created and populated topicmeta | [
"Create",
"topicmeta",
"node",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L355-L407 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.getFirstTopicId | String getFirstTopicId(final File ditaTopicFile) {
assert ditaTopicFile.isAbsolute();
if (!ditaTopicFile.isAbsolute()) {
return null;
}
final StringBuilder firstTopicId = new StringBuilder();
final TopicIdParser parser = new TopicIdParser(firstTopicId);
try {
final XMLReader reader = getXMLReader();
reader.setContentHandler(parser);
reader.parse(ditaTopicFile.toURI().toString());
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
if (firstTopicId.length() == 0) {
return null;
}
return firstTopicId.toString();
} | java | String getFirstTopicId(final File ditaTopicFile) {
assert ditaTopicFile.isAbsolute();
if (!ditaTopicFile.isAbsolute()) {
return null;
}
final StringBuilder firstTopicId = new StringBuilder();
final TopicIdParser parser = new TopicIdParser(firstTopicId);
try {
final XMLReader reader = getXMLReader();
reader.setContentHandler(parser);
reader.parse(ditaTopicFile.toURI().toString());
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
if (firstTopicId.length() == 0) {
return null;
}
return firstTopicId.toString();
} | [
"String",
"getFirstTopicId",
"(",
"final",
"File",
"ditaTopicFile",
")",
"{",
"assert",
"ditaTopicFile",
".",
"isAbsolute",
"(",
")",
";",
"if",
"(",
"!",
"ditaTopicFile",
".",
"isAbsolute",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringB... | Get the first topic id from the given dita file.
@param ditaTopicFile a dita file.
@return The first topic id from the given dita file if success, otherwise
{@code null} string is returned. | [
"Get",
"the",
"first",
"topic",
"id",
"from",
"the",
"given",
"dita",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L416-L436 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.writeStartDocument | void writeStartDocument(final Writer output) throws SAXException {
try {
output.write(XML_HEAD);
} catch (IOException e) {
throw new SAXException(e);
}
} | java | void writeStartDocument(final Writer output) throws SAXException {
try {
output.write(XML_HEAD);
} catch (IOException e) {
throw new SAXException(e);
}
} | [
"void",
"writeStartDocument",
"(",
"final",
"Writer",
"output",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"output",
".",
"write",
"(",
"XML_HEAD",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"e",
... | Convenience method to write document start. | [
"Convenience",
"method",
"to",
"write",
"document",
"start",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L443-L449 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java | AbstractChunkTopicParser.writeProcessingInstruction | void writeProcessingInstruction(final Writer output, final String name, final String value)
throws SAXException {
try {
output.write(LESS_THAN);
output.write(QUESTION);
output.write(name);
if (value != null) {
output.write(STRING_BLANK);
output.write(value);
}
output.write(QUESTION);
output.write(GREATER_THAN);
} catch (IOException e) {
throw new SAXException(e);
}
} | java | void writeProcessingInstruction(final Writer output, final String name, final String value)
throws SAXException {
try {
output.write(LESS_THAN);
output.write(QUESTION);
output.write(name);
if (value != null) {
output.write(STRING_BLANK);
output.write(value);
}
output.write(QUESTION);
output.write(GREATER_THAN);
} catch (IOException e) {
throw new SAXException(e);
}
} | [
"void",
"writeProcessingInstruction",
"(",
"final",
"Writer",
"output",
",",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"output",
".",
"write",
"(",
"LESS_THAN",
")",
";",
"output",
".",
"write... | Convenience method to write a processing instruction.
@param name PI name
@param value PI value, may be {@code null} | [
"Convenience",
"method",
"to",
"write",
"a",
"processing",
"instruction",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractChunkTopicParser.java#L496-L511 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/ChunkTopicParser.java | ChunkTopicParser.insertAfter | private void insertAfter(final URI hrefValue, final StringBuffer parentResult, final CharSequence tmpContent) {
int insertpoint = parentResult.lastIndexOf("</");
final int end = parentResult.indexOf(">", insertpoint);
if (insertpoint == -1 || end == -1) {
logger.error(MessageUtils.getMessage("DOTJ033E", hrefValue.toString()).toString());
} else {
if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint, end).trim())) {
insertpoint = parentResult.lastIndexOf("</", insertpoint - 1);
}
parentResult.insert(insertpoint, tmpContent);
}
} | java | private void insertAfter(final URI hrefValue, final StringBuffer parentResult, final CharSequence tmpContent) {
int insertpoint = parentResult.lastIndexOf("</");
final int end = parentResult.indexOf(">", insertpoint);
if (insertpoint == -1 || end == -1) {
logger.error(MessageUtils.getMessage("DOTJ033E", hrefValue.toString()).toString());
} else {
if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint, end).trim())) {
insertpoint = parentResult.lastIndexOf("</", insertpoint - 1);
}
parentResult.insert(insertpoint, tmpContent);
}
} | [
"private",
"void",
"insertAfter",
"(",
"final",
"URI",
"hrefValue",
",",
"final",
"StringBuffer",
"parentResult",
",",
"final",
"CharSequence",
"tmpContent",
")",
"{",
"int",
"insertpoint",
"=",
"parentResult",
".",
"lastIndexOf",
"(",
"\"</\"",
")",
";",
"final... | Append XML content into root element
@param hrefValue href of the topicref
@param parentResult XML content to insert into
@param tmpContent XML content to insert | [
"Append",
"XML",
"content",
"into",
"root",
"element"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ChunkTopicParser.java#L279-L291 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/ChunkTopicParser.java | ChunkTopicParser.writeToContentChunk | private void writeToContentChunk(final String tmpContent, final URI outputFileName, final boolean needWriteDitaTag) throws IOException {
assert outputFileName.isAbsolute();
logger.info("Writing " + outputFileName);
try (OutputStreamWriter ditaFileOutput = new OutputStreamWriter(new FileOutputStream(new File(outputFileName)), StandardCharsets.UTF_8)) {
if (outputFileName.equals(changeTable.get(outputFileName))) {
// if the output file is newly generated file
// write the xml header and workdir PI into new file
writeStartDocument(ditaFileOutput);
final URI workDir = outputFileName.resolve(".");
if (!OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) {
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, new File(workDir).getAbsolutePath());
} else {
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, UNIX_SEPARATOR + new File(workDir).getAbsolutePath());
}
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET_URI, workDir.toString());
final File path2rootmap = toFile(getRelativePath(outputFileName, job.getInputMap())).getParentFile();
writeProcessingInstruction(ditaFileOutput, PI_PATH2ROOTMAP_TARGET_URI, path2rootmap == null ? "./" : toURI(path2rootmap).toString());
if (conflictTable.get(outputFileName) != null) {
final String relativePath = getRelativeUnixPath(new File(currentFile.resolve(".")) + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,
new File(conflictTable.get(outputFileName)).getAbsolutePath());
String path2project = getRelativeUnixPath(relativePath);
if (null == path2project) {
path2project = "";
}
writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET, path2project);
writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET_URI, path2project.isEmpty() ? "./" : toURI(path2project).toString());
}
}
if (needWriteDitaTag) {
final AttributesImpl atts = new AttributesImpl();
addOrSetAttribute(atts, ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION, DITA_NAMESPACE);
addOrSetAttribute(atts, ATTRIBUTE_PREFIX_DITAARCHVERSION + COLON + ATTRIBUTE_NAME_DITAARCHVERSION, "1.3");
writeStartElement(ditaFileOutput, ELEMENT_NAME_DITA, atts);
}
// write the final result to the output file
ditaFileOutput.write(tmpContent);
if (needWriteDitaTag) {
writeEndElement(ditaFileOutput, ELEMENT_NAME_DITA);
}
ditaFileOutput.flush();
} catch (SAXException e) {
throw new IOException(e);
}
} | java | private void writeToContentChunk(final String tmpContent, final URI outputFileName, final boolean needWriteDitaTag) throws IOException {
assert outputFileName.isAbsolute();
logger.info("Writing " + outputFileName);
try (OutputStreamWriter ditaFileOutput = new OutputStreamWriter(new FileOutputStream(new File(outputFileName)), StandardCharsets.UTF_8)) {
if (outputFileName.equals(changeTable.get(outputFileName))) {
// if the output file is newly generated file
// write the xml header and workdir PI into new file
writeStartDocument(ditaFileOutput);
final URI workDir = outputFileName.resolve(".");
if (!OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) {
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, new File(workDir).getAbsolutePath());
} else {
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, UNIX_SEPARATOR + new File(workDir).getAbsolutePath());
}
writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET_URI, workDir.toString());
final File path2rootmap = toFile(getRelativePath(outputFileName, job.getInputMap())).getParentFile();
writeProcessingInstruction(ditaFileOutput, PI_PATH2ROOTMAP_TARGET_URI, path2rootmap == null ? "./" : toURI(path2rootmap).toString());
if (conflictTable.get(outputFileName) != null) {
final String relativePath = getRelativeUnixPath(new File(currentFile.resolve(".")) + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,
new File(conflictTable.get(outputFileName)).getAbsolutePath());
String path2project = getRelativeUnixPath(relativePath);
if (null == path2project) {
path2project = "";
}
writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET, path2project);
writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET_URI, path2project.isEmpty() ? "./" : toURI(path2project).toString());
}
}
if (needWriteDitaTag) {
final AttributesImpl atts = new AttributesImpl();
addOrSetAttribute(atts, ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION, DITA_NAMESPACE);
addOrSetAttribute(atts, ATTRIBUTE_PREFIX_DITAARCHVERSION + COLON + ATTRIBUTE_NAME_DITAARCHVERSION, "1.3");
writeStartElement(ditaFileOutput, ELEMENT_NAME_DITA, atts);
}
// write the final result to the output file
ditaFileOutput.write(tmpContent);
if (needWriteDitaTag) {
writeEndElement(ditaFileOutput, ELEMENT_NAME_DITA);
}
ditaFileOutput.flush();
} catch (SAXException e) {
throw new IOException(e);
}
} | [
"private",
"void",
"writeToContentChunk",
"(",
"final",
"String",
"tmpContent",
",",
"final",
"URI",
"outputFileName",
",",
"final",
"boolean",
"needWriteDitaTag",
")",
"throws",
"IOException",
"{",
"assert",
"outputFileName",
".",
"isAbsolute",
"(",
")",
";",
"lo... | flush the buffer to file after processing is finished | [
"flush",
"the",
"buffer",
"to",
"file",
"after",
"processing",
"is",
"finished"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ChunkTopicParser.java#L294-L339 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/index/Messages.java | Messages.getString | public static String getString (final String key, final Locale msgLocale) {
/*read message resource file.*/
ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, msgLocale);
try {
return RESOURCE_BUNDLE.getString(key);
} catch (final MissingResourceException e) {
return key;
}
} | java | public static String getString (final String key, final Locale msgLocale) {
/*read message resource file.*/
ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, msgLocale);
try {
return RESOURCE_BUNDLE.getString(key);
} catch (final MissingResourceException e) {
return key;
}
} | [
"public",
"static",
"String",
"getString",
"(",
"final",
"String",
"key",
",",
"final",
"Locale",
"msgLocale",
")",
"{",
"/*read message resource file.*/",
"ResourceBundle",
"RESOURCE_BUNDLE",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"BUNDLE_NAME",
",",
"msgLocal... | get specific message by key and locale.
@param key key
@param msgLocale locale
@return string | [
"get",
"specific",
"message",
"by",
"key",
"and",
"locale",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/index/Messages.java#L33-L41 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/DelayConrefUtils.java | DelayConrefUtils.findTopicId | public boolean findTopicId(final File absolutePathToFile, final String id) {
if (!absolutePathToFile.exists()) {
return false;
}
try {
//load the file
final DocumentBuilder builder = XMLUtils.getDocumentBuilder();
builder.setEntityResolver(CatalogUtils.getCatalogResolver());
final Document root = builder.parse(new InputSource(new FileInputStream(absolutePathToFile)));
//get root element
final Element doc = root.getDocumentElement();
//do BFS
final Queue<Element> queue = new LinkedList<>();
queue.offer(doc);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element)node);
}
}
final String classValue = pe.getAttribute(ATTRIBUTE_NAME_CLASS);
if (classValue != null && TOPIC_TOPIC.matches(classValue)) {
//topic id found
if (pe.getAttribute(ATTRIBUTE_NAME_ID).equals(id)) {
return true;
}
}
}
return false;
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error("Failed to read document: " + e.getMessage(), e);
}
return false;
} | java | public boolean findTopicId(final File absolutePathToFile, final String id) {
if (!absolutePathToFile.exists()) {
return false;
}
try {
//load the file
final DocumentBuilder builder = XMLUtils.getDocumentBuilder();
builder.setEntityResolver(CatalogUtils.getCatalogResolver());
final Document root = builder.parse(new InputSource(new FileInputStream(absolutePathToFile)));
//get root element
final Element doc = root.getDocumentElement();
//do BFS
final Queue<Element> queue = new LinkedList<>();
queue.offer(doc);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element)node);
}
}
final String classValue = pe.getAttribute(ATTRIBUTE_NAME_CLASS);
if (classValue != null && TOPIC_TOPIC.matches(classValue)) {
//topic id found
if (pe.getAttribute(ATTRIBUTE_NAME_ID).equals(id)) {
return true;
}
}
}
return false;
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error("Failed to read document: " + e.getMessage(), e);
}
return false;
} | [
"public",
"boolean",
"findTopicId",
"(",
"final",
"File",
"absolutePathToFile",
",",
"final",
"String",
"id",
")",
"{",
"if",
"(",
"!",
"absolutePathToFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"//load the file",
"fi... | Find whether an id is refer to a topic in a dita file.
@param absolutePathToFile the absolute path of dita file
@param id topic id
@return true if id find and false otherwise | [
"Find",
"whether",
"an",
"id",
"is",
"refer",
"to",
"a",
"topic",
"in",
"a",
"dita",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/DelayConrefUtils.java#L82-L122 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/DelayConrefUtils.java | DelayConrefUtils.searchForKey | private Element searchForKey(final Element root, final String key, final String tagName) {
if (root == null || StringUtils.isEmptyString(key)) {
return null;
}
final Queue<Element> queue = new LinkedList<>();
queue.offer(root);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element)node);
}
}
String value = pe.getNodeName();
if (StringUtils.isEmptyString(value)||
!value.equals(tagName)) {
continue;
}
value = pe.getAttribute(ATTRIBUTE_NAME_NAME);
if (StringUtils.isEmptyString(value)) {
continue;
}
if (value.equals(key)) {
return pe;
}
}
return null;
} | java | private Element searchForKey(final Element root, final String key, final String tagName) {
if (root == null || StringUtils.isEmptyString(key)) {
return null;
}
final Queue<Element> queue = new LinkedList<>();
queue.offer(root);
while (!queue.isEmpty()) {
final Element pe = queue.poll();
final NodeList pchildrenList = pe.getChildNodes();
for (int i = 0; i < pchildrenList.getLength(); i++) {
final Node node = pchildrenList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
queue.offer((Element)node);
}
}
String value = pe.getNodeName();
if (StringUtils.isEmptyString(value)||
!value.equals(tagName)) {
continue;
}
value = pe.getAttribute(ATTRIBUTE_NAME_NAME);
if (StringUtils.isEmptyString(value)) {
continue;
}
if (value.equals(key)) {
return pe;
}
}
return null;
} | [
"private",
"Element",
"searchForKey",
"(",
"final",
"Element",
"root",
",",
"final",
"String",
"key",
",",
"final",
"String",
"tagName",
")",
"{",
"if",
"(",
"root",
"==",
"null",
"||",
"StringUtils",
".",
"isEmptyString",
"(",
"key",
")",
")",
"{",
"ret... | Search specific element by key and tagName.
@param root root element
@param key search keyword
@param tagName search tag name
@return search result, null of either input is invalid or the looking result is not found. | [
"Search",
"specific",
"element",
"by",
"key",
"and",
"tagName",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/DelayConrefUtils.java#L192-L224 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/DelayConrefUtils.java | DelayConrefUtils.writeMapToXML | public void writeMapToXML(final Map<String, Set<String>> m) {
final File outputFile = new File(job.tempDir, FILE_NAME_PLUGIN_XML);
if (m == null) {
return;
}
final Properties prop = new Properties();
for (Map.Entry<String, Set<String>> entry : m.entrySet()) {
final String key = entry.getKey();
final String value = StringUtils.join(entry.getValue(),
COMMA);
prop.setProperty(key, value);
}
//File outputFile = new File(tempDir, filename);
final DocumentBuilder db = XMLUtils.getDocumentBuilder();
final Document doc = db.newDocument();
final Element properties = (Element) doc.appendChild(doc
.createElement("properties"));
final Set<Object> keys = prop.keySet();
for (Object key1 : keys) {
final String key = (String) key1;
final Element entry = (Element) properties.appendChild(doc
.createElement("entry"));
entry.setAttribute("key", key);
entry.appendChild(doc.createTextNode(prop.getProperty(key)));
}
final TransformerFactory tf = TransformerFactory.newInstance();
Transformer t;
try {
t = withLogger(tf.newTransformer(), logger);
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.METHOD, "xml");
t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
} catch (final TransformerConfigurationException tce) {
throw new RuntimeException(tce);
}
final DOMSource doms = new DOMSource(doc);
OutputStream out = null;
try {
out = new FileOutputStream(outputFile);
final StreamResult sr = new StreamResult(out);
t.transform(doms, sr);
} catch (final Exception e) {
logger.error("Failed to process map: " + e.getMessage(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (final IOException e) {
logger.error("Failed to close output stream: " + e.getMessage());
}
}
}
} | java | public void writeMapToXML(final Map<String, Set<String>> m) {
final File outputFile = new File(job.tempDir, FILE_NAME_PLUGIN_XML);
if (m == null) {
return;
}
final Properties prop = new Properties();
for (Map.Entry<String, Set<String>> entry : m.entrySet()) {
final String key = entry.getKey();
final String value = StringUtils.join(entry.getValue(),
COMMA);
prop.setProperty(key, value);
}
//File outputFile = new File(tempDir, filename);
final DocumentBuilder db = XMLUtils.getDocumentBuilder();
final Document doc = db.newDocument();
final Element properties = (Element) doc.appendChild(doc
.createElement("properties"));
final Set<Object> keys = prop.keySet();
for (Object key1 : keys) {
final String key = (String) key1;
final Element entry = (Element) properties.appendChild(doc
.createElement("entry"));
entry.setAttribute("key", key);
entry.appendChild(doc.createTextNode(prop.getProperty(key)));
}
final TransformerFactory tf = TransformerFactory.newInstance();
Transformer t;
try {
t = withLogger(tf.newTransformer(), logger);
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.METHOD, "xml");
t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
} catch (final TransformerConfigurationException tce) {
throw new RuntimeException(tce);
}
final DOMSource doms = new DOMSource(doc);
OutputStream out = null;
try {
out = new FileOutputStream(outputFile);
final StreamResult sr = new StreamResult(out);
t.transform(doms, sr);
} catch (final Exception e) {
logger.error("Failed to process map: " + e.getMessage(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (final IOException e) {
logger.error("Failed to close output stream: " + e.getMessage());
}
}
}
} | [
"public",
"void",
"writeMapToXML",
"(",
"final",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"m",
")",
"{",
"final",
"File",
"outputFile",
"=",
"new",
"File",
"(",
"job",
".",
"tempDir",
",",
"FILE_NAME_PLUGIN_XML",
")",
";",
"if",
"(",
... | Write map into xml file.
@param m map | [
"Write",
"map",
"into",
"xml",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/DelayConrefUtils.java#L229-L283 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java | AbstractBranchFilterModule.getSubjectScheme | SubjectScheme getSubjectScheme(final Element root) {
subjectSchemeReader.reset();
logger.debug("Loading subject schemes");
final List<Element> subjectSchemes = toList(root.getElementsByTagName("*"));
subjectSchemes.stream()
.filter(SUBJECTSCHEME_ENUMERATIONDEF::matches)
.forEach(enumerationDef -> {
final Element schemeRoot = ancestors(enumerationDef)
.filter(SUBMAP::matches)
.findFirst()
.orElse(root);
subjectSchemeReader.processEnumerationDef(schemeRoot, enumerationDef);
});
return subjectSchemeReader.getSubjectSchemeMap();
} | java | SubjectScheme getSubjectScheme(final Element root) {
subjectSchemeReader.reset();
logger.debug("Loading subject schemes");
final List<Element> subjectSchemes = toList(root.getElementsByTagName("*"));
subjectSchemes.stream()
.filter(SUBJECTSCHEME_ENUMERATIONDEF::matches)
.forEach(enumerationDef -> {
final Element schemeRoot = ancestors(enumerationDef)
.filter(SUBMAP::matches)
.findFirst()
.orElse(root);
subjectSchemeReader.processEnumerationDef(schemeRoot, enumerationDef);
});
return subjectSchemeReader.getSubjectSchemeMap();
} | [
"SubjectScheme",
"getSubjectScheme",
"(",
"final",
"Element",
"root",
")",
"{",
"subjectSchemeReader",
".",
"reset",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Loading subject schemes\"",
")",
";",
"final",
"List",
"<",
"Element",
">",
"subjectSchemes",
"=",... | Read subject scheme definitions. | [
"Read",
"subject",
"scheme",
"definitions",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java#L76-L90 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java | AbstractBranchFilterModule.combineFilterUtils | List<FilterUtils> combineFilterUtils(final Element topicref, final List<FilterUtils> filters,
final SubjectScheme subjectSchemeMap) {
return getChildElement(topicref, DITAVAREF_D_DITAVALREF)
.map(ditavalRef -> getFilterUtils(ditavalRef).refine(subjectSchemeMap))
.map(f -> {
final List<FilterUtils> fs = new ArrayList<>(filters.size() + 1);
fs.addAll(filters);
fs.add(f);
return fs;
})
.orElse(filters);
} | java | List<FilterUtils> combineFilterUtils(final Element topicref, final List<FilterUtils> filters,
final SubjectScheme subjectSchemeMap) {
return getChildElement(topicref, DITAVAREF_D_DITAVALREF)
.map(ditavalRef -> getFilterUtils(ditavalRef).refine(subjectSchemeMap))
.map(f -> {
final List<FilterUtils> fs = new ArrayList<>(filters.size() + 1);
fs.addAll(filters);
fs.add(f);
return fs;
})
.orElse(filters);
} | [
"List",
"<",
"FilterUtils",
">",
"combineFilterUtils",
"(",
"final",
"Element",
"topicref",
",",
"final",
"List",
"<",
"FilterUtils",
">",
"filters",
",",
"final",
"SubjectScheme",
"subjectSchemeMap",
")",
"{",
"return",
"getChildElement",
"(",
"topicref",
",",
... | Combine referenced DITAVAL to existing list and refine with subject scheme. | [
"Combine",
"referenced",
"DITAVAL",
"to",
"existing",
"list",
"and",
"refine",
"with",
"subject",
"scheme",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java#L95-L106 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java | AbstractBranchFilterModule.getFilterUtils | private FilterUtils getFilterUtils(final Element ditavalRef) {
final URI href = toURI(ditavalRef.getAttribute(ATTRIBUTE_NAME_HREF));
final URI tmp = currentFile.resolve(href);
final FileInfo fi = job.getFileInfo(tmp);
final URI ditaval = fi.src;
return filterCache.computeIfAbsent(ditaval, this::getFilterUtils);
} | java | private FilterUtils getFilterUtils(final Element ditavalRef) {
final URI href = toURI(ditavalRef.getAttribute(ATTRIBUTE_NAME_HREF));
final URI tmp = currentFile.resolve(href);
final FileInfo fi = job.getFileInfo(tmp);
final URI ditaval = fi.src;
return filterCache.computeIfAbsent(ditaval, this::getFilterUtils);
} | [
"private",
"FilterUtils",
"getFilterUtils",
"(",
"final",
"Element",
"ditavalRef",
")",
"{",
"final",
"URI",
"href",
"=",
"toURI",
"(",
"ditavalRef",
".",
"getAttribute",
"(",
"ATTRIBUTE_NAME_HREF",
")",
")",
";",
"final",
"URI",
"tmp",
"=",
"currentFile",
"."... | Read referenced DITAVAL and cache filter. | [
"Read",
"referenced",
"DITAVAL",
"and",
"cache",
"filter",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java#L111-L117 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java | AbstractBranchFilterModule.getFilterUtils | FilterUtils getFilterUtils(final URI ditaval) {
logger.info("Reading " + ditaval);
ditaValReader.filterReset();
ditaValReader.read(ditaval);
flagImageSet.addAll(ditaValReader.getImageList());
relFlagImagesSet.addAll(ditaValReader.getRelFlagImageList());
Map<FilterUtils.FilterKey, FilterUtils.Action> filterMap = ditaValReader.getFilterMap();
final FilterUtils f = new FilterUtils(filterMap, ditaValReader.getForegroundConflictColor(), ditaValReader.getBackgroundConflictColor());
f.setLogger(logger);
return f;
} | java | FilterUtils getFilterUtils(final URI ditaval) {
logger.info("Reading " + ditaval);
ditaValReader.filterReset();
ditaValReader.read(ditaval);
flagImageSet.addAll(ditaValReader.getImageList());
relFlagImagesSet.addAll(ditaValReader.getRelFlagImageList());
Map<FilterUtils.FilterKey, FilterUtils.Action> filterMap = ditaValReader.getFilterMap();
final FilterUtils f = new FilterUtils(filterMap, ditaValReader.getForegroundConflictColor(), ditaValReader.getBackgroundConflictColor());
f.setLogger(logger);
return f;
} | [
"FilterUtils",
"getFilterUtils",
"(",
"final",
"URI",
"ditaval",
")",
"{",
"logger",
".",
"info",
"(",
"\"Reading \"",
"+",
"ditaval",
")",
";",
"ditaValReader",
".",
"filterReset",
"(",
")",
";",
"ditaValReader",
".",
"read",
"(",
"ditaval",
")",
";",
"fl... | Read DITAVAL file. | [
"Read",
"DITAVAL",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/filter/AbstractBranchFilterModule.java#L125-L135 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/GrammarPoolManager.java | GrammarPoolManager.getGrammarPool | public static XMLGrammarPool getGrammarPool() {
XMLGrammarPool pool = grammarPool.get();
if (pool == null) {
try {
pool = new XMLGrammarPoolImplUtils();
grammarPool.set(pool);
} catch (final Exception e) {
System.out.println("Failed to create Xerces grammar pool for caching DTDs and schemas");
}
}
return pool;
} | java | public static XMLGrammarPool getGrammarPool() {
XMLGrammarPool pool = grammarPool.get();
if (pool == null) {
try {
pool = new XMLGrammarPoolImplUtils();
grammarPool.set(pool);
} catch (final Exception e) {
System.out.println("Failed to create Xerces grammar pool for caching DTDs and schemas");
}
}
return pool;
} | [
"public",
"static",
"XMLGrammarPool",
"getGrammarPool",
"(",
")",
"{",
"XMLGrammarPool",
"pool",
"=",
"grammarPool",
".",
"get",
"(",
")",
";",
"if",
"(",
"pool",
"==",
"null",
")",
"{",
"try",
"{",
"pool",
"=",
"new",
"XMLGrammarPoolImplUtils",
"(",
")",
... | Get grammar pool
@return grammar pool instance | [
"Get",
"grammar",
"pool"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GrammarPoolManager.java#L27-L38 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.correct | private static String correct(String url) {
// Fix for bad URLs containing UNC paths
// If the url is a UNC file url it must be specified like:
// file:////<PATH>...
if (url.startsWith("file://")
// A url like file:///<PATH> refers to a local file so it must not be
// modified.
&& !url.startsWith("file:///") && isWindows()) {
url = "file:////" + url.substring("file://".length());
}
String userInfo = getUserInfo(url);
String user = extractUser(userInfo);
String pass = extractPassword(userInfo);
String initialUrl = url;
// See if the url contains user and password. If so we remove them and
// attach them back after the correction is performed.
if (user != null || pass != null) {
URL urlWithoutUserInfo = clearUserInfo(url);
if (urlWithoutUserInfo != null) {
url = clearUserInfo(url).toString();
} else {
// Possible a malformed URL
}
}
// If there is a % that means the url was already corrected.
if (url.contains("%")) {
return initialUrl;
}
// Extract the reference (anchor) part from the url. The '#' char
// identifying the anchor must not be corrected.
String reference = null;
int refIndex = url.lastIndexOf('#');
if (refIndex != -1) {
reference = filepath2URI(url.substring(refIndex + 1));
url = url.substring(0, refIndex);
}
// Buffer where eventual query string will be processed.
StringBuilder queryBuffer = null;
int queryIndex = url.indexOf('?');
if (queryIndex != -1) {
// We have a query
String query = url.substring(queryIndex + 1);
url = url.substring(0, queryIndex);
queryBuffer = new StringBuilder(query.length());
// Tokenize by &
StringTokenizer st = new StringTokenizer(query, "&");
while (st.hasMoreElements()) {
String token = st.nextToken();
token = filepath2URI(token);
// Correct token
queryBuffer.append(token);
if (st.hasMoreElements()) {
queryBuffer.append("&");
}
}
}
String toReturn = filepath2URI(url);
if (queryBuffer != null) {
// Append to the end the corrected query.
toReturn += "?" + queryBuffer.toString();
}
if (reference != null) {
// Append the reference to the end the corrected query.
toReturn += "#" + reference;
}
// Re-attach the user and password.
if (user != null || pass != null) {
try {
if (user == null) {
user = "";
}
if (pass == null) {
pass = "";
}
// Re-attach user info.
toReturn = attachUserInfo(new URL(toReturn), user, pass.toCharArray())
.toString();
} catch (MalformedURLException e) {
// Shoudn't happen.
}
}
return toReturn;
} | java | private static String correct(String url) {
// Fix for bad URLs containing UNC paths
// If the url is a UNC file url it must be specified like:
// file:////<PATH>...
if (url.startsWith("file://")
// A url like file:///<PATH> refers to a local file so it must not be
// modified.
&& !url.startsWith("file:///") && isWindows()) {
url = "file:////" + url.substring("file://".length());
}
String userInfo = getUserInfo(url);
String user = extractUser(userInfo);
String pass = extractPassword(userInfo);
String initialUrl = url;
// See if the url contains user and password. If so we remove them and
// attach them back after the correction is performed.
if (user != null || pass != null) {
URL urlWithoutUserInfo = clearUserInfo(url);
if (urlWithoutUserInfo != null) {
url = clearUserInfo(url).toString();
} else {
// Possible a malformed URL
}
}
// If there is a % that means the url was already corrected.
if (url.contains("%")) {
return initialUrl;
}
// Extract the reference (anchor) part from the url. The '#' char
// identifying the anchor must not be corrected.
String reference = null;
int refIndex = url.lastIndexOf('#');
if (refIndex != -1) {
reference = filepath2URI(url.substring(refIndex + 1));
url = url.substring(0, refIndex);
}
// Buffer where eventual query string will be processed.
StringBuilder queryBuffer = null;
int queryIndex = url.indexOf('?');
if (queryIndex != -1) {
// We have a query
String query = url.substring(queryIndex + 1);
url = url.substring(0, queryIndex);
queryBuffer = new StringBuilder(query.length());
// Tokenize by &
StringTokenizer st = new StringTokenizer(query, "&");
while (st.hasMoreElements()) {
String token = st.nextToken();
token = filepath2URI(token);
// Correct token
queryBuffer.append(token);
if (st.hasMoreElements()) {
queryBuffer.append("&");
}
}
}
String toReturn = filepath2URI(url);
if (queryBuffer != null) {
// Append to the end the corrected query.
toReturn += "?" + queryBuffer.toString();
}
if (reference != null) {
// Append the reference to the end the corrected query.
toReturn += "#" + reference;
}
// Re-attach the user and password.
if (user != null || pass != null) {
try {
if (user == null) {
user = "";
}
if (pass == null) {
pass = "";
}
// Re-attach user info.
toReturn = attachUserInfo(new URL(toReturn), user, pass.toCharArray())
.toString();
} catch (MalformedURLException e) {
// Shoudn't happen.
}
}
return toReturn;
} | [
"private",
"static",
"String",
"correct",
"(",
"String",
"url",
")",
"{",
"// Fix for bad URLs containing UNC paths",
"// If the url is a UNC file url it must be specified like:",
"// file:////<PATH>...",
"if",
"(",
"url",
".",
"startsWith",
"(",
"\"file://\"",
")",
"// A url... | Method introduced to correct the URLs in the default machine encoding. This
was needed by the xsltproc, the catalogs URLs must be encoded in the
machine encoding.
@param url
The URL to be corrected. If it contains a % char, it means it
already was corrected, so it will be returned. Take care at
composing URLs from a corrected part and an uncorrected part.
Correcting the result will not work. Try to correct first the
relative part.
@return The corrected URL. | [
"Method",
"introduced",
"to",
"correct",
"the",
"URLs",
"in",
"the",
"default",
"machine",
"encoding",
".",
"This",
"was",
"needed",
"by",
"the",
"xsltproc",
"the",
"catalogs",
"URLs",
"must",
"be",
"encoded",
"in",
"the",
"machine",
"encoding",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L176-L268 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.getUserInfo | private static String getUserInfo(String url) {
String userInfo = null;
int startIndex = Integer.MIN_VALUE;
int nextSlashIndex = Integer.MIN_VALUE;
int endIndex = Integer.MIN_VALUE;
try {
// The user info start index should be the first index of "//".
startIndex = url.indexOf("//");
if (startIndex != -1) {
startIndex += 2;
// The user info should be found before the next '/' index.
nextSlashIndex = url.indexOf('/', startIndex);
if (nextSlashIndex == -1) {
nextSlashIndex = url.length();
}
// The user info ends at the last index of '@' from the previously
// computed subsequence.
endIndex = url.substring(startIndex, nextSlashIndex).lastIndexOf('@');
if (endIndex != -1) {
userInfo = url.substring(startIndex, startIndex + endIndex);
}
}
} catch (StringIndexOutOfBoundsException ex) {
System.err.println("String index out of bounds for:|" + url + "|");
System.err.println("Start index: " + startIndex);
System.err.println("Next slash index " + nextSlashIndex);
System.err.println("End index :" + endIndex);
System.err.println("User info :|" + userInfo + "|");
ex.printStackTrace();
}
return userInfo;
} | java | private static String getUserInfo(String url) {
String userInfo = null;
int startIndex = Integer.MIN_VALUE;
int nextSlashIndex = Integer.MIN_VALUE;
int endIndex = Integer.MIN_VALUE;
try {
// The user info start index should be the first index of "//".
startIndex = url.indexOf("//");
if (startIndex != -1) {
startIndex += 2;
// The user info should be found before the next '/' index.
nextSlashIndex = url.indexOf('/', startIndex);
if (nextSlashIndex == -1) {
nextSlashIndex = url.length();
}
// The user info ends at the last index of '@' from the previously
// computed subsequence.
endIndex = url.substring(startIndex, nextSlashIndex).lastIndexOf('@');
if (endIndex != -1) {
userInfo = url.substring(startIndex, startIndex + endIndex);
}
}
} catch (StringIndexOutOfBoundsException ex) {
System.err.println("String index out of bounds for:|" + url + "|");
System.err.println("Start index: " + startIndex);
System.err.println("Next slash index " + nextSlashIndex);
System.err.println("End index :" + endIndex);
System.err.println("User info :|" + userInfo + "|");
ex.printStackTrace();
}
return userInfo;
} | [
"private",
"static",
"String",
"getUserInfo",
"(",
"String",
"url",
")",
"{",
"String",
"userInfo",
"=",
"null",
";",
"int",
"startIndex",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"int",
"nextSlashIndex",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"int",
"endIndex... | Extract the user info from an URL.
@param url
The string representing the URL.
@return The userinfo or null if cannot extract it. | [
"Extract",
"the",
"user",
"info",
"from",
"an",
"URL",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L277-L308 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.extractUser | private static String extractUser(String userInfo) {
if (userInfo == null) {
return null;
}
int index = userInfo.lastIndexOf(':');
if (index == -1) {
return userInfo;
} else {
return userInfo.substring(0, index);
}
} | java | private static String extractUser(String userInfo) {
if (userInfo == null) {
return null;
}
int index = userInfo.lastIndexOf(':');
if (index == -1) {
return userInfo;
} else {
return userInfo.substring(0, index);
}
} | [
"private",
"static",
"String",
"extractUser",
"(",
"String",
"userInfo",
")",
"{",
"if",
"(",
"userInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"index",
"=",
"userInfo",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"in... | Gets the user from an userInfo string obtained from the starting URL. Used
only by the constructor.
@param userInfo
userInfo, taken from the URL.
@return The user. | [
"Gets",
"the",
"user",
"from",
"an",
"userInfo",
"string",
"obtained",
"from",
"the",
"starting",
"URL",
".",
"Used",
"only",
"by",
"the",
"constructor",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L318-L329 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.extractPassword | private static String extractPassword(String userInfo) {
if (userInfo == null) {
return null;
}
String password = "";
int index = userInfo.lastIndexOf(':');
if (index != -1 && index < userInfo.length() - 1) {
// Extract password from the URL.
password = userInfo.substring(index + 1);
}
return password;
} | java | private static String extractPassword(String userInfo) {
if (userInfo == null) {
return null;
}
String password = "";
int index = userInfo.lastIndexOf(':');
if (index != -1 && index < userInfo.length() - 1) {
// Extract password from the URL.
password = userInfo.substring(index + 1);
}
return password;
} | [
"private",
"static",
"String",
"extractPassword",
"(",
"String",
"userInfo",
")",
"{",
"if",
"(",
"userInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"password",
"=",
"\"\"",
";",
"int",
"index",
"=",
"userInfo",
".",
"lastIndexOf",
... | Gets the password from an user info string obtained from the starting URL.
@param userInfo
userInfo, taken from the URL. If no user info specified returning
null. If user info not null but no password after ":" then
returning empty, (we have a user so the default pass for him is
empty string). See bug 6086.
@return The password. | [
"Gets",
"the",
"password",
"from",
"an",
"user",
"info",
"string",
"obtained",
"from",
"the",
"starting",
"URL",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L342-L353 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.clearUserInfo | private static URL clearUserInfo(String systemID) {
try {
URL url = new URL(systemID);
// Do not clear user info on "file" urls 'cause on Windows the drive will
// have no ":"...
if (!"file".equals(url.getProtocol())) {
return attachUserInfo(url, null, null);
}
return url;
} catch (MalformedURLException e) {
return null;
}
} | java | private static URL clearUserInfo(String systemID) {
try {
URL url = new URL(systemID);
// Do not clear user info on "file" urls 'cause on Windows the drive will
// have no ":"...
if (!"file".equals(url.getProtocol())) {
return attachUserInfo(url, null, null);
}
return url;
} catch (MalformedURLException e) {
return null;
}
} | [
"private",
"static",
"URL",
"clearUserInfo",
"(",
"String",
"systemID",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"systemID",
")",
";",
"// Do not clear user info on \"file\" urls 'cause on Windows the drive will",
"// have no \":\"...",
"if",
"(",
"... | Clears the user info from an url.
@param systemID
the url to be cleaned.
@return the cleaned url, or null if the argument is not an URL. | [
"Clears",
"the",
"user",
"info",
"from",
"an",
"url",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L362-L374 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.attachUserInfo | private static URL attachUserInfo(URL url, String user, char[] password)
throws MalformedURLException {
if (url == null) {
return null;
}
if ((url.getAuthority() == null || "".equals(url.getAuthority()))
&& !"jar".equals(url.getProtocol())) {
return url;
}
StringBuilder buf = new StringBuilder();
String protocol = url.getProtocol();
if (protocol.equals("jar")) {
URL newURL = new URL(url.getPath());
newURL = attachUserInfo(newURL, user, password);
buf.append("jar:");
buf.append(newURL.toString());
} else {
password = correctPassword(password);
user = correctUser(user);
buf.append(protocol);
buf.append("://");
if (!"file".equals(protocol) && user != null && user.trim().length() > 0) {
buf.append(user);
if (password != null && password.length > 0) {
buf.append(":");
buf.append(password);
}
buf.append("@");
}
buf.append(url.getHost());
if (url.getPort() > 0) {
buf.append(":");
buf.append(url.getPort());
}
buf.append(url.getPath());
String query = url.getQuery();
if (query != null && query.trim().length() > 0) {
buf.append("?").append(query);
}
String ref = url.getRef();
if (ref != null && ref.trim().length() > 0) {
buf.append("#").append(ref);
}
}
return new URL(buf.toString());
} | java | private static URL attachUserInfo(URL url, String user, char[] password)
throws MalformedURLException {
if (url == null) {
return null;
}
if ((url.getAuthority() == null || "".equals(url.getAuthority()))
&& !"jar".equals(url.getProtocol())) {
return url;
}
StringBuilder buf = new StringBuilder();
String protocol = url.getProtocol();
if (protocol.equals("jar")) {
URL newURL = new URL(url.getPath());
newURL = attachUserInfo(newURL, user, password);
buf.append("jar:");
buf.append(newURL.toString());
} else {
password = correctPassword(password);
user = correctUser(user);
buf.append(protocol);
buf.append("://");
if (!"file".equals(protocol) && user != null && user.trim().length() > 0) {
buf.append(user);
if (password != null && password.length > 0) {
buf.append(":");
buf.append(password);
}
buf.append("@");
}
buf.append(url.getHost());
if (url.getPort() > 0) {
buf.append(":");
buf.append(url.getPort());
}
buf.append(url.getPath());
String query = url.getQuery();
if (query != null && query.trim().length() > 0) {
buf.append("?").append(query);
}
String ref = url.getRef();
if (ref != null && ref.trim().length() > 0) {
buf.append("#").append(ref);
}
}
return new URL(buf.toString());
} | [
"private",
"static",
"URL",
"attachUserInfo",
"(",
"URL",
"url",
",",
"String",
"user",
",",
"char",
"[",
"]",
"password",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"("... | Build the URL from the data obtained from the user.
@param url
The URL to be transformed.
@param user
The user name.
@param password
The password.
@return The URL with userInfo.
@exception MalformedURLException
Exception thrown if the URL is malformed. | [
"Build",
"the",
"URL",
"from",
"the",
"data",
"obtained",
"from",
"the",
"user",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L389-L439 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.correctUser | private static String correctUser(String user) {
if (user != null && user.trim().length() > 0
&& (false || user.indexOf('%') == -1)) {
String escaped = escapeSpecialAsciiAndNonAscii(user);
StringBuilder totalEscaped = new StringBuilder();
for (int i = 0; i < escaped.length(); i++) {
char ch = escaped.charAt(i);
if (ch == '@' || ch == '/' || ch == ':') {
totalEscaped.append('%')
.append(Integer.toHexString(ch).toUpperCase());
} else {
totalEscaped.append(ch);
}
}
user = totalEscaped.toString();
}
return user;
} | java | private static String correctUser(String user) {
if (user != null && user.trim().length() > 0
&& (false || user.indexOf('%') == -1)) {
String escaped = escapeSpecialAsciiAndNonAscii(user);
StringBuilder totalEscaped = new StringBuilder();
for (int i = 0; i < escaped.length(); i++) {
char ch = escaped.charAt(i);
if (ch == '@' || ch == '/' || ch == ':') {
totalEscaped.append('%')
.append(Integer.toHexString(ch).toUpperCase());
} else {
totalEscaped.append(ch);
}
}
user = totalEscaped.toString();
}
return user;
} | [
"private",
"static",
"String",
"correctUser",
"(",
"String",
"user",
")",
"{",
"if",
"(",
"user",
"!=",
"null",
"&&",
"user",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
"&&",
"(",
"false",
"||",
"user",
".",
"indexOf",
"(",
"'",
"'... | Escape the specified user.
@param user
The user name to correct.
@return The escaped user. | [
"Escape",
"the",
"specified",
"user",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L448-L465 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/Util.java | Util.correctPassword | private static char[] correctPassword(char[] password) {
if (password != null && new String(password).indexOf('%') == -1) {
String escaped = escapeSpecialAsciiAndNonAscii(new String(password));
StringBuilder totalEscaped = new StringBuilder();
for (int i = 0; i < escaped.length(); i++) {
char ch = escaped.charAt(i);
if (ch == '@' || ch == '/' || ch == ':') {
totalEscaped.append('%')
.append(Integer.toHexString(ch).toUpperCase());
} else {
totalEscaped.append(ch);
}
}
password = totalEscaped.toString().toCharArray();
}
return password;
} | java | private static char[] correctPassword(char[] password) {
if (password != null && new String(password).indexOf('%') == -1) {
String escaped = escapeSpecialAsciiAndNonAscii(new String(password));
StringBuilder totalEscaped = new StringBuilder();
for (int i = 0; i < escaped.length(); i++) {
char ch = escaped.charAt(i);
if (ch == '@' || ch == '/' || ch == ':') {
totalEscaped.append('%')
.append(Integer.toHexString(ch).toUpperCase());
} else {
totalEscaped.append(ch);
}
}
password = totalEscaped.toString().toCharArray();
}
return password;
} | [
"private",
"static",
"char",
"[",
"]",
"correctPassword",
"(",
"char",
"[",
"]",
"password",
")",
"{",
"if",
"(",
"password",
"!=",
"null",
"&&",
"new",
"String",
"(",
"password",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
... | Escape the specified password.
@param password
The password to be corrected.
@return The escaped password. | [
"Escape",
"the",
"specified",
"password",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/Util.java#L475-L491 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.read | private void read() throws IOException {
lastModified = jobFile.lastModified();
if (jobFile.exists()) {
try (final InputStream in = new FileInputStream(jobFile)) {
final XMLReader parser = XMLUtils.getXMLReader();
parser.setContentHandler(new JobHandler(prop, files));
parser.parse(new InputSource(in));
} catch (final SAXException e) {
throw new IOException("Failed to read job file: " + e.getMessage());
}
} else {
// defaults
prop.put(PROPERTY_GENERATE_COPY_OUTER, Generate.NOT_GENERATEOUTTER.toString());
prop.put(PROPERTY_ONLY_TOPIC_IN_MAP, Boolean.toString(false));
prop.put(PROPERTY_OUTER_CONTROL, OutterControl.WARN.toString());
}
} | java | private void read() throws IOException {
lastModified = jobFile.lastModified();
if (jobFile.exists()) {
try (final InputStream in = new FileInputStream(jobFile)) {
final XMLReader parser = XMLUtils.getXMLReader();
parser.setContentHandler(new JobHandler(prop, files));
parser.parse(new InputSource(in));
} catch (final SAXException e) {
throw new IOException("Failed to read job file: " + e.getMessage());
}
} else {
// defaults
prop.put(PROPERTY_GENERATE_COPY_OUTER, Generate.NOT_GENERATEOUTTER.toString());
prop.put(PROPERTY_ONLY_TOPIC_IN_MAP, Boolean.toString(false));
prop.put(PROPERTY_OUTER_CONTROL, OutterControl.WARN.toString());
}
} | [
"private",
"void",
"read",
"(",
")",
"throws",
"IOException",
"{",
"lastModified",
"=",
"jobFile",
".",
"lastModified",
"(",
")",
";",
"if",
"(",
"jobFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"(",
"final",
"InputStream",
"in",
"=",
"new",
"FileI... | Read temporary configuration files. If configuration files are not found,
assume an empty job object is being created.
@throws IOException if reading configuration files failed
@throws IllegalStateException if configuration files are missing | [
"Read",
"temporary",
"configuration",
"files",
".",
"If",
"configuration",
"files",
"are",
"not",
"found",
"assume",
"an",
"empty",
"job",
"object",
"is",
"being",
"created",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L168-L185 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getProperties | public Map<String, String> getProperties() {
final Map<String, String> res = new HashMap<>();
for (final Map.Entry<String, Object> e: prop.entrySet()) {
if (e.getValue() instanceof String) {
res.put(e.getKey(), (String) e.getValue());
}
}
return Collections.unmodifiableMap(res);
} | java | public Map<String, String> getProperties() {
final Map<String, String> res = new HashMap<>();
for (final Map.Entry<String, Object> e: prop.entrySet()) {
if (e.getValue() instanceof String) {
res.put(e.getKey(), (String) e.getValue());
}
}
return Collections.unmodifiableMap(res);
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getProperties",
"(",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"res",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
... | Get a map of string properties.
@return map of properties, may be an empty map | [
"Get",
"a",
"map",
"of",
"string",
"properties",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L426-L434 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.setProperty | public Object setProperty(final String key, final String value) {
return prop.put(key, value);
} | java | public Object setProperty(final String key, final String value) {
return prop.put(key, value);
} | [
"public",
"Object",
"setProperty",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"return",
"prop",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Set property value.
@param key property key
@param value property value
@return the previous value of the specified key in this property list, or {@code null} if it did not have one | [
"Set",
"property",
"value",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L443-L445 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getInputMap | public URI getInputMap() {
// return toURI(getProperty(INPUT_DITAMAP_URI));
return files.values().stream()
.filter(fi -> fi.isInput)
.map(fi -> getInputDir().relativize(fi.src))
.findAny()
.orElse(null);
} | java | public URI getInputMap() {
// return toURI(getProperty(INPUT_DITAMAP_URI));
return files.values().stream()
.filter(fi -> fi.isInput)
.map(fi -> getInputDir().relativize(fi.src))
.findAny()
.orElse(null);
} | [
"public",
"URI",
"getInputMap",
"(",
")",
"{",
"// return toURI(getProperty(INPUT_DITAMAP_URI));",
"return",
"files",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"fi",
"->",
"fi",
".",
"isInput",
")",
".",
"map",
"(",
"fi",
... | Get input file
@return input file path relative to input directory, {@code null} if not set | [
"Get",
"input",
"file"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L452-L459 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.setInputMap | public void setInputMap(final URI map) {
assert !map.isAbsolute();
setProperty(INPUT_DITAMAP_URI, map.toString());
// Deprecated since 2.2
setProperty(INPUT_DITAMAP, toFile(map).getPath());
} | java | public void setInputMap(final URI map) {
assert !map.isAbsolute();
setProperty(INPUT_DITAMAP_URI, map.toString());
// Deprecated since 2.2
setProperty(INPUT_DITAMAP, toFile(map).getPath());
} | [
"public",
"void",
"setInputMap",
"(",
"final",
"URI",
"map",
")",
"{",
"assert",
"!",
"map",
".",
"isAbsolute",
"(",
")",
";",
"setProperty",
"(",
"INPUT_DITAMAP_URI",
",",
"map",
".",
"toString",
"(",
")",
")",
";",
"// Deprecated since 2.2",
"setProperty",... | set input file
@param map input file path relative to input directory | [
"set",
"input",
"file"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L466-L471 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.setInputDir | public void setInputDir(final URI dir) {
assert dir.isAbsolute();
setProperty(INPUT_DIR_URI, dir.toString());
// Deprecated since 2.2
if (dir.getScheme().equals("file")) {
setProperty(INPUT_DIR, new File(dir).getAbsolutePath());
}
} | java | public void setInputDir(final URI dir) {
assert dir.isAbsolute();
setProperty(INPUT_DIR_URI, dir.toString());
// Deprecated since 2.2
if (dir.getScheme().equals("file")) {
setProperty(INPUT_DIR, new File(dir).getAbsolutePath());
}
} | [
"public",
"void",
"setInputDir",
"(",
"final",
"URI",
"dir",
")",
"{",
"assert",
"dir",
".",
"isAbsolute",
"(",
")",
";",
"setProperty",
"(",
"INPUT_DIR_URI",
",",
"dir",
".",
"toString",
"(",
")",
")",
";",
"// Deprecated since 2.2",
"if",
"(",
"dir",
"... | Set input directory
@param dir absolute input directory path | [
"Set",
"input",
"directory"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L486-L493 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getFileInfoMap | public Map<File, FileInfo> getFileInfoMap() {
final Map<File, FileInfo> ret = new HashMap<>();
for (final Map.Entry<URI, FileInfo> e: files.entrySet()) {
ret.put(e.getValue().file, e.getValue());
}
return Collections.unmodifiableMap(ret);
} | java | public Map<File, FileInfo> getFileInfoMap() {
final Map<File, FileInfo> ret = new HashMap<>();
for (final Map.Entry<URI, FileInfo> e: files.entrySet()) {
ret.put(e.getValue().file, e.getValue());
}
return Collections.unmodifiableMap(ret);
} | [
"public",
"Map",
"<",
"File",
",",
"FileInfo",
">",
"getFileInfoMap",
"(",
")",
"{",
"final",
"Map",
"<",
"File",
",",
"FileInfo",
">",
"ret",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"URI",
",",
... | Get all file info objects as a map
@return map of file info objects, where the key is the {@link FileInfo#file} value. May be empty | [
"Get",
"all",
"file",
"info",
"objects",
"as",
"a",
"map"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L500-L506 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getFileInfo | public Collection<FileInfo> getFileInfo(final Predicate<FileInfo> filter) {
return files.values().stream()
.filter(filter)
.collect(Collectors.toList());
} | java | public Collection<FileInfo> getFileInfo(final Predicate<FileInfo> filter) {
return files.values().stream()
.filter(filter)
.collect(Collectors.toList());
} | [
"public",
"Collection",
"<",
"FileInfo",
">",
"getFileInfo",
"(",
"final",
"Predicate",
"<",
"FileInfo",
">",
"filter",
")",
"{",
"return",
"files",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"filter",
")",
".",
"collect",
"(... | Get file info objects that pass the filter
@param filter filter file info object must pass
@return collection of file info objects that pass the filter, may be empty | [
"Get",
"file",
"info",
"objects",
"that",
"pass",
"the",
"filter"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L523-L527 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getFileInfo | public FileInfo getFileInfo(final URI file) {
if (file == null) {
return null;
} else if (files.containsKey(file)) {
return files.get(file);
} else if (file.isAbsolute() && file.toString().startsWith(tempDirURI.toString())) {
final URI relative = getRelativePath(jobFile.toURI(), file);
return files.get(relative);
} else {
return files.values().stream()
.filter(fileInfo -> file.equals(fileInfo.src) || file.equals(fileInfo.result))
.findFirst()
.orElse(null);
}
} | java | public FileInfo getFileInfo(final URI file) {
if (file == null) {
return null;
} else if (files.containsKey(file)) {
return files.get(file);
} else if (file.isAbsolute() && file.toString().startsWith(tempDirURI.toString())) {
final URI relative = getRelativePath(jobFile.toURI(), file);
return files.get(relative);
} else {
return files.values().stream()
.filter(fileInfo -> file.equals(fileInfo.src) || file.equals(fileInfo.result))
.findFirst()
.orElse(null);
}
} | [
"public",
"FileInfo",
"getFileInfo",
"(",
"final",
"URI",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"files",
".",
"containsKey",
"(",
"file",
")",
")",
"{",
"return",
"files",
".",
"... | Get file info object
@param file file URI
@return file info object, {@code null} if not found | [
"Get",
"file",
"info",
"object"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L535-L549 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getOrCreateFileInfo | public FileInfo getOrCreateFileInfo(final URI file) {
assert file.getFragment() == null;
URI f = file.normalize();
if (f.isAbsolute()) {
f = tempDirURI.relativize(f);
}
FileInfo i = getFileInfo(file);
if (i == null) {
i = new FileInfo(f);
add(i);
}
return i;
} | java | public FileInfo getOrCreateFileInfo(final URI file) {
assert file.getFragment() == null;
URI f = file.normalize();
if (f.isAbsolute()) {
f = tempDirURI.relativize(f);
}
FileInfo i = getFileInfo(file);
if (i == null) {
i = new FileInfo(f);
add(i);
}
return i;
} | [
"public",
"FileInfo",
"getOrCreateFileInfo",
"(",
"final",
"URI",
"file",
")",
"{",
"assert",
"file",
".",
"getFragment",
"(",
")",
"==",
"null",
";",
"URI",
"f",
"=",
"file",
".",
"normalize",
"(",
")",
";",
"if",
"(",
"f",
".",
"isAbsolute",
"(",
"... | Get or create FileInfo for given path.
@param file relative URI to temporary directory
@return created or existing file info object | [
"Get",
"or",
"create",
"FileInfo",
"for",
"given",
"path",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L556-L568 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.setOutterControl | public void setOutterControl(final String control) {
prop.put(PROPERTY_OUTER_CONTROL, OutterControl.valueOf(control.toUpperCase()).toString());
} | java | public void setOutterControl(final String control) {
prop.put(PROPERTY_OUTER_CONTROL, OutterControl.valueOf(control.toUpperCase()).toString());
} | [
"public",
"void",
"setOutterControl",
"(",
"final",
"String",
"control",
")",
"{",
"prop",
".",
"put",
"(",
"PROPERTY_OUTER_CONTROL",
",",
"OutterControl",
".",
"valueOf",
"(",
"control",
".",
"toUpperCase",
"(",
")",
")",
".",
"toString",
"(",
")",
")",
"... | Set the outercontrol.
@param control control | [
"Set",
"the",
"outercontrol",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L874-L876 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.crawlTopics | public boolean crawlTopics() {
if (prop.get(PROPERTY_LINK_CRAWLER) == null) {
return true;
}
return prop.get(PROPERTY_LINK_CRAWLER).toString().equals(ANT_INVOKER_EXT_PARAM_CRAWL_VALUE_TOPIC);
} | java | public boolean crawlTopics() {
if (prop.get(PROPERTY_LINK_CRAWLER) == null) {
return true;
}
return prop.get(PROPERTY_LINK_CRAWLER).toString().equals(ANT_INVOKER_EXT_PARAM_CRAWL_VALUE_TOPIC);
} | [
"public",
"boolean",
"crawlTopics",
"(",
")",
"{",
"if",
"(",
"prop",
".",
"get",
"(",
"PROPERTY_LINK_CRAWLER",
")",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"prop",
".",
"get",
"(",
"PROPERTY_LINK_CRAWLER",
")",
".",
"toString",
"("... | Retrieve the link crawling behaviour.
@return {@code true} if crawl links in topics, {@code false} if only crawl links in maps | [
"Retrieve",
"the",
"link",
"crawling",
"behaviour",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L890-L895 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getOutputDir | public File getOutputDir() {
if (prop.containsKey(PROPERTY_OUTPUT_DIR)) {
return new File(prop.get(PROPERTY_OUTPUT_DIR).toString());
}
return null;
} | java | public File getOutputDir() {
if (prop.containsKey(PROPERTY_OUTPUT_DIR)) {
return new File(prop.get(PROPERTY_OUTPUT_DIR).toString());
}
return null;
} | [
"public",
"File",
"getOutputDir",
"(",
")",
"{",
"if",
"(",
"prop",
".",
"containsKey",
"(",
"PROPERTY_OUTPUT_DIR",
")",
")",
"{",
"return",
"new",
"File",
"(",
"prop",
".",
"get",
"(",
"PROPERTY_OUTPUT_DIR",
")",
".",
"toString",
"(",
")",
")",
";",
"... | Get output dir.
@return absolute output dir | [
"Get",
"output",
"dir",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L939-L944 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getInputFile | public URI getInputFile() {
// if (prop.containsKey(PROPERTY_INPUT_MAP_URI)) {
// return toURI(prop.get(PROPERTY_INPUT_MAP_URI).toString());
// }
// return null;
return files.values().stream()
.filter(fi -> fi.isInput)
.map(fi -> fi.src)
.findAny()
.orElse(null);
} | java | public URI getInputFile() {
// if (prop.containsKey(PROPERTY_INPUT_MAP_URI)) {
// return toURI(prop.get(PROPERTY_INPUT_MAP_URI).toString());
// }
// return null;
return files.values().stream()
.filter(fi -> fi.isInput)
.map(fi -> fi.src)
.findAny()
.orElse(null);
} | [
"public",
"URI",
"getInputFile",
"(",
")",
"{",
"// if (prop.containsKey(PROPERTY_INPUT_MAP_URI)) {",
"// return toURI(prop.get(PROPERTY_INPUT_MAP_URI).toString());",
"// }",
"// return null;",
"return",
"files",
".",
"values",
"(",
")",
".",
"stream... | Get input file path.
@return absolute input file path, {@code null} if not set | [
"Get",
"input",
"file",
"path",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L958-L969 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.setInputFile | public void setInputFile(final URI inputFile) {
assert inputFile.isAbsolute();
prop.put(PROPERTY_INPUT_MAP_URI, inputFile.toString());
// Deprecated since 2.1
if (inputFile.getScheme().equals("file")) {
prop.put(PROPERTY_INPUT_MAP, new File(inputFile).getAbsolutePath());
}
} | java | public void setInputFile(final URI inputFile) {
assert inputFile.isAbsolute();
prop.put(PROPERTY_INPUT_MAP_URI, inputFile.toString());
// Deprecated since 2.1
if (inputFile.getScheme().equals("file")) {
prop.put(PROPERTY_INPUT_MAP, new File(inputFile).getAbsolutePath());
}
} | [
"public",
"void",
"setInputFile",
"(",
"final",
"URI",
"inputFile",
")",
"{",
"assert",
"inputFile",
".",
"isAbsolute",
"(",
")",
";",
"prop",
".",
"put",
"(",
"PROPERTY_INPUT_MAP_URI",
",",
"inputFile",
".",
"toString",
"(",
")",
")",
";",
"// Deprecated si... | Set input map path.
@param inputFile absolute input map path | [
"Set",
"input",
"map",
"path",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L975-L982 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/Job.java | Job.getTempFileNameScheme | public TempFileNameScheme getTempFileNameScheme() {
final TempFileNameScheme tempFileNameScheme;
try {
final String cls = Optional
.ofNullable(getProperty("temp-file-name-scheme"))
.orElse(configuration.get("temp-file-name-scheme"));
tempFileNameScheme = (GenMapAndTopicListModule.TempFileNameScheme) Class.forName(cls).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
tempFileNameScheme.setBaseDir(getInputDir());
return tempFileNameScheme;
} | java | public TempFileNameScheme getTempFileNameScheme() {
final TempFileNameScheme tempFileNameScheme;
try {
final String cls = Optional
.ofNullable(getProperty("temp-file-name-scheme"))
.orElse(configuration.get("temp-file-name-scheme"));
tempFileNameScheme = (GenMapAndTopicListModule.TempFileNameScheme) Class.forName(cls).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
tempFileNameScheme.setBaseDir(getInputDir());
return tempFileNameScheme;
} | [
"public",
"TempFileNameScheme",
"getTempFileNameScheme",
"(",
")",
"{",
"final",
"TempFileNameScheme",
"tempFileNameScheme",
";",
"try",
"{",
"final",
"String",
"cls",
"=",
"Optional",
".",
"ofNullable",
"(",
"getProperty",
"(",
"\"temp-file-name-scheme\"",
")",
")",
... | Get temporary file name generator. | [
"Get",
"temporary",
"file",
"name",
"generator",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/Job.java#L987-L999 | train |
dita-ot/dita-ot | src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/util/IndexStringProcessor.java | IndexStringProcessor.processIndexString | public static IndexEntry[] processIndexString(final String theIndexMarkerString, final List<Node> contents) {
final IndexEntryImpl indexEntry = createIndexEntry(theIndexMarkerString, contents, null, false);
final StringBuffer referenceIDBuf = new StringBuffer();
referenceIDBuf.append(indexEntry.getValue());
referenceIDBuf.append(VALUE_SEPARATOR);
indexEntry.addRefID(referenceIDBuf.toString());
return new IndexEntry[] { indexEntry };
} | java | public static IndexEntry[] processIndexString(final String theIndexMarkerString, final List<Node> contents) {
final IndexEntryImpl indexEntry = createIndexEntry(theIndexMarkerString, contents, null, false);
final StringBuffer referenceIDBuf = new StringBuffer();
referenceIDBuf.append(indexEntry.getValue());
referenceIDBuf.append(VALUE_SEPARATOR);
indexEntry.addRefID(referenceIDBuf.toString());
return new IndexEntry[] { indexEntry };
} | [
"public",
"static",
"IndexEntry",
"[",
"]",
"processIndexString",
"(",
"final",
"String",
"theIndexMarkerString",
",",
"final",
"List",
"<",
"Node",
">",
"contents",
")",
"{",
"final",
"IndexEntryImpl",
"indexEntry",
"=",
"createIndexEntry",
"(",
"theIndexMarkerStri... | Parse the index marker string and create IndexEntry object from one.
@param theIndexMarkerString index marker string
@param contents IndexPreprocessorTask instance
@return IndexEntry objects created from the index string | [
"Parse",
"the",
"index",
"marker",
"string",
"and",
"create",
"IndexEntry",
"object",
"from",
"one",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/util/IndexStringProcessor.java#L53-L61 | train |
dita-ot/dita-ot | src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/util/IndexStringProcessor.java | IndexStringProcessor.normalizeTextValue | public static String normalizeTextValue(final String theString) {
if (null != theString && theString.length() > 0) {
return theString.replaceAll("[\\s\\n]+", " ").trim();
}
return theString;
} | java | public static String normalizeTextValue(final String theString) {
if (null != theString && theString.length() > 0) {
return theString.replaceAll("[\\s\\n]+", " ").trim();
}
return theString;
} | [
"public",
"static",
"String",
"normalizeTextValue",
"(",
"final",
"String",
"theString",
")",
"{",
"if",
"(",
"null",
"!=",
"theString",
"&&",
"theString",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"theString",
".",
"replaceAll",
"(",
"\"[\\\\... | Method equals to the normalize-space xslt function
@param theString string to normalize
@return normalized string | [
"Method",
"equals",
"to",
"the",
"normalize",
"-",
"space",
"xslt",
"function"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/util/IndexStringProcessor.java#L70-L75 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java | ExtensibleAntInvoker.setTempdir | public void setTempdir(final File tempdir) {
this.tempDir = tempdir.getAbsoluteFile();
attrs.put(ANT_INVOKER_PARAM_TEMPDIR, tempdir.getAbsolutePath());
} | java | public void setTempdir(final File tempdir) {
this.tempDir = tempdir.getAbsoluteFile();
attrs.put(ANT_INVOKER_PARAM_TEMPDIR, tempdir.getAbsolutePath());
} | [
"public",
"void",
"setTempdir",
"(",
"final",
"File",
"tempdir",
")",
"{",
"this",
".",
"tempDir",
"=",
"tempdir",
".",
"getAbsoluteFile",
"(",
")",
";",
"attrs",
".",
"put",
"(",
"ANT_INVOKER_PARAM_TEMPDIR",
",",
"tempdir",
".",
"getAbsolutePath",
"(",
")",... | Set temporary directory.
@param tempdir temporary directory | [
"Set",
"temporary",
"directory",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java#L102-L105 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java | ExtensibleAntInvoker.execute | @Override
public void execute() throws BuildException {
initialize();
final Job job = getJob(tempDir, getProject());
try {
for (final ModuleElem m : modules) {
m.setProject(getProject());
m.setLocation(getLocation());
final PipelineHashIO pipelineInput = new PipelineHashIO();
for (final Map.Entry<String, String> e : attrs.entrySet()) {
pipelineInput.setAttribute(e.getKey(), e.getValue());
}
AbstractPipelineModule mod = getPipelineModule(m, pipelineInput);
long start = System.currentTimeMillis();
mod.setLogger(logger);
mod.setJob(job);
mod.execute(pipelineInput);
long end = System.currentTimeMillis();
logger.debug("{0} processing took {1} ms", mod.getClass().getSimpleName(), end - start);
}
} catch (final DITAOTException e) {
throw new BuildException("Failed to run pipeline: " + e.getMessage(), e);
}
} | java | @Override
public void execute() throws BuildException {
initialize();
final Job job = getJob(tempDir, getProject());
try {
for (final ModuleElem m : modules) {
m.setProject(getProject());
m.setLocation(getLocation());
final PipelineHashIO pipelineInput = new PipelineHashIO();
for (final Map.Entry<String, String> e : attrs.entrySet()) {
pipelineInput.setAttribute(e.getKey(), e.getValue());
}
AbstractPipelineModule mod = getPipelineModule(m, pipelineInput);
long start = System.currentTimeMillis();
mod.setLogger(logger);
mod.setJob(job);
mod.execute(pipelineInput);
long end = System.currentTimeMillis();
logger.debug("{0} processing took {1} ms", mod.getClass().getSimpleName(), end - start);
}
} catch (final DITAOTException e) {
throw new BuildException("Failed to run pipeline: " + e.getMessage(), e);
}
} | [
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"throws",
"BuildException",
"{",
"initialize",
"(",
")",
";",
"final",
"Job",
"job",
"=",
"getJob",
"(",
"tempDir",
",",
"getProject",
"(",
")",
")",
";",
"try",
"{",
"for",
"(",
"final",
"ModuleE... | Execution point of this invoker.
@throws BuildException exception | [
"Execution",
"point",
"of",
"this",
"invoker",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java#L165-L189 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java | ExtensibleAntInvoker.getJob | public static Job getJob(final File tempDir, final Project project) {
Job job = project.getReference(ANT_REFERENCE_JOB);
if (job != null && job.isStale()) {
project.log("Reload stale job configuration reference", Project.MSG_VERBOSE);
job = null;
}
if (job == null) {
try {
job = new Job(tempDir);
} catch (final IOException ioe) {
throw new BuildException(ioe);
}
project.addReference(ANT_REFERENCE_JOB, job);
}
return job;
} | java | public static Job getJob(final File tempDir, final Project project) {
Job job = project.getReference(ANT_REFERENCE_JOB);
if (job != null && job.isStale()) {
project.log("Reload stale job configuration reference", Project.MSG_VERBOSE);
job = null;
}
if (job == null) {
try {
job = new Job(tempDir);
} catch (final IOException ioe) {
throw new BuildException(ioe);
}
project.addReference(ANT_REFERENCE_JOB, job);
}
return job;
} | [
"public",
"static",
"Job",
"getJob",
"(",
"final",
"File",
"tempDir",
",",
"final",
"Project",
"project",
")",
"{",
"Job",
"job",
"=",
"project",
".",
"getReference",
"(",
"ANT_REFERENCE_JOB",
")",
";",
"if",
"(",
"job",
"!=",
"null",
"&&",
"job",
".",
... | Get job configuration from Ant project reference or create new.
@param tempDir configuration directory
@param project Ant project
@return job configuration | [
"Get",
"job",
"configuration",
"from",
"Ant",
"project",
"reference",
"or",
"create",
"new",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/ant/ExtensibleAntInvoker.java#L292-L307 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/log/MessageUtils.java | MessageUtils.getMessage | public static MessageBean getMessage(final String id, final String... params) {
if (!msgs.containsKey(id)) {
throw new IllegalArgumentException("Message for ID '" + id + "' not found");
}
final String msg = MessageFormat.format(msgs.getString(id), (Object[]) params);
MessageBean.Type type = null;
switch (id.substring(id.length() - 1)) {
case "F":
type = MessageBean.Type.FATAL;
break;
case "E":
type = MessageBean.Type.ERROR;
break;
case "W":
type = MessageBean.Type.WARN;
break;
case "I":
type = MessageBean.Type.INFO;
break;
case "D":
type = MessageBean.Type.DEBUG;
break;
}
return new MessageBean(id, type, msg, null);
} | java | public static MessageBean getMessage(final String id, final String... params) {
if (!msgs.containsKey(id)) {
throw new IllegalArgumentException("Message for ID '" + id + "' not found");
}
final String msg = MessageFormat.format(msgs.getString(id), (Object[]) params);
MessageBean.Type type = null;
switch (id.substring(id.length() - 1)) {
case "F":
type = MessageBean.Type.FATAL;
break;
case "E":
type = MessageBean.Type.ERROR;
break;
case "W":
type = MessageBean.Type.WARN;
break;
case "I":
type = MessageBean.Type.INFO;
break;
case "D":
type = MessageBean.Type.DEBUG;
break;
}
return new MessageBean(id, type, msg, null);
} | [
"public",
"static",
"MessageBean",
"getMessage",
"(",
"final",
"String",
"id",
",",
"final",
"String",
"...",
"params",
")",
"{",
"if",
"(",
"!",
"msgs",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Mess... | Get the message respond to the given id with all of the parameters
are replaced by those in the given 'prop', if no message found,
an empty message with this id will be returned.
@param id id
@param params message parameters
@return MessageBean | [
"Get",
"the",
"message",
"respond",
"to",
"the",
"given",
"id",
"with",
"all",
"of",
"the",
"parameters",
"are",
"replaced",
"by",
"those",
"in",
"the",
"given",
"prop",
"if",
"no",
"message",
"found",
"an",
"empty",
"message",
"with",
"this",
"id",
"wil... | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/log/MessageUtils.java#L57-L81 | train |
dita-ot/dita-ot | src/main/java/org/ditang/relaxng/defaults/RelaxDefaultsParserConfiguration.java | RelaxDefaultsParserConfiguration.insertRelaxDefaultsComponent | protected void insertRelaxDefaultsComponent() {
if (fRelaxDefaults == null) {
fRelaxDefaults = new RelaxNGDefaultsComponent(resolver);
addCommonComponent(fRelaxDefaults);
fRelaxDefaults.reset(this);
}
XMLDocumentSource prev = fLastComponent;
fLastComponent = fRelaxDefaults;
XMLDocumentHandler next = prev.getDocumentHandler();
prev.setDocumentHandler(fRelaxDefaults);
fRelaxDefaults.setDocumentSource(prev);
if (next != null) {
fRelaxDefaults.setDocumentHandler(next);
next.setDocumentSource(fRelaxDefaults);
}
} | java | protected void insertRelaxDefaultsComponent() {
if (fRelaxDefaults == null) {
fRelaxDefaults = new RelaxNGDefaultsComponent(resolver);
addCommonComponent(fRelaxDefaults);
fRelaxDefaults.reset(this);
}
XMLDocumentSource prev = fLastComponent;
fLastComponent = fRelaxDefaults;
XMLDocumentHandler next = prev.getDocumentHandler();
prev.setDocumentHandler(fRelaxDefaults);
fRelaxDefaults.setDocumentSource(prev);
if (next != null) {
fRelaxDefaults.setDocumentHandler(next);
next.setDocumentSource(fRelaxDefaults);
}
} | [
"protected",
"void",
"insertRelaxDefaultsComponent",
"(",
")",
"{",
"if",
"(",
"fRelaxDefaults",
"==",
"null",
")",
"{",
"fRelaxDefaults",
"=",
"new",
"RelaxNGDefaultsComponent",
"(",
"resolver",
")",
";",
"addCommonComponent",
"(",
"fRelaxDefaults",
")",
";",
"fR... | Insert the Relax NG defaults component | [
"Insert",
"the",
"Relax",
"NG",
"defaults",
"component"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxDefaultsParserConfiguration.java#L135-L151 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/IndexTermReader.java | IndexTermReader.reset | public void reset() {
targetFile = null;
title = null;
defaultTitle = null;
inTitleElement = false;
termStack.clear();
topicIdStack.clear();
indexTermSpecList.clear();
indexSeeSpecList.clear();
indexSeeAlsoSpecList.clear();
indexSortAsSpecList.clear();
topicSpecList.clear();
indexTermList.clear();
processRoleStack.clear();
processRoleLevel = 0;
titleMap.clear();
} | java | public void reset() {
targetFile = null;
title = null;
defaultTitle = null;
inTitleElement = false;
termStack.clear();
topicIdStack.clear();
indexTermSpecList.clear();
indexSeeSpecList.clear();
indexSeeAlsoSpecList.clear();
indexSortAsSpecList.clear();
topicSpecList.clear();
indexTermList.clear();
processRoleStack.clear();
processRoleLevel = 0;
titleMap.clear();
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"targetFile",
"=",
"null",
";",
"title",
"=",
"null",
";",
"defaultTitle",
"=",
"null",
";",
"inTitleElement",
"=",
"false",
";",
"termStack",
".",
"clear",
"(",
")",
";",
"topicIdStack",
".",
"clear",
"(",
")"... | Reset the reader. | [
"Reset",
"the",
"reader",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/IndexTermReader.java#L110-L126 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/IndexTermReader.java | IndexTermReader.genTarget | private IndexTermTarget genTarget() {
final IndexTermTarget target = new IndexTermTarget();
String fragment;
if (topicIdStack.peek() == null) {
fragment = null;
} else {
fragment = topicIdStack.peek();
}
if (title != null) {
target.setTargetName(title);
} else {
target.setTargetName(targetFile);
}
if (fragment != null) {
target.setTargetURI(setFragment(targetFile, fragment));
} else {
target.setTargetURI(targetFile);
}
return target;
} | java | private IndexTermTarget genTarget() {
final IndexTermTarget target = new IndexTermTarget();
String fragment;
if (topicIdStack.peek() == null) {
fragment = null;
} else {
fragment = topicIdStack.peek();
}
if (title != null) {
target.setTargetName(title);
} else {
target.setTargetName(targetFile);
}
if (fragment != null) {
target.setTargetURI(setFragment(targetFile, fragment));
} else {
target.setTargetURI(targetFile);
}
return target;
} | [
"private",
"IndexTermTarget",
"genTarget",
"(",
")",
"{",
"final",
"IndexTermTarget",
"target",
"=",
"new",
"IndexTermTarget",
"(",
")",
";",
"String",
"fragment",
";",
"if",
"(",
"topicIdStack",
".",
"peek",
"(",
")",
"==",
"null",
")",
"{",
"fragment",
"... | This method is used to create a target which refers to current topic.
@return instance of IndexTermTarget created | [
"This",
"method",
"is",
"used",
"to",
"create",
"a",
"target",
"which",
"refers",
"to",
"current",
"topic",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/IndexTermReader.java#L266-L287 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/IndexTermReader.java | IndexTermReader.updateIndexTermTargetName | private void updateIndexTermTargetName() {
if (defaultTitle == null) {
defaultTitle = targetFile;
}
for (final IndexTerm indexterm : indexTermList) {
updateIndexTermTargetName(indexterm);
}
} | java | private void updateIndexTermTargetName() {
if (defaultTitle == null) {
defaultTitle = targetFile;
}
for (final IndexTerm indexterm : indexTermList) {
updateIndexTermTargetName(indexterm);
}
} | [
"private",
"void",
"updateIndexTermTargetName",
"(",
")",
"{",
"if",
"(",
"defaultTitle",
"==",
"null",
")",
"{",
"defaultTitle",
"=",
"targetFile",
";",
"}",
"for",
"(",
"final",
"IndexTerm",
"indexterm",
":",
"indexTermList",
")",
"{",
"updateIndexTermTargetNa... | Update the target name of constructed IndexTerm recursively | [
"Update",
"the",
"target",
"name",
"of",
"constructed",
"IndexTerm",
"recursively"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/IndexTermReader.java#L463-L470 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/IndexTermReader.java | IndexTermReader.updateIndexTermTargetName | private void updateIndexTermTargetName(final IndexTerm indexterm) {
final int targetSize = indexterm.getTargetList().size();
final int subtermSize = indexterm.getSubTerms().size();
for (int i = 0; i<targetSize; i++) {
final IndexTermTarget target = indexterm.getTargetList().get(i);
final String uri = target.getTargetURI();
final int indexOfSharp = uri.lastIndexOf(SHARP);
final String fragment = (indexOfSharp == -1 || uri.endsWith(SHARP))?
null:
uri.substring(indexOfSharp + 1);
if (fragment != null && titleMap.containsKey(fragment)) {
target.setTargetName(titleMap.get(fragment));
} else {
target.setTargetName(defaultTitle);
}
}
for (int i = 0; i<subtermSize; i++) {
final IndexTerm subterm = indexterm.getSubTerms().get(i);
updateIndexTermTargetName(subterm);
}
} | java | private void updateIndexTermTargetName(final IndexTerm indexterm) {
final int targetSize = indexterm.getTargetList().size();
final int subtermSize = indexterm.getSubTerms().size();
for (int i = 0; i<targetSize; i++) {
final IndexTermTarget target = indexterm.getTargetList().get(i);
final String uri = target.getTargetURI();
final int indexOfSharp = uri.lastIndexOf(SHARP);
final String fragment = (indexOfSharp == -1 || uri.endsWith(SHARP))?
null:
uri.substring(indexOfSharp + 1);
if (fragment != null && titleMap.containsKey(fragment)) {
target.setTargetName(titleMap.get(fragment));
} else {
target.setTargetName(defaultTitle);
}
}
for (int i = 0; i<subtermSize; i++) {
final IndexTerm subterm = indexterm.getSubTerms().get(i);
updateIndexTermTargetName(subterm);
}
} | [
"private",
"void",
"updateIndexTermTargetName",
"(",
"final",
"IndexTerm",
"indexterm",
")",
"{",
"final",
"int",
"targetSize",
"=",
"indexterm",
".",
"getTargetList",
"(",
")",
".",
"size",
"(",
")",
";",
"final",
"int",
"subtermSize",
"=",
"indexterm",
".",
... | Update the target name of each IndexTerm, recursively. | [
"Update",
"the",
"target",
"name",
"of",
"each",
"IndexTerm",
"recursively",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/IndexTermReader.java#L475-L497 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/IndexTermReader.java | IndexTermReader.trimSpaceAtStart | private static String trimSpaceAtStart(final String temp, final String termName) {
if (termName != null && termName.charAt(termName.length() - 1) == ' ') {
if (temp.charAt(0) == ' ') {
return temp.substring(1);
}
}
return temp;
} | java | private static String trimSpaceAtStart(final String temp, final String termName) {
if (termName != null && termName.charAt(termName.length() - 1) == ' ') {
if (temp.charAt(0) == ' ') {
return temp.substring(1);
}
}
return temp;
} | [
"private",
"static",
"String",
"trimSpaceAtStart",
"(",
"final",
"String",
"temp",
",",
"final",
"String",
"termName",
")",
"{",
"if",
"(",
"termName",
"!=",
"null",
"&&",
"termName",
".",
"charAt",
"(",
"termName",
".",
"length",
"(",
")",
"-",
"1",
")"... | Trim whitespace from start of the string. If last character of termName and
first character of temp is a space character, remove leading string from temp
@return trimmed temp value | [
"Trim",
"whitespace",
"from",
"start",
"of",
"the",
"string",
".",
"If",
"last",
"character",
"of",
"termName",
"and",
"first",
"character",
"of",
"temp",
"is",
"a",
"space",
"character",
"remove",
"leading",
"string",
"from",
"temp"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/IndexTermReader.java#L505-L512 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/ChunkModule.java | ChunkModule.execute | @Override
public AbstractPipelineOutput execute(final AbstractPipelineInput input) throws DITAOTException {
final String transtype = input.getAttribute(ANT_INVOKER_EXT_PARAM_TRANSTYPE);
// change to xml property
final ChunkMapReader mapReader = new ChunkMapReader();
mapReader.setLogger(logger);
mapReader.setJob(job);
mapReader.supportToNavigation(INDEX_TYPE_ECLIPSEHELP.equals(transtype));
if (input.getAttribute(ROOT_CHUNK_OVERRIDE) != null) {
mapReader.setRootChunkOverride(input.getAttribute(ROOT_CHUNK_OVERRIDE));
}
try {
final Job.FileInfo in = job.getFileInfo(fi -> fi.isInput).iterator().next();
final File mapFile = new File(job.tempDirURI.resolve(in.uri));
if (transtype.equals(INDEX_TYPE_ECLIPSEHELP) && isEclipseMap(mapFile.toURI())) {
for (final FileInfo f : job.getFileInfo()) {
if (ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
mapReader.read(new File(job.tempDir, f.file.getPath()).getAbsoluteFile());
}
}
} else {
mapReader.read(mapFile);
}
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
final Map<URI, URI> changeTable = mapReader.getChangeTable();
if (hasChanges(changeTable)) {
final Map<URI, URI> conflicTable = mapReader.getConflicTable();
updateList(changeTable, conflicTable, mapReader);
updateRefOfDita(changeTable, conflicTable);
}
return null;
} | java | @Override
public AbstractPipelineOutput execute(final AbstractPipelineInput input) throws DITAOTException {
final String transtype = input.getAttribute(ANT_INVOKER_EXT_PARAM_TRANSTYPE);
// change to xml property
final ChunkMapReader mapReader = new ChunkMapReader();
mapReader.setLogger(logger);
mapReader.setJob(job);
mapReader.supportToNavigation(INDEX_TYPE_ECLIPSEHELP.equals(transtype));
if (input.getAttribute(ROOT_CHUNK_OVERRIDE) != null) {
mapReader.setRootChunkOverride(input.getAttribute(ROOT_CHUNK_OVERRIDE));
}
try {
final Job.FileInfo in = job.getFileInfo(fi -> fi.isInput).iterator().next();
final File mapFile = new File(job.tempDirURI.resolve(in.uri));
if (transtype.equals(INDEX_TYPE_ECLIPSEHELP) && isEclipseMap(mapFile.toURI())) {
for (final FileInfo f : job.getFileInfo()) {
if (ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
mapReader.read(new File(job.tempDir, f.file.getPath()).getAbsoluteFile());
}
}
} else {
mapReader.read(mapFile);
}
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
final Map<URI, URI> changeTable = mapReader.getChangeTable();
if (hasChanges(changeTable)) {
final Map<URI, URI> conflicTable = mapReader.getConflicTable();
updateList(changeTable, conflicTable, mapReader);
updateRefOfDita(changeTable, conflicTable);
}
return null;
} | [
"@",
"Override",
"public",
"AbstractPipelineOutput",
"execute",
"(",
"final",
"AbstractPipelineInput",
"input",
")",
"throws",
"DITAOTException",
"{",
"final",
"String",
"transtype",
"=",
"input",
".",
"getAttribute",
"(",
"ANT_INVOKER_EXT_PARAM_TRANSTYPE",
")",
";",
... | Entry point of chunk module.
@param input Input parameters and resources.
@return null
@throws DITAOTException exception | [
"Entry",
"point",
"of",
"chunk",
"module",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/ChunkModule.java#L59-L97 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/ChunkModule.java | ChunkModule.hasChanges | private boolean hasChanges(final Map<URI, URI> changeTable) {
if (changeTable.isEmpty()) {
return false;
}
for (Map.Entry<URI, URI> e : changeTable.entrySet()) {
if (!e.getKey().equals(e.getValue())) {
return true;
}
}
return false;
} | java | private boolean hasChanges(final Map<URI, URI> changeTable) {
if (changeTable.isEmpty()) {
return false;
}
for (Map.Entry<URI, URI> e : changeTable.entrySet()) {
if (!e.getKey().equals(e.getValue())) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"hasChanges",
"(",
"final",
"Map",
"<",
"URI",
",",
"URI",
">",
"changeTable",
")",
"{",
"if",
"(",
"changeTable",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"URI",
"... | Test whether there are changes that require topic rewriting. | [
"Test",
"whether",
"there",
"are",
"changes",
"that",
"require",
"topic",
"rewriting",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/ChunkModule.java#L102-L112 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/ChunkModule.java | ChunkModule.isEclipseMap | private boolean isEclipseMap(final URI mapFile) throws DITAOTException {
final DocumentBuilder builder = getDocumentBuilder();
Document doc;
try {
doc = builder.parse(mapFile.toString());
} catch (final SAXException | IOException e) {
throw new DITAOTException("Failed to parse input map: " + e.getMessage(), e);
}
final Element root = doc.getDocumentElement();
return ECLIPSEMAP_PLUGIN.matches(root);
} | java | private boolean isEclipseMap(final URI mapFile) throws DITAOTException {
final DocumentBuilder builder = getDocumentBuilder();
Document doc;
try {
doc = builder.parse(mapFile.toString());
} catch (final SAXException | IOException e) {
throw new DITAOTException("Failed to parse input map: " + e.getMessage(), e);
}
final Element root = doc.getDocumentElement();
return ECLIPSEMAP_PLUGIN.matches(root);
} | [
"private",
"boolean",
"isEclipseMap",
"(",
"final",
"URI",
"mapFile",
")",
"throws",
"DITAOTException",
"{",
"final",
"DocumentBuilder",
"builder",
"=",
"getDocumentBuilder",
"(",
")",
";",
"Document",
"doc",
";",
"try",
"{",
"doc",
"=",
"builder",
".",
"parse... | Check whether ditamap is an Eclipse specialization.
@param mapFile ditamap file to test
@return {@code true} if Eclipse specialization, otherwise {@code false}
@throws DITAOTException if reading ditamap fails | [
"Check",
"whether",
"ditamap",
"is",
"an",
"Eclipse",
"specialization",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/ChunkModule.java#L121-L131 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/ChunkModule.java | ChunkModule.updateRefOfDita | private void updateRefOfDita(final Map<URI, URI> changeTable, final Map<URI, URI> conflictTable) {
final TopicRefWriter topicRefWriter = new TopicRefWriter();
topicRefWriter.setLogger(logger);
topicRefWriter.setJob(job);
topicRefWriter.setChangeTable(changeTable);
topicRefWriter.setup(conflictTable);
try {
for (final FileInfo f : job.getFileInfo()) {
if (ATTR_FORMAT_VALUE_DITA.equals(f.format) || ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
topicRefWriter.setFixpath(relativePath2fix.get(f.uri));
final File tmp = new File(job.tempDirURI.resolve(f.uri));
topicRefWriter.write(tmp);
}
}
} catch (final DITAOTException ex) {
logger.error(ex.getMessage(), ex);
}
} | java | private void updateRefOfDita(final Map<URI, URI> changeTable, final Map<URI, URI> conflictTable) {
final TopicRefWriter topicRefWriter = new TopicRefWriter();
topicRefWriter.setLogger(logger);
topicRefWriter.setJob(job);
topicRefWriter.setChangeTable(changeTable);
topicRefWriter.setup(conflictTable);
try {
for (final FileInfo f : job.getFileInfo()) {
if (ATTR_FORMAT_VALUE_DITA.equals(f.format) || ATTR_FORMAT_VALUE_DITAMAP.equals(f.format)) {
topicRefWriter.setFixpath(relativePath2fix.get(f.uri));
final File tmp = new File(job.tempDirURI.resolve(f.uri));
topicRefWriter.write(tmp);
}
}
} catch (final DITAOTException ex) {
logger.error(ex.getMessage(), ex);
}
} | [
"private",
"void",
"updateRefOfDita",
"(",
"final",
"Map",
"<",
"URI",
",",
"URI",
">",
"changeTable",
",",
"final",
"Map",
"<",
"URI",
",",
"URI",
">",
"conflictTable",
")",
"{",
"final",
"TopicRefWriter",
"topicRefWriter",
"=",
"new",
"TopicRefWriter",
"("... | Update href attributes in ditamap and topic files. | [
"Update",
"href",
"attributes",
"in",
"ditamap",
"and",
"topic",
"files",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/ChunkModule.java#L136-L154 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/index/IndexTermCollection.java | IndexTermCollection.addTerm | public void addTerm(final IndexTerm term) {
int i = 0;
final int termNum = termList.size();
for (; i < termNum; i++) {
final IndexTerm indexTerm = termList.get(i);
if (indexTerm.equals(term)) {
return;
}
// Add targets when same term name and same term key
if (indexTerm.getTermFullName().equals(term.getTermFullName())
&& indexTerm.getTermKey().equals(term.getTermKey())) {
indexTerm.addTargets(term.getTargetList());
indexTerm.addSubTerms(term.getSubTerms());
break;
}
}
if (i == termNum) {
termList.add(term);
}
} | java | public void addTerm(final IndexTerm term) {
int i = 0;
final int termNum = termList.size();
for (; i < termNum; i++) {
final IndexTerm indexTerm = termList.get(i);
if (indexTerm.equals(term)) {
return;
}
// Add targets when same term name and same term key
if (indexTerm.getTermFullName().equals(term.getTermFullName())
&& indexTerm.getTermKey().equals(term.getTermKey())) {
indexTerm.addTargets(term.getTargetList());
indexTerm.addSubTerms(term.getSubTerms());
break;
}
}
if (i == termNum) {
termList.add(term);
}
} | [
"public",
"void",
"addTerm",
"(",
"final",
"IndexTerm",
"term",
")",
"{",
"int",
"i",
"=",
"0",
";",
"final",
"int",
"termNum",
"=",
"termList",
".",
"size",
"(",
")",
";",
"for",
"(",
";",
"i",
"<",
"termNum",
";",
"i",
"++",
")",
"{",
"final",
... | All a new term into the collection.
@param term index term | [
"All",
"a",
"new",
"term",
"into",
"the",
"collection",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/index/IndexTermCollection.java#L99-L121 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/index/IndexTermCollection.java | IndexTermCollection.sort | public void sort() {
if (IndexTerm.getTermLocale() == null ||
IndexTerm.getTermLocale().getLanguage().trim().length() == 0) {
IndexTerm.setTermLocale(new Locale(LANGUAGE_EN,
COUNTRY_US));
}
/*
* Sort all the terms recursively
*/
for (final IndexTerm term : termList) {
term.sortSubTerms();
}
Collections.sort(termList);
} | java | public void sort() {
if (IndexTerm.getTermLocale() == null ||
IndexTerm.getTermLocale().getLanguage().trim().length() == 0) {
IndexTerm.setTermLocale(new Locale(LANGUAGE_EN,
COUNTRY_US));
}
/*
* Sort all the terms recursively
*/
for (final IndexTerm term : termList) {
term.sortSubTerms();
}
Collections.sort(termList);
} | [
"public",
"void",
"sort",
"(",
")",
"{",
"if",
"(",
"IndexTerm",
".",
"getTermLocale",
"(",
")",
"==",
"null",
"||",
"IndexTerm",
".",
"getTermLocale",
"(",
")",
".",
"getLanguage",
"(",
")",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0... | Sort term list extracted from dita files base on Locale. | [
"Sort",
"term",
"list",
"extracted",
"from",
"dita",
"files",
"base",
"on",
"Locale",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/index/IndexTermCollection.java#L135-L150 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/index/IndexTermCollection.java | IndexTermCollection.outputTerms | public void outputTerms() throws DITAOTException {
StringBuilder buff = new StringBuilder(outputFileRoot);
AbstractWriter abstractWriter = null;
if (indexClass != null && indexClass.length() > 0) {
//Instantiate the class value
Class<?> anIndexClass;
try {
anIndexClass = Class.forName( indexClass );
abstractWriter = (AbstractWriter) anIndexClass.newInstance();
final IDitaTranstypeIndexWriter indexWriter = (IDitaTranstypeIndexWriter) anIndexClass.newInstance();
//RFE 2987769 Eclipse index-see
try {
((AbstractExtendDitaWriter) abstractWriter).setPipelineHashIO(this.getPipelineHashIO());
} catch (final ClassCastException e) {
javaLogger.info(e.getMessage());
javaLogger.info(e.toString());
e.printStackTrace();
}
buff = new StringBuilder(indexWriter.getIndexFileName(outputFileRoot));
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
} else {
throw new IllegalArgumentException("Index writer class not defined");
}
//Even if there is no term in the list create an empty index file
//otherwise the compiler will report error.
abstractWriter.setLogger(javaLogger);
((IDitaTranstypeIndexWriter) abstractWriter).setTermList(this.getTermList());
abstractWriter.write(new File(buff.toString()));
} | java | public void outputTerms() throws DITAOTException {
StringBuilder buff = new StringBuilder(outputFileRoot);
AbstractWriter abstractWriter = null;
if (indexClass != null && indexClass.length() > 0) {
//Instantiate the class value
Class<?> anIndexClass;
try {
anIndexClass = Class.forName( indexClass );
abstractWriter = (AbstractWriter) anIndexClass.newInstance();
final IDitaTranstypeIndexWriter indexWriter = (IDitaTranstypeIndexWriter) anIndexClass.newInstance();
//RFE 2987769 Eclipse index-see
try {
((AbstractExtendDitaWriter) abstractWriter).setPipelineHashIO(this.getPipelineHashIO());
} catch (final ClassCastException e) {
javaLogger.info(e.getMessage());
javaLogger.info(e.toString());
e.printStackTrace();
}
buff = new StringBuilder(indexWriter.getIndexFileName(outputFileRoot));
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
} else {
throw new IllegalArgumentException("Index writer class not defined");
}
//Even if there is no term in the list create an empty index file
//otherwise the compiler will report error.
abstractWriter.setLogger(javaLogger);
((IDitaTranstypeIndexWriter) abstractWriter).setTermList(this.getTermList());
abstractWriter.write(new File(buff.toString()));
} | [
"public",
"void",
"outputTerms",
"(",
")",
"throws",
"DITAOTException",
"{",
"StringBuilder",
"buff",
"=",
"new",
"StringBuilder",
"(",
"outputFileRoot",
")",
";",
"AbstractWriter",
"abstractWriter",
"=",
"null",
";",
"if",
"(",
"indexClass",
"!=",
"null",
"&&",... | Output index terms into index file.
@throws DITAOTException exception | [
"Output",
"index",
"terms",
"into",
"index",
"file",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/index/IndexTermCollection.java#L157-L199 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractDitaMetaWriter.java | AbstractDitaMetaWriter.skipUnlockedNavtitle | boolean skipUnlockedNavtitle(final Element metadataContainer, final Element checkForNavtitle) {
if (!TOPIC_TITLEALTS.matches(metadataContainer) ||
!TOPIC_NAVTITLE.matches(checkForNavtitle)) {
return false;
} else if (checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE) == null) {
return false;
} else if (ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.matches(checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE).getValue())) {
return false;
}
return true;
} | java | boolean skipUnlockedNavtitle(final Element metadataContainer, final Element checkForNavtitle) {
if (!TOPIC_TITLEALTS.matches(metadataContainer) ||
!TOPIC_NAVTITLE.matches(checkForNavtitle)) {
return false;
} else if (checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE) == null) {
return false;
} else if (ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.matches(checkForNavtitle.getAttributeNodeNS(DITA_OT_NS, ATTRIBUTE_NAME_LOCKTITLE).getValue())) {
return false;
}
return true;
} | [
"boolean",
"skipUnlockedNavtitle",
"(",
"final",
"Element",
"metadataContainer",
",",
"final",
"Element",
"checkForNavtitle",
")",
"{",
"if",
"(",
"!",
"TOPIC_TITLEALTS",
".",
"matches",
"(",
"metadataContainer",
")",
"||",
"!",
"TOPIC_NAVTITLE",
".",
"matches",
"... | Check if an element is an unlocked navtitle, which should not be pushed into topics.
@param metadataContainer container element
@param checkForNavtitle title element | [
"Check",
"if",
"an",
"element",
"is",
"an",
"unlocked",
"navtitle",
"which",
"should",
"not",
"be",
"pushed",
"into",
"topics",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractDitaMetaWriter.java#L86-L96 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/writer/AbstractDitaMetaWriter.java | AbstractDitaMetaWriter.getNewChildren | private List<Element> getNewChildren(final DitaClass cls, final Document doc) {
final List<Element> res = new ArrayList<>();
if (metaTable.containsKey(cls.matcher)) {
metaTable.get(cls.matcher);
final NodeList list = metaTable.get(cls.matcher).getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node item = list.item(i);
res.add((Element) doc.importNode(item, true));
}
}
Collections.reverse(res);
return res;
} | java | private List<Element> getNewChildren(final DitaClass cls, final Document doc) {
final List<Element> res = new ArrayList<>();
if (metaTable.containsKey(cls.matcher)) {
metaTable.get(cls.matcher);
final NodeList list = metaTable.get(cls.matcher).getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node item = list.item(i);
res.add((Element) doc.importNode(item, true));
}
}
Collections.reverse(res);
return res;
} | [
"private",
"List",
"<",
"Element",
">",
"getNewChildren",
"(",
"final",
"DitaClass",
"cls",
",",
"final",
"Document",
"doc",
")",
"{",
"final",
"List",
"<",
"Element",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"metaTable",
".... | Get metadata elements to add to current document. Elements have been cloned and imported
into the current document.
@param cls element class of metadata elements
@param doc current document
@return list of metadata elements, may be empty | [
"Get",
"metadata",
"elements",
"to",
"add",
"to",
"current",
"document",
".",
"Elements",
"have",
"been",
"cloned",
"and",
"imported",
"into",
"the",
"current",
"document",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/AbstractDitaMetaWriter.java#L106-L118 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.createTopicStump | private void createTopicStump(final URI newFile) {
try (final OutputStream newFileWriter = new FileOutputStream(new File(newFile))) {
final XMLStreamWriter o = XMLOutputFactory.newInstance().createXMLStreamWriter(newFileWriter, UTF8);
o.writeStartDocument();
o.writeProcessingInstruction(PI_WORKDIR_TARGET, UNIX_SEPARATOR + new File(newFile.resolve(".")).getAbsolutePath());
o.writeProcessingInstruction(PI_WORKDIR_TARGET_URI, newFile.resolve(".").toString());
o.writeStartElement(ELEMENT_NAME_DITA);
o.writeEndElement();
o.writeEndDocument();
o.close();
newFileWriter.flush();
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
} | java | private void createTopicStump(final URI newFile) {
try (final OutputStream newFileWriter = new FileOutputStream(new File(newFile))) {
final XMLStreamWriter o = XMLOutputFactory.newInstance().createXMLStreamWriter(newFileWriter, UTF8);
o.writeStartDocument();
o.writeProcessingInstruction(PI_WORKDIR_TARGET, UNIX_SEPARATOR + new File(newFile.resolve(".")).getAbsolutePath());
o.writeProcessingInstruction(PI_WORKDIR_TARGET_URI, newFile.resolve(".").toString());
o.writeStartElement(ELEMENT_NAME_DITA);
o.writeEndElement();
o.writeEndDocument();
o.close();
newFileWriter.flush();
} catch (final RuntimeException e) {
throw e;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
} | [
"private",
"void",
"createTopicStump",
"(",
"final",
"URI",
"newFile",
")",
"{",
"try",
"(",
"final",
"OutputStream",
"newFileWriter",
"=",
"new",
"FileOutputStream",
"(",
"new",
"File",
"(",
"newFile",
")",
")",
")",
"{",
"final",
"XMLStreamWriter",
"o",
"=... | Create the new topic stump. | [
"Create",
"the",
"new",
"topic",
"stump",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L238-L254 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.readProcessingInstructions | private void readProcessingInstructions(final Document doc) {
final NodeList docNodes = doc.getChildNodes();
for (int i = 0; i < docNodes.getLength(); i++) {
final Node node = docNodes.item(i);
if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
final ProcessingInstruction pi = (ProcessingInstruction) node;
switch (pi.getNodeName()) {
case PI_WORKDIR_TARGET:
workdir = pi;
break;
case PI_WORKDIR_TARGET_URI:
workdirUrl = pi;
break;
case PI_PATH2PROJ_TARGET:
path2proj = pi;
break;
case PI_PATH2PROJ_TARGET_URI:
path2projUrl = pi;
break;
case PI_PATH2ROOTMAP_TARGET_URI:
path2rootmapUrl = pi;
break;
}
}
}
} | java | private void readProcessingInstructions(final Document doc) {
final NodeList docNodes = doc.getChildNodes();
for (int i = 0; i < docNodes.getLength(); i++) {
final Node node = docNodes.item(i);
if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
final ProcessingInstruction pi = (ProcessingInstruction) node;
switch (pi.getNodeName()) {
case PI_WORKDIR_TARGET:
workdir = pi;
break;
case PI_WORKDIR_TARGET_URI:
workdirUrl = pi;
break;
case PI_PATH2PROJ_TARGET:
path2proj = pi;
break;
case PI_PATH2PROJ_TARGET_URI:
path2projUrl = pi;
break;
case PI_PATH2ROOTMAP_TARGET_URI:
path2rootmapUrl = pi;
break;
}
}
}
} | [
"private",
"void",
"readProcessingInstructions",
"(",
"final",
"Document",
"doc",
")",
"{",
"final",
"NodeList",
"docNodes",
"=",
"doc",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"docNodes",
".",
"getLength",
"... | Read processing metadata from processing instructions. | [
"Read",
"processing",
"metadata",
"from",
"processing",
"instructions",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L259-L284 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.processNavitation | private void processNavitation(final Element topicref) {
// create new map's root element
final Element root = (Element) topicref.getOwnerDocument().getDocumentElement().cloneNode(false);
// create navref element
final Element navref = topicref.getOwnerDocument().createElement(MAP_NAVREF.localName);
final String newMapFile = chunkFilenameGenerator.generateFilename("MAPCHUNK", FILE_EXTENSION_DITAMAP);
navref.setAttribute(ATTRIBUTE_NAME_MAPREF, newMapFile);
navref.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_NAVREF.toString());
// replace topicref with navref
topicref.getParentNode().replaceChild(navref, topicref);
root.appendChild(topicref);
// generate new file
final URI navmap = currentFile.resolve(newMapFile);
changeTable.put(stripFragment(navmap), stripFragment(navmap));
outputMapFile(navmap, buildOutputDocument(root));
} | java | private void processNavitation(final Element topicref) {
// create new map's root element
final Element root = (Element) topicref.getOwnerDocument().getDocumentElement().cloneNode(false);
// create navref element
final Element navref = topicref.getOwnerDocument().createElement(MAP_NAVREF.localName);
final String newMapFile = chunkFilenameGenerator.generateFilename("MAPCHUNK", FILE_EXTENSION_DITAMAP);
navref.setAttribute(ATTRIBUTE_NAME_MAPREF, newMapFile);
navref.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_NAVREF.toString());
// replace topicref with navref
topicref.getParentNode().replaceChild(navref, topicref);
root.appendChild(topicref);
// generate new file
final URI navmap = currentFile.resolve(newMapFile);
changeTable.put(stripFragment(navmap), stripFragment(navmap));
outputMapFile(navmap, buildOutputDocument(root));
} | [
"private",
"void",
"processNavitation",
"(",
"final",
"Element",
"topicref",
")",
"{",
"// create new map's root element",
"final",
"Element",
"root",
"=",
"(",
"Element",
")",
"topicref",
".",
"getOwnerDocument",
"(",
")",
".",
"getDocumentElement",
"(",
")",
"."... | Create new map and refer to it with navref. | [
"Create",
"new",
"map",
"and",
"refer",
"to",
"it",
"with",
"navref",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L383-L398 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.generateStumpTopic | private void generateStumpTopic(final Element topicref) {
final URI result = getResultFile(topicref);
final URI temp = tempFileNameScheme.generateTempFileName(result);
final URI absTemp = job.tempDir.toURI().resolve(temp);
final String name = getBaseName(new File(result).getName());
String navtitle = getChildElementValueOfTopicmeta(topicref, TOPIC_NAVTITLE);
if (navtitle == null) {
navtitle = getValue(topicref, ATTRIBUTE_NAME_NAVTITLE);
}
final String shortDesc = getChildElementValueOfTopicmeta(topicref, MAP_SHORTDESC);
writeChunk(absTemp, name, navtitle, shortDesc);
// update current element's @href value
final URI relativePath = getRelativePath(currentFile.resolve(FILE_NAME_STUB_DITAMAP), absTemp);
topicref.setAttribute(ATTRIBUTE_NAME_HREF, relativePath.toString());
if (MAPGROUP_D_TOPICGROUP.matches(topicref)) {
topicref.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICREF.toString());
}
final URI relativeToBase = getRelativePath(job.tempDirURI.resolve("dummy"), absTemp);
final FileInfo fi = new FileInfo.Builder()
.uri(temp)
.result(result)
.format(ATTR_FORMAT_VALUE_DITA)
.build();
job.add(fi);
} | java | private void generateStumpTopic(final Element topicref) {
final URI result = getResultFile(topicref);
final URI temp = tempFileNameScheme.generateTempFileName(result);
final URI absTemp = job.tempDir.toURI().resolve(temp);
final String name = getBaseName(new File(result).getName());
String navtitle = getChildElementValueOfTopicmeta(topicref, TOPIC_NAVTITLE);
if (navtitle == null) {
navtitle = getValue(topicref, ATTRIBUTE_NAME_NAVTITLE);
}
final String shortDesc = getChildElementValueOfTopicmeta(topicref, MAP_SHORTDESC);
writeChunk(absTemp, name, navtitle, shortDesc);
// update current element's @href value
final URI relativePath = getRelativePath(currentFile.resolve(FILE_NAME_STUB_DITAMAP), absTemp);
topicref.setAttribute(ATTRIBUTE_NAME_HREF, relativePath.toString());
if (MAPGROUP_D_TOPICGROUP.matches(topicref)) {
topicref.setAttribute(ATTRIBUTE_NAME_CLASS, MAP_TOPICREF.toString());
}
final URI relativeToBase = getRelativePath(job.tempDirURI.resolve("dummy"), absTemp);
final FileInfo fi = new FileInfo.Builder()
.uri(temp)
.result(result)
.format(ATTR_FORMAT_VALUE_DITA)
.build();
job.add(fi);
} | [
"private",
"void",
"generateStumpTopic",
"(",
"final",
"Element",
"topicref",
")",
"{",
"final",
"URI",
"result",
"=",
"getResultFile",
"(",
"topicref",
")",
";",
"final",
"URI",
"temp",
"=",
"tempFileNameScheme",
".",
"generateTempFileName",
"(",
"result",
")",... | Generate stump topic for to-content content.
@param topicref topicref without href to generate stump topic for | [
"Generate",
"stump",
"topic",
"for",
"to",
"-",
"content",
"content",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L414-L442 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.createChildTopicrefStubs | private void createChildTopicrefStubs(final List<Element> topicrefs) {
if (!topicrefs.isEmpty()) {
for (final Element currentElem : topicrefs) {
final String href = getValue(currentElem, ATTRIBUTE_NAME_HREF);
final String chunk = getValue(currentElem,ATTRIBUTE_NAME_CHUNK);
if (href == null && chunk != null) {
generateStumpTopic(currentElem);
}
createChildTopicrefStubs(getChildElements(currentElem, MAP_TOPICREF));
}
}
} | java | private void createChildTopicrefStubs(final List<Element> topicrefs) {
if (!topicrefs.isEmpty()) {
for (final Element currentElem : topicrefs) {
final String href = getValue(currentElem, ATTRIBUTE_NAME_HREF);
final String chunk = getValue(currentElem,ATTRIBUTE_NAME_CHUNK);
if (href == null && chunk != null) {
generateStumpTopic(currentElem);
}
createChildTopicrefStubs(getChildElements(currentElem, MAP_TOPICREF));
}
}
} | [
"private",
"void",
"createChildTopicrefStubs",
"(",
"final",
"List",
"<",
"Element",
">",
"topicrefs",
")",
"{",
"if",
"(",
"!",
"topicrefs",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"final",
"Element",
"currentElem",
":",
"topicrefs",
")",
"{",
"... | Before combining topics in a branch, ensure any descendant topicref with @chunk and no @href has a stub | [
"Before",
"combining",
"topics",
"in",
"a",
"branch",
"ensure",
"any",
"descendant",
"topicref",
"with"
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L550-L561 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.getChangeTable | public Map<URI, URI> getChangeTable() {
for (final Map.Entry<URI, URI> e : changeTable.entrySet()) {
assert e.getKey().isAbsolute();
assert e.getValue().isAbsolute();
}
return Collections.unmodifiableMap(changeTable);
} | java | public Map<URI, URI> getChangeTable() {
for (final Map.Entry<URI, URI> e : changeTable.entrySet()) {
assert e.getKey().isAbsolute();
assert e.getValue().isAbsolute();
}
return Collections.unmodifiableMap(changeTable);
} | [
"public",
"Map",
"<",
"URI",
",",
"URI",
">",
"getChangeTable",
"(",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"URI",
",",
"URI",
">",
"e",
":",
"changeTable",
".",
"entrySet",
"(",
")",
")",
"{",
"assert",
"e",
".",
"getKey",
"(",... | Get changed files table.
@return map of changed files, absolute temporary files | [
"Get",
"changed",
"files",
"table",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L594-L600 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/reader/ChunkMapReader.java | ChunkMapReader.getConflicTable | public Map<URI, URI> getConflicTable() {
for (final Map.Entry<URI, URI> e : conflictTable.entrySet()) {
assert e.getKey().isAbsolute();
assert e.getValue().isAbsolute();
}
return conflictTable;
} | java | public Map<URI, URI> getConflicTable() {
for (final Map.Entry<URI, URI> e : conflictTable.entrySet()) {
assert e.getKey().isAbsolute();
assert e.getValue().isAbsolute();
}
return conflictTable;
} | [
"public",
"Map",
"<",
"URI",
",",
"URI",
">",
"getConflicTable",
"(",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"URI",
",",
"URI",
">",
"e",
":",
"conflictTable",
".",
"entrySet",
"(",
")",
")",
"{",
"assert",
"e",
".",
"getKey",
"... | get conflict table.
@return conflict table, absolute temporary files | [
"get",
"conflict",
"table",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/ChunkMapReader.java#L607-L613 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/platform/ImportAntAction.java | ImportAntAction.getResult | @Override
public void getResult(final ContentHandler buf) throws SAXException {
for (final Value value: valueSet) {
final String[] tokens = value.value.split("[/\\\\]", 2);
buf.startElement(NULL_NS_URI, "import", "import", XMLUtils.EMPTY_ATTRIBUTES);
buf.startElement(NULL_NS_URI, "fileset", "fileset", new AttributesBuilder()
.add("dir", tokens[0])
.add("includes", tokens[1])
.build());
buf.endElement(NULL_NS_URI, "fileset", "fileset");
buf.endElement(NULL_NS_URI, "import", "import");
}
} | java | @Override
public void getResult(final ContentHandler buf) throws SAXException {
for (final Value value: valueSet) {
final String[] tokens = value.value.split("[/\\\\]", 2);
buf.startElement(NULL_NS_URI, "import", "import", XMLUtils.EMPTY_ATTRIBUTES);
buf.startElement(NULL_NS_URI, "fileset", "fileset", new AttributesBuilder()
.add("dir", tokens[0])
.add("includes", tokens[1])
.build());
buf.endElement(NULL_NS_URI, "fileset", "fileset");
buf.endElement(NULL_NS_URI, "import", "import");
}
} | [
"@",
"Override",
"public",
"void",
"getResult",
"(",
"final",
"ContentHandler",
"buf",
")",
"throws",
"SAXException",
"{",
"for",
"(",
"final",
"Value",
"value",
":",
"valueSet",
")",
"{",
"final",
"String",
"[",
"]",
"tokens",
"=",
"value",
".",
"value",
... | Generate Ant import task. | [
"Generate",
"Ant",
"import",
"task",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/ImportAntAction.java#L28-L40 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/pipeline/PipelineHashIO.java | PipelineHashIO.setAttribute | @Override
public void setAttribute(final String name, final String value) {
hash.put(name, value);
} | java | @Override
public void setAttribute(final String name, final String value) {
hash.put(name, value);
} | [
"@",
"Override",
"public",
"void",
"setAttribute",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"hash",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Set the attribute vale with name into hash map.
@param name name
@param value value | [
"Set",
"the",
"attribute",
"vale",
"with",
"name",
"into",
"hash",
"map",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/pipeline/PipelineHashIO.java#L42-L45 | train |
dita-ot/dita-ot | src/main/java/org/dita/dost/pipeline/PipelineHashIO.java | PipelineHashIO.getAttribute | @Override
public String getAttribute(final String name) {
String value;
value = hash.get(name);
return value;
} | java | @Override
public String getAttribute(final String name) {
String value;
value = hash.get(name);
return value;
} | [
"@",
"Override",
"public",
"String",
"getAttribute",
"(",
"final",
"String",
"name",
")",
"{",
"String",
"value",
";",
"value",
"=",
"hash",
".",
"get",
"(",
"name",
")",
";",
"return",
"value",
";",
"}"
] | Get the attribute value according to its name.
@param name name
@return String value | [
"Get",
"the",
"attribute",
"value",
"according",
"to",
"its",
"name",
"."
] | ea776b3c60c03d9f033b6f7ea072349e49dbcdd2 | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/pipeline/PipelineHashIO.java#L53-L58 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.