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/module/KeyrefModule.java
KeyrefModule.walkMap
void walkMap(final Element elem, final KeyScope scope, final List<ResolveTask> res) { List<KeyScope> ss = Collections.singletonList(scope); if (elem.getAttributeNode(ATTRIBUTE_NAME_KEYSCOPE) != null) { ss = new ArrayList<>(); for (final String keyscope: elem.getAttribute(ATTRIBUTE_NAME_KEYSCOPE).trim().split("\\s+")) { final KeyScope s = scope.getChildScope(keyscope); assert s != null; ss.add(s); } } Attr hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_COPY_TO); if (hrefNode == null) { hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_HREF); } if (hrefNode == null && SUBMAP.matches(elem)) { hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_DITA_OT_ORIG_HREF); } final boolean isResourceOnly = isResourceOnly(elem); for (final KeyScope s: ss) { if (hrefNode != null) { final URI href = stripFragment(job.getInputMap().resolve(hrefNode.getValue())); final FileInfo fi = job.getFileInfo(href); if (fi != null && fi.hasKeyref) { final int count = usage.getOrDefault(fi.uri, 0); final Optional<ResolveTask> existing = res.stream().filter(rt -> rt.scope.equals(s) && rt.in.uri.equals(fi.uri)).findAny(); if (count != 0 && existing.isPresent()) { final ResolveTask resolveTask = existing.get(); if (resolveTask.out != null) { final URI value = tempFileNameScheme.generateTempFileName(resolveTask.out.result); hrefNode.setValue(value.toString()); } } else { final ResolveTask resolveTask = processTopic(fi, s, isResourceOnly); res.add(resolveTask); final Integer used = usage.get(fi.uri); if (used > 1) { final URI value = tempFileNameScheme.generateTempFileName(resolveTask.out.result); hrefNode.setValue(value.toString()); } } } } for (final Element child : getChildElements(elem, MAP_TOPICREF)) { walkMap(child, s, res); } } }
java
void walkMap(final Element elem, final KeyScope scope, final List<ResolveTask> res) { List<KeyScope> ss = Collections.singletonList(scope); if (elem.getAttributeNode(ATTRIBUTE_NAME_KEYSCOPE) != null) { ss = new ArrayList<>(); for (final String keyscope: elem.getAttribute(ATTRIBUTE_NAME_KEYSCOPE).trim().split("\\s+")) { final KeyScope s = scope.getChildScope(keyscope); assert s != null; ss.add(s); } } Attr hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_COPY_TO); if (hrefNode == null) { hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_HREF); } if (hrefNode == null && SUBMAP.matches(elem)) { hrefNode = elem.getAttributeNode(ATTRIBUTE_NAME_DITA_OT_ORIG_HREF); } final boolean isResourceOnly = isResourceOnly(elem); for (final KeyScope s: ss) { if (hrefNode != null) { final URI href = stripFragment(job.getInputMap().resolve(hrefNode.getValue())); final FileInfo fi = job.getFileInfo(href); if (fi != null && fi.hasKeyref) { final int count = usage.getOrDefault(fi.uri, 0); final Optional<ResolveTask> existing = res.stream().filter(rt -> rt.scope.equals(s) && rt.in.uri.equals(fi.uri)).findAny(); if (count != 0 && existing.isPresent()) { final ResolveTask resolveTask = existing.get(); if (resolveTask.out != null) { final URI value = tempFileNameScheme.generateTempFileName(resolveTask.out.result); hrefNode.setValue(value.toString()); } } else { final ResolveTask resolveTask = processTopic(fi, s, isResourceOnly); res.add(resolveTask); final Integer used = usage.get(fi.uri); if (used > 1) { final URI value = tempFileNameScheme.generateTempFileName(resolveTask.out.result); hrefNode.setValue(value.toString()); } } } } for (final Element child : getChildElements(elem, MAP_TOPICREF)) { walkMap(child, s, res); } } }
[ "void", "walkMap", "(", "final", "Element", "elem", ",", "final", "KeyScope", "scope", ",", "final", "List", "<", "ResolveTask", ">", "res", ")", "{", "List", "<", "KeyScope", ">", "ss", "=", "Collections", ".", "singletonList", "(", "scope", ")", ";", ...
Recursively walk map and process topics that have keyrefs.
[ "Recursively", "walk", "map", "and", "process", "topics", "that", "have", "keyrefs", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/KeyrefModule.java#L249-L295
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/KeyrefModule.java
KeyrefModule.processTopic
private ResolveTask processTopic(final FileInfo f, final KeyScope scope, final boolean isResourceOnly) { final int increment = isResourceOnly ? 0 : 1; final Integer used = usage.containsKey(f.uri) ? usage.get(f.uri) + increment : increment; usage.put(f.uri, used); if (used > 1) { final URI result = addSuffix(f.result, "-" + (used - 1)); final URI out = tempFileNameScheme.generateTempFileName(result); final FileInfo fo = new FileInfo.Builder(f) .uri(out) .result(result) .build(); // TODO: Should this be added when content is actually generated? job.add(fo); return new ResolveTask(scope, f, fo); } else { return new ResolveTask(scope, f, null); } }
java
private ResolveTask processTopic(final FileInfo f, final KeyScope scope, final boolean isResourceOnly) { final int increment = isResourceOnly ? 0 : 1; final Integer used = usage.containsKey(f.uri) ? usage.get(f.uri) + increment : increment; usage.put(f.uri, used); if (used > 1) { final URI result = addSuffix(f.result, "-" + (used - 1)); final URI out = tempFileNameScheme.generateTempFileName(result); final FileInfo fo = new FileInfo.Builder(f) .uri(out) .result(result) .build(); // TODO: Should this be added when content is actually generated? job.add(fo); return new ResolveTask(scope, f, fo); } else { return new ResolveTask(scope, f, null); } }
[ "private", "ResolveTask", "processTopic", "(", "final", "FileInfo", "f", ",", "final", "KeyScope", "scope", ",", "final", "boolean", "isResourceOnly", ")", "{", "final", "int", "increment", "=", "isResourceOnly", "?", "0", ":", "1", ";", "final", "Integer", ...
Determine how topic is processed for key reference processing. @return key reference processing
[ "Determine", "how", "topic", "is", "processed", "for", "key", "reference", "processing", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/KeyrefModule.java#L316-L334
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/KeyrefModule.java
KeyrefModule.processFile
private void processFile(final ResolveTask r) { final List<XMLFilter> filters = new ArrayList<>(); final ConkeyrefFilter conkeyrefFilter = new ConkeyrefFilter(); conkeyrefFilter.setLogger(logger); conkeyrefFilter.setJob(job); conkeyrefFilter.setKeyDefinitions(r.scope); conkeyrefFilter.setCurrentFile(job.tempDirURI.resolve(r.in.uri)); conkeyrefFilter.setDelayConrefUtils(delayConrefUtils); filters.add(conkeyrefFilter); filters.add(topicFragmentFilter); final KeyrefPaser parser = new KeyrefPaser(); parser.setLogger(logger); parser.setJob(job); parser.setKeyDefinition(r.scope); parser.setCurrentFile(job.tempDirURI.resolve(r.in.uri)); filters.add(parser); try { logger.debug("Using " + (r.scope.name != null ? r.scope.name + " scope" : "root scope")); if (r.out != null) { logger.info("Processing " + job.tempDirURI.resolve(r.in.uri) + " to " + job.tempDirURI.resolve(r.out.uri)); xmlUtils.transform(new File(job.tempDir, r.in.file.getPath()), new File(job.tempDir, r.out.file.getPath()), filters); } else { logger.info("Processing " + job.tempDirURI.resolve(r.in.uri)); xmlUtils.transform(new File(job.tempDir, r.in.file.getPath()), filters); } // validate resource-only list normalProcessingRole.addAll(parser.getNormalProcessingRoleTargets()); } catch (final DITAOTException e) { logger.error("Failed to process key references: " + e.getMessage(), e); } }
java
private void processFile(final ResolveTask r) { final List<XMLFilter> filters = new ArrayList<>(); final ConkeyrefFilter conkeyrefFilter = new ConkeyrefFilter(); conkeyrefFilter.setLogger(logger); conkeyrefFilter.setJob(job); conkeyrefFilter.setKeyDefinitions(r.scope); conkeyrefFilter.setCurrentFile(job.tempDirURI.resolve(r.in.uri)); conkeyrefFilter.setDelayConrefUtils(delayConrefUtils); filters.add(conkeyrefFilter); filters.add(topicFragmentFilter); final KeyrefPaser parser = new KeyrefPaser(); parser.setLogger(logger); parser.setJob(job); parser.setKeyDefinition(r.scope); parser.setCurrentFile(job.tempDirURI.resolve(r.in.uri)); filters.add(parser); try { logger.debug("Using " + (r.scope.name != null ? r.scope.name + " scope" : "root scope")); if (r.out != null) { logger.info("Processing " + job.tempDirURI.resolve(r.in.uri) + " to " + job.tempDirURI.resolve(r.out.uri)); xmlUtils.transform(new File(job.tempDir, r.in.file.getPath()), new File(job.tempDir, r.out.file.getPath()), filters); } else { logger.info("Processing " + job.tempDirURI.resolve(r.in.uri)); xmlUtils.transform(new File(job.tempDir, r.in.file.getPath()), filters); } // validate resource-only list normalProcessingRole.addAll(parser.getNormalProcessingRoleTargets()); } catch (final DITAOTException e) { logger.error("Failed to process key references: " + e.getMessage(), e); } }
[ "private", "void", "processFile", "(", "final", "ResolveTask", "r", ")", "{", "final", "List", "<", "XMLFilter", ">", "filters", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "ConkeyrefFilter", "conkeyrefFilter", "=", "new", "ConkeyrefFilter", "(", ...
Process key references in a topic. Topic is stored with a new name if it's been processed before.
[ "Process", "key", "references", "in", "a", "topic", ".", "Topic", "is", "stored", "with", "a", "new", "name", "if", "it", "s", "been", "processed", "before", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/KeyrefModule.java#L340-L377
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/KeyrefModule.java
KeyrefModule.writeKeyDefinition
private void writeKeyDefinition(final Map<String, KeyDef> keydefs) { try { KeyDef.writeKeydef(new File(job.tempDir, KEYDEF_LIST_FILE), keydefs.values()); } catch (final DITAOTException e) { logger.error("Failed to write key definition file: " + e.getMessage(), e); } }
java
private void writeKeyDefinition(final Map<String, KeyDef> keydefs) { try { KeyDef.writeKeydef(new File(job.tempDir, KEYDEF_LIST_FILE), keydefs.values()); } catch (final DITAOTException e) { logger.error("Failed to write key definition file: " + e.getMessage(), e); } }
[ "private", "void", "writeKeyDefinition", "(", "final", "Map", "<", "String", ",", "KeyDef", ">", "keydefs", ")", "{", "try", "{", "KeyDef", ".", "writeKeydef", "(", "new", "File", "(", "job", ".", "tempDir", ",", "KEYDEF_LIST_FILE", ")", ",", "keydefs", ...
Add key definition to job configuration @param keydefs key defintions to add
[ "Add", "key", "definition", "to", "job", "configuration" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/KeyrefModule.java#L384-L390
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/ArgumentParser.java
ArgumentParser.getPluginArguments
public synchronized Map<String, Argument> getPluginArguments() { if (PLUGIN_ARGUMENTS == null) { final List<Element> params = toList(Plugins.getPluginConfiguration().getElementsByTagName("param")); PLUGIN_ARGUMENTS = params.stream() .map(ArgumentParser::getArgument) .collect(Collectors.toMap( arg -> ("--" + arg.property), arg -> arg, ArgumentParser::mergeArguments)); } return PLUGIN_ARGUMENTS; }
java
public synchronized Map<String, Argument> getPluginArguments() { if (PLUGIN_ARGUMENTS == null) { final List<Element> params = toList(Plugins.getPluginConfiguration().getElementsByTagName("param")); PLUGIN_ARGUMENTS = params.stream() .map(ArgumentParser::getArgument) .collect(Collectors.toMap( arg -> ("--" + arg.property), arg -> arg, ArgumentParser::mergeArguments)); } return PLUGIN_ARGUMENTS; }
[ "public", "synchronized", "Map", "<", "String", ",", "Argument", ">", "getPluginArguments", "(", ")", "{", "if", "(", "PLUGIN_ARGUMENTS", "==", "null", ")", "{", "final", "List", "<", "Element", ">", "params", "=", "toList", "(", "Plugins", ".", "getPlugin...
Lazy load parameters
[ "Lazy", "load", "parameters" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/ArgumentParser.java#L84-L95
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/ArgumentParser.java
ArgumentParser.handleArgDefine
private Map<String, Object> handleArgDefine(final String arg, final Deque<String> args) { /* * Interestingly enough, we get to here when a user uses -Dname=value. * However, in some cases, the OS goes ahead and parses this out to args * {"-Dname", "value"} so instead of parsing on "=", we just make the * "-D" characters go away and skip one argument forward. * * I don't know how to predict when the JDK is going to help or not, so * we simply look for the equals sign. */ final Map.Entry<String, String> entry = parse(arg.substring(2), args); if (entry.getValue() == null) { throw new BuildException("Missing value for property " + entry.getKey()); } if (RESERVED_PROPERTIES.containsKey(entry.getKey())) { throw new BuildException("Property " + entry.getKey() + " cannot be set with -D, use " + RESERVED_PROPERTIES.get(entry.getKey()) + " instead"); } return ImmutableMap.of(entry.getKey(), entry.getValue()); }
java
private Map<String, Object> handleArgDefine(final String arg, final Deque<String> args) { /* * Interestingly enough, we get to here when a user uses -Dname=value. * However, in some cases, the OS goes ahead and parses this out to args * {"-Dname", "value"} so instead of parsing on "=", we just make the * "-D" characters go away and skip one argument forward. * * I don't know how to predict when the JDK is going to help or not, so * we simply look for the equals sign. */ final Map.Entry<String, String> entry = parse(arg.substring(2), args); if (entry.getValue() == null) { throw new BuildException("Missing value for property " + entry.getKey()); } if (RESERVED_PROPERTIES.containsKey(entry.getKey())) { throw new BuildException("Property " + entry.getKey() + " cannot be set with -D, use " + RESERVED_PROPERTIES.get(entry.getKey()) + " instead"); } return ImmutableMap.of(entry.getKey(), entry.getValue()); }
[ "private", "Map", "<", "String", ",", "Object", ">", "handleArgDefine", "(", "final", "String", "arg", ",", "final", "Deque", "<", "String", ">", "args", ")", "{", "/*\n * Interestingly enough, we get to here when a user uses -Dname=value.\n * However, in so...
Handler -D argument
[ "Handler", "-", "D", "argument" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/ArgumentParser.java#L451-L470
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/ArgumentParser.java
ArgumentParser.handleArgInput
private void handleArgInput(final String arg, final Deque<String> args, final Argument argument) { final Map.Entry<String, String> entry = parse(arg, args); if (entry.getValue() == null) { throw new BuildException("Missing value for input " + entry.getKey()); } inputs.add(argument.getValue((String) entry.getValue())); }
java
private void handleArgInput(final String arg, final Deque<String> args, final Argument argument) { final Map.Entry<String, String> entry = parse(arg, args); if (entry.getValue() == null) { throw new BuildException("Missing value for input " + entry.getKey()); } inputs.add(argument.getValue((String) entry.getValue())); }
[ "private", "void", "handleArgInput", "(", "final", "String", "arg", ",", "final", "Deque", "<", "String", ">", "args", ",", "final", "Argument", "argument", ")", "{", "final", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", "=", "parse",...
Handler input argument
[ "Handler", "input", "argument" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/ArgumentParser.java#L488-L494
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/ArgumentParser.java
ArgumentParser.handleParameterArg
private Map<String, Object> handleParameterArg(final String arg, final Deque<String> args, final Argument argument) { final Map.Entry<String, String> entry = parse(arg, args); if (entry.getValue() == null) { throw new BuildException("Missing value for property " + entry.getKey()); } return ImmutableMap.of(argument.property, argument.getValue(entry.getValue())); }
java
private Map<String, Object> handleParameterArg(final String arg, final Deque<String> args, final Argument argument) { final Map.Entry<String, String> entry = parse(arg, args); if (entry.getValue() == null) { throw new BuildException("Missing value for property " + entry.getKey()); } return ImmutableMap.of(argument.property, argument.getValue(entry.getValue())); }
[ "private", "Map", "<", "String", ",", "Object", ">", "handleParameterArg", "(", "final", "String", "arg", ",", "final", "Deque", "<", "String", ">", "args", ",", "final", "Argument", "argument", ")", "{", "final", "Map", ".", "Entry", "<", "String", ",",...
Handler parameter argument
[ "Handler", "parameter", "argument" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/ArgumentParser.java#L499-L505
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/ArgumentParser.java
ArgumentParser.getArgumentName
private String getArgumentName(final String arg) { int pos = arg.indexOf("="); if (pos == -1) { pos = arg.indexOf(":"); } return arg.substring(0, pos != -1 ? pos : arg.length()); }
java
private String getArgumentName(final String arg) { int pos = arg.indexOf("="); if (pos == -1) { pos = arg.indexOf(":"); } return arg.substring(0, pos != -1 ? pos : arg.length()); }
[ "private", "String", "getArgumentName", "(", "final", "String", "arg", ")", "{", "int", "pos", "=", "arg", ".", "indexOf", "(", "\"=\"", ")", ";", "if", "(", "pos", "==", "-", "1", ")", "{", "pos", "=", "arg", ".", "indexOf", "(", "\":\"", ")", "...
Get argument name
[ "Get", "argument", "name" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/ArgumentParser.java#L510-L516
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/ExportAnchorsFilter.java
ExportAnchorsFilter.setCurrentFile
public void setCurrentFile(final URI currentFile) { assert currentFile.isAbsolute(); super.setCurrentFile(currentFile); currentDir = currentFile.resolve("."); }
java
public void setCurrentFile(final URI currentFile) { assert currentFile.isAbsolute(); super.setCurrentFile(currentFile); currentDir = currentFile.resolve("."); }
[ "public", "void", "setCurrentFile", "(", "final", "URI", "currentFile", ")", "{", "assert", "currentFile", ".", "isAbsolute", "(", ")", ";", "super", ".", "setCurrentFile", "(", "currentFile", ")", ";", "currentDir", "=", "currentFile", ".", "resolve", "(", ...
Set current file absolute path @param currentFile absolute path to current file
[ "Set", "current", "file", "absolute", "path" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ExportAnchorsFilter.java#L68-L72
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/ExportAnchorsFilter.java
ExportAnchorsFilter.parseAttribute
private void parseAttribute(final Attributes atts) { final URI attrValue = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); if (attrValue == null) { return; } final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE); if (isExternal(attrValue, attrScope)) { return; } String attrFormat = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (attrFormat == null || ATTR_FORMAT_VALUE_DITA.equals(attrFormat)) { final File target = toFile(attrValue); topicHref = target.isAbsolute() ? attrValue : currentDir.resolve(attrValue); if (attrValue.getFragment() != null) { topicId = attrValue.getFragment(); } else { if (attrFormat == null || attrFormat.equals(ATTR_FORMAT_VALUE_DITA) || attrFormat.equals(ATTR_FORMAT_VALUE_DITAMAP)) { topicId = topicHref + QUESTION; } } } else { topicHref = null; topicId = null; } }
java
private void parseAttribute(final Attributes atts) { final URI attrValue = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); if (attrValue == null) { return; } final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE); if (isExternal(attrValue, attrScope)) { return; } String attrFormat = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (attrFormat == null || ATTR_FORMAT_VALUE_DITA.equals(attrFormat)) { final File target = toFile(attrValue); topicHref = target.isAbsolute() ? attrValue : currentDir.resolve(attrValue); if (attrValue.getFragment() != null) { topicId = attrValue.getFragment(); } else { if (attrFormat == null || attrFormat.equals(ATTR_FORMAT_VALUE_DITA) || attrFormat.equals(ATTR_FORMAT_VALUE_DITAMAP)) { topicId = topicHref + QUESTION; } } } else { topicHref = null; topicId = null; } }
[ "private", "void", "parseAttribute", "(", "final", "Attributes", "atts", ")", "{", "final", "URI", "attrValue", "=", "toURI", "(", "atts", ".", "getValue", "(", "ATTRIBUTE_NAME_HREF", ")", ")", ";", "if", "(", "attrValue", "==", "null", ")", "{", "return",...
Parse the href attribute for needed information. @param atts attributes to process
[ "Parse", "the", "href", "attribute", "for", "needed", "information", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ExportAnchorsFilter.java#L164-L191
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.processParseResult
private void processParseResult(final URI currentFile) { // Category non-copyto result and update uplevels accordingly for (final Reference file: listFilter.getNonCopytoResult()) { categorizeReferenceFile(file); updateUplevels(file.filename); } for (final Map.Entry<URI, URI> e : listFilter.getCopytoMap().entrySet()) { final URI source = e.getValue(); final URI target = e.getKey(); copyTo.put(target, source); updateUplevels(target); } schemeSet.addAll(listFilter.getSchemeRefSet()); // collect key definitions for (final Map.Entry<String, KeyDef> e: keydefFilter.getKeysDMap().entrySet()) { // key and value.keys will differ when keydef is a redirect to another keydef final String key = e.getKey(); final KeyDef value = e.getValue(); if (schemeSet.contains(currentFile)) { schemekeydefMap.put(key, new KeyDef(key, value.href, value.scope, value.format, currentFile, null)); } } hrefTargetSet.addAll(listFilter.getHrefTargets()); conrefTargetSet.addAll(listFilter.getConrefTargets()); nonConrefCopytoTargetSet.addAll(listFilter.getNonConrefCopytoTargets()); coderefTargetSet.addAll(listFilter.getCoderefTargets()); outDitaFilesSet.addAll(listFilter.getOutFilesSet()); // Generate topic-scheme dictionary final Set<URI> schemeSet = listFilter.getSchemeSet(); if (schemeSet != null && !schemeSet.isEmpty()) { Set<URI> children = schemeDictionary.get(currentFile); if (children == null) { children = new HashSet<>(); } children.addAll(schemeSet); schemeDictionary.put(currentFile, children); final Set<URI> hrfSet = listFilter.getHrefTargets(); for (final URI filename: hrfSet) { children = schemeDictionary.get(filename); if (children == null) { children = new HashSet<>(); } children.addAll(schemeSet); schemeDictionary.put(filename, children); } } }
java
private void processParseResult(final URI currentFile) { // Category non-copyto result and update uplevels accordingly for (final Reference file: listFilter.getNonCopytoResult()) { categorizeReferenceFile(file); updateUplevels(file.filename); } for (final Map.Entry<URI, URI> e : listFilter.getCopytoMap().entrySet()) { final URI source = e.getValue(); final URI target = e.getKey(); copyTo.put(target, source); updateUplevels(target); } schemeSet.addAll(listFilter.getSchemeRefSet()); // collect key definitions for (final Map.Entry<String, KeyDef> e: keydefFilter.getKeysDMap().entrySet()) { // key and value.keys will differ when keydef is a redirect to another keydef final String key = e.getKey(); final KeyDef value = e.getValue(); if (schemeSet.contains(currentFile)) { schemekeydefMap.put(key, new KeyDef(key, value.href, value.scope, value.format, currentFile, null)); } } hrefTargetSet.addAll(listFilter.getHrefTargets()); conrefTargetSet.addAll(listFilter.getConrefTargets()); nonConrefCopytoTargetSet.addAll(listFilter.getNonConrefCopytoTargets()); coderefTargetSet.addAll(listFilter.getCoderefTargets()); outDitaFilesSet.addAll(listFilter.getOutFilesSet()); // Generate topic-scheme dictionary final Set<URI> schemeSet = listFilter.getSchemeSet(); if (schemeSet != null && !schemeSet.isEmpty()) { Set<URI> children = schemeDictionary.get(currentFile); if (children == null) { children = new HashSet<>(); } children.addAll(schemeSet); schemeDictionary.put(currentFile, children); final Set<URI> hrfSet = listFilter.getHrefTargets(); for (final URI filename: hrfSet) { children = schemeDictionary.get(filename); if (children == null) { children = new HashSet<>(); } children.addAll(schemeSet); schemeDictionary.put(filename, children); } } }
[ "private", "void", "processParseResult", "(", "final", "URI", "currentFile", ")", "{", "// Category non-copyto result and update uplevels accordingly", "for", "(", "final", "Reference", "file", ":", "listFilter", ".", "getNonCopytoResult", "(", ")", ")", "{", "categoriz...
Process results from parsing a single topic or map @param currentFile absolute URI processes files
[ "Process", "results", "from", "parsing", "a", "single", "topic", "or", "map" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L459-L509
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.categorizeReferenceFile
private void categorizeReferenceFile(final Reference file) { // avoid files referred by coderef being added into wait list if (listFilter.getCoderefTargets().contains(file.filename)) { return; } if (isFormatDita(file.format) && listFilter.isDitaTopic() && !job.crawlTopics() && !listFilter.getConrefTargets().contains(file.filename)) { return; // Do not process topics linked from within topics } else if ((isFormatDita(file.format) || ATTR_FORMAT_VALUE_DITAMAP.equals(file.format))) { addToWaitList(file); } else if (ATTR_FORMAT_VALUE_IMAGE.equals(file.format)) { formatSet.add(file); if (!exists(file.filename)) { logger.warn(MessageUtils.getMessage("DOTX008E", file.filename.toString()).toString()); } } else if (ATTR_FORMAT_VALUE_DITAVAL.equals(file.format)) { formatSet.add(file); } else { htmlSet.put(file.format, file.filename); } }
java
private void categorizeReferenceFile(final Reference file) { // avoid files referred by coderef being added into wait list if (listFilter.getCoderefTargets().contains(file.filename)) { return; } if (isFormatDita(file.format) && listFilter.isDitaTopic() && !job.crawlTopics() && !listFilter.getConrefTargets().contains(file.filename)) { return; // Do not process topics linked from within topics } else if ((isFormatDita(file.format) || ATTR_FORMAT_VALUE_DITAMAP.equals(file.format))) { addToWaitList(file); } else if (ATTR_FORMAT_VALUE_IMAGE.equals(file.format)) { formatSet.add(file); if (!exists(file.filename)) { logger.warn(MessageUtils.getMessage("DOTX008E", file.filename.toString()).toString()); } } else if (ATTR_FORMAT_VALUE_DITAVAL.equals(file.format)) { formatSet.add(file); } else { htmlSet.put(file.format, file.filename); } }
[ "private", "void", "categorizeReferenceFile", "(", "final", "Reference", "file", ")", "{", "// avoid files referred by coderef being added into wait list", "if", "(", "listFilter", ".", "getCoderefTargets", "(", ")", ".", "contains", "(", "file", ".", "filename", ")", ...
Categorize file. @param file file system path with optional format
[ "Categorize", "file", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L556-L577
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.getLevelsPath
private String getLevelsPath(final URI rootTemp) { final int u = rootTemp.toString().split(URI_SEPARATOR).length - 1; if (u == 0) { return ""; } final StringBuilder buff = new StringBuilder(); for (int current = u; current > 0; current--) { buff.append("..").append(File.separator); } return buff.toString(); }
java
private String getLevelsPath(final URI rootTemp) { final int u = rootTemp.toString().split(URI_SEPARATOR).length - 1; if (u == 0) { return ""; } final StringBuilder buff = new StringBuilder(); for (int current = u; current > 0; current--) { buff.append("..").append(File.separator); } return buff.toString(); }
[ "private", "String", "getLevelsPath", "(", "final", "URI", "rootTemp", ")", "{", "final", "int", "u", "=", "rootTemp", ".", "toString", "(", ")", ".", "split", "(", "URI_SEPARATOR", ")", ".", "length", "-", "1", ";", "if", "(", "u", "==", "0", ")", ...
Get up-levels absolute path. @param rootTemp relative URI for temporary root file @return path to up-level, e.g. {@code ../../}, may be empty string
[ "Get", "up", "-", "levels", "absolute", "path", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L630-L640
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.filterConflictingCopyTo
private Map<URI, URI> filterConflictingCopyTo( final Map<URI, URI> copyTo, final Collection<FileInfo> fileInfos) { final Set<URI> fileinfoTargets = fileInfos.stream() .filter(fi -> fi.src.equals(fi.result)) .map(fi -> fi.result) .collect(Collectors.toSet()); return copyTo.entrySet().stream() .filter(e -> !fileinfoTargets.contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
java
private Map<URI, URI> filterConflictingCopyTo( final Map<URI, URI> copyTo, final Collection<FileInfo> fileInfos) { final Set<URI> fileinfoTargets = fileInfos.stream() .filter(fi -> fi.src.equals(fi.result)) .map(fi -> fi.result) .collect(Collectors.toSet()); return copyTo.entrySet().stream() .filter(e -> !fileinfoTargets.contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
[ "private", "Map", "<", "URI", ",", "URI", ">", "filterConflictingCopyTo", "(", "final", "Map", "<", "URI", ",", "URI", ">", "copyTo", ",", "final", "Collection", "<", "FileInfo", ">", "fileInfos", ")", "{", "final", "Set", "<", "URI", ">", "fileinfoTarge...
Filter copy-to where target is used directly.
[ "Filter", "copy", "-", "to", "where", "target", "is", "used", "directly", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L849-L857
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.writeListFile
private void writeListFile(final File inputfile, final String relativeRootFile) { try (Writer bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(inputfile)))) { bufferedWriter.write(relativeRootFile); bufferedWriter.flush(); } catch (final IOException e) { logger.error(e.getMessage(), e) ; } }
java
private void writeListFile(final File inputfile, final String relativeRootFile) { try (Writer bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(inputfile)))) { bufferedWriter.write(relativeRootFile); bufferedWriter.flush(); } catch (final IOException e) { logger.error(e.getMessage(), e) ; } }
[ "private", "void", "writeListFile", "(", "final", "File", "inputfile", ",", "final", "String", "relativeRootFile", ")", "{", "try", "(", "Writer", "bufferedWriter", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "("...
Write list file. @param inputfile output list file @param relativeRootFile list value
[ "Write", "list", "file", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L864-L871
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.getPrefix
private String getPrefix(final File relativeRootFile) { String res; final File p = relativeRootFile.getParentFile(); if (p != null) { res = p.toString() + File.separator; } else { res = ""; } return res; }
java
private String getPrefix(final File relativeRootFile) { String res; final File p = relativeRootFile.getParentFile(); if (p != null) { res = p.toString() + File.separator; } else { res = ""; } return res; }
[ "private", "String", "getPrefix", "(", "final", "File", "relativeRootFile", ")", "{", "String", "res", ";", "final", "File", "p", "=", "relativeRootFile", ".", "getParentFile", "(", ")", ";", "if", "(", "p", "!=", "null", ")", "{", "res", "=", "p", "."...
Prefix path. @param relativeRootFile relative path for root temporary file @return either an empty string or a path which ends in {@link java.io.File#separator File.separator}
[ "Prefix", "path", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L879-L888
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.addMapFilePrefix
private Map<URI, Set<URI>> addMapFilePrefix(final Map<URI, Set<URI>> map) { final Map<URI, Set<URI>> res = new HashMap<>(); for (final Map.Entry<URI, Set<URI>> e: map.entrySet()) { final URI key = e.getKey(); final Set<URI> newSet = new HashSet<>(e.getValue().size()); for (final URI file: e.getValue()) { newSet.add(tempFileNameScheme.generateTempFileName(file)); } res.put(key.equals(ROOT_URI) ? key : tempFileNameScheme.generateTempFileName(key), newSet); } return res; }
java
private Map<URI, Set<URI>> addMapFilePrefix(final Map<URI, Set<URI>> map) { final Map<URI, Set<URI>> res = new HashMap<>(); for (final Map.Entry<URI, Set<URI>> e: map.entrySet()) { final URI key = e.getKey(); final Set<URI> newSet = new HashSet<>(e.getValue().size()); for (final URI file: e.getValue()) { newSet.add(tempFileNameScheme.generateTempFileName(file)); } res.put(key.equals(ROOT_URI) ? key : tempFileNameScheme.generateTempFileName(key), newSet); } return res; }
[ "private", "Map", "<", "URI", ",", "Set", "<", "URI", ">", ">", "addMapFilePrefix", "(", "final", "Map", "<", "URI", ",", "Set", "<", "URI", ">", ">", "map", ")", "{", "final", "Map", "<", "URI", ",", "Set", "<", "URI", ">", ">", "res", "=", ...
Convert absolute paths to relative temporary directory paths @return map with relative keys and values
[ "Convert", "absolute", "paths", "to", "relative", "temporary", "directory", "paths" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L909-L920
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.addFilePrefix
private Map<URI, URI> addFilePrefix(final Map<URI, URI> set) { final Map<URI, URI> newSet = new HashMap<>(); for (final Map.Entry<URI, URI> file: set.entrySet()) { final URI key = tempFileNameScheme.generateTempFileName(file.getKey()); final URI value = tempFileNameScheme.generateTempFileName(file.getValue()); newSet.put(key, value); } return newSet; }
java
private Map<URI, URI> addFilePrefix(final Map<URI, URI> set) { final Map<URI, URI> newSet = new HashMap<>(); for (final Map.Entry<URI, URI> file: set.entrySet()) { final URI key = tempFileNameScheme.generateTempFileName(file.getKey()); final URI value = tempFileNameScheme.generateTempFileName(file.getValue()); newSet.put(key, value); } return newSet; }
[ "private", "Map", "<", "URI", ",", "URI", ">", "addFilePrefix", "(", "final", "Map", "<", "URI", ",", "URI", ">", "set", ")", "{", "final", "Map", "<", "URI", ",", "URI", ">", "newSet", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "f...
Add file prefix. For absolute paths the prefix is not added. @param set file paths @return file paths with prefix
[ "Add", "file", "prefix", ".", "For", "absolute", "paths", "the", "prefix", "is", "not", "added", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L928-L936
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java
GenMapAndTopicListModule.addFlagImagesSetToProperties
private void addFlagImagesSetToProperties(final Job prop, final Set<URI> set) { final Set<URI> newSet = new LinkedHashSet<>(128); for (final URI file: set) { // assert file.isAbsolute(); if (file.isAbsolute()) { // no need to append relative path before absolute paths newSet.add(file.normalize()); } else { // In ant, all the file separator should be slash, so we need to // replace all the back slash with slash. newSet.add(file.normalize()); } } // write list attribute to file final String fileKey = org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.substring(0, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.lastIndexOf("list")) + "file"; prop.setProperty(fileKey, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.substring(0, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.lastIndexOf("list")) + ".list"); final File list = new File(job.tempDir, prop.getProperty(fileKey)); try (Writer bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(list)))) { final Iterator<URI> it = newSet.iterator(); while (it.hasNext()) { bufferedWriter.write(it.next().getPath()); if (it.hasNext()) { bufferedWriter.write("\n"); } } bufferedWriter.flush(); } catch (final IOException e) { logger.error(e.getMessage(), e) ; } prop.setProperty(org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST, StringUtils.join(newSet, COMMA)); }
java
private void addFlagImagesSetToProperties(final Job prop, final Set<URI> set) { final Set<URI> newSet = new LinkedHashSet<>(128); for (final URI file: set) { // assert file.isAbsolute(); if (file.isAbsolute()) { // no need to append relative path before absolute paths newSet.add(file.normalize()); } else { // In ant, all the file separator should be slash, so we need to // replace all the back slash with slash. newSet.add(file.normalize()); } } // write list attribute to file final String fileKey = org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.substring(0, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.lastIndexOf("list")) + "file"; prop.setProperty(fileKey, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.substring(0, org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST.lastIndexOf("list")) + ".list"); final File list = new File(job.tempDir, prop.getProperty(fileKey)); try (Writer bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(list)))) { final Iterator<URI> it = newSet.iterator(); while (it.hasNext()) { bufferedWriter.write(it.next().getPath()); if (it.hasNext()) { bufferedWriter.write("\n"); } } bufferedWriter.flush(); } catch (final IOException e) { logger.error(e.getMessage(), e) ; } prop.setProperty(org.dita.dost.util.Constants.REL_FLAGIMAGE_LIST, StringUtils.join(newSet, COMMA)); }
[ "private", "void", "addFlagImagesSetToProperties", "(", "final", "Job", "prop", ",", "final", "Set", "<", "URI", ">", "set", ")", "{", "final", "Set", "<", "URI", ">", "newSet", "=", "new", "LinkedHashSet", "<>", "(", "128", ")", ";", "for", "(", "fina...
add FlagImangesSet to Properties, which needn't to change the dir level, just ouput to the ouput dir. @param prop job configuration @param set absolute flag image files
[ "add", "FlagImangesSet", "to", "Properties", "which", "needn", "t", "to", "change", "the", "dir", "level", "just", "ouput", "to", "the", "ouput", "dir", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/GenMapAndTopicListModule.java#L954-L986
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/SourceReaderModule.java
SourceReaderModule.getXmlReader
XMLReader getXmlReader(final String format) throws SAXException { if (format == null || format.equals(ATTR_FORMAT_VALUE_DITA)) { return reader; } for (final Map.Entry<String, String> e : parserMap.entrySet()) { if (format.equals(e.getKey())) { try { // XMLReaderFactory.createXMLReader cannot be used final XMLReader r = (XMLReader) Class.forName(e.getValue()).newInstance(); final Map<String, Boolean> features = parserFeatures.getOrDefault(e.getKey(), emptyMap()); for (final Map.Entry<String, Boolean> feature : features.entrySet()) { try { r.setFeature(feature.getKey(), feature.getValue()); } catch (final SAXNotRecognizedException ex) { // Not Xerces, ignore exception } } return r; } catch (final InstantiationException | ClassNotFoundException | IllegalAccessException ex) { throw new SAXException(ex); } } } return reader; }
java
XMLReader getXmlReader(final String format) throws SAXException { if (format == null || format.equals(ATTR_FORMAT_VALUE_DITA)) { return reader; } for (final Map.Entry<String, String> e : parserMap.entrySet()) { if (format.equals(e.getKey())) { try { // XMLReaderFactory.createXMLReader cannot be used final XMLReader r = (XMLReader) Class.forName(e.getValue()).newInstance(); final Map<String, Boolean> features = parserFeatures.getOrDefault(e.getKey(), emptyMap()); for (final Map.Entry<String, Boolean> feature : features.entrySet()) { try { r.setFeature(feature.getKey(), feature.getValue()); } catch (final SAXNotRecognizedException ex) { // Not Xerces, ignore exception } } return r; } catch (final InstantiationException | ClassNotFoundException | IllegalAccessException ex) { throw new SAXException(ex); } } } return reader; }
[ "XMLReader", "getXmlReader", "(", "final", "String", "format", ")", "throws", "SAXException", "{", "if", "(", "format", "==", "null", "||", "format", ".", "equals", "(", "ATTR_FORMAT_VALUE_DITA", ")", ")", "{", "return", "reader", ";", "}", "for", "(", "fi...
Get reader for input format @param format input document format @return reader for given format @throws SAXException if creating reader failed
[ "Get", "reader", "for", "input", "format" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/SourceReaderModule.java#L60-L84
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/SourceReaderModule.java
SourceReaderModule.initXmlReader
void initXmlReader() throws SAXException { if (parserMap.containsKey(ATTR_FORMAT_VALUE_DITA)) { reader = XMLReaderFactory.createXMLReader(parserMap.get(ATTR_FORMAT_VALUE_DITA)); final Map<String, Boolean> features = parserFeatures.getOrDefault(ATTR_FORMAT_VALUE_DITA, emptyMap()); for (final Map.Entry<String, Boolean> feature : features.entrySet()) { try { reader.setFeature(feature.getKey(), feature.getValue()); } catch (final SAXNotRecognizedException e) { // Not Xerces, ignore exception } } } else { reader = XMLUtils.getXMLReader(); } reader.setFeature(FEATURE_NAMESPACE_PREFIX, true); if (validate) { reader.setFeature(FEATURE_VALIDATION, true); try { reader.setFeature(FEATURE_VALIDATION_SCHEMA, true); } catch (final SAXNotRecognizedException e) { // Not Xerces, ignore exception } } if (gramcache) { final XMLGrammarPool grammarPool = GrammarPoolManager.getGrammarPool(); try { reader.setProperty(FEATURE_GRAMMAR_POOL, grammarPool); logger.info("Using Xerces grammar pool for DTD and schema caching."); } catch (final NoClassDefFoundError e) { logger.debug("Xerces not available, not using grammar caching"); } catch (final SAXNotRecognizedException | SAXNotSupportedException e) { logger.warn("Failed to set Xerces grammar pool for parser: " + e.getMessage()); } } CatalogUtils.setDitaDir(ditaDir); reader.setEntityResolver(CatalogUtils.getCatalogResolver()); }
java
void initXmlReader() throws SAXException { if (parserMap.containsKey(ATTR_FORMAT_VALUE_DITA)) { reader = XMLReaderFactory.createXMLReader(parserMap.get(ATTR_FORMAT_VALUE_DITA)); final Map<String, Boolean> features = parserFeatures.getOrDefault(ATTR_FORMAT_VALUE_DITA, emptyMap()); for (final Map.Entry<String, Boolean> feature : features.entrySet()) { try { reader.setFeature(feature.getKey(), feature.getValue()); } catch (final SAXNotRecognizedException e) { // Not Xerces, ignore exception } } } else { reader = XMLUtils.getXMLReader(); } reader.setFeature(FEATURE_NAMESPACE_PREFIX, true); if (validate) { reader.setFeature(FEATURE_VALIDATION, true); try { reader.setFeature(FEATURE_VALIDATION_SCHEMA, true); } catch (final SAXNotRecognizedException e) { // Not Xerces, ignore exception } } if (gramcache) { final XMLGrammarPool grammarPool = GrammarPoolManager.getGrammarPool(); try { reader.setProperty(FEATURE_GRAMMAR_POOL, grammarPool); logger.info("Using Xerces grammar pool for DTD and schema caching."); } catch (final NoClassDefFoundError e) { logger.debug("Xerces not available, not using grammar caching"); } catch (final SAXNotRecognizedException | SAXNotSupportedException e) { logger.warn("Failed to set Xerces grammar pool for parser: " + e.getMessage()); } } CatalogUtils.setDitaDir(ditaDir); reader.setEntityResolver(CatalogUtils.getCatalogResolver()); }
[ "void", "initXmlReader", "(", ")", "throws", "SAXException", "{", "if", "(", "parserMap", ".", "containsKey", "(", "ATTR_FORMAT_VALUE_DITA", ")", ")", "{", "reader", "=", "XMLReaderFactory", ".", "createXMLReader", "(", "parserMap", ".", "get", "(", "ATTR_FORMAT...
XML reader used for pipeline parsing DITA documents. @throws SAXException if parser configuration failed
[ "XML", "reader", "used", "for", "pipeline", "parsing", "DITA", "documents", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/SourceReaderModule.java#L91-L129
train
dita-ot/dita-ot
src/main/java/org/dita/dost/platform/PluginParser.java
PluginParser.migrate
private Element migrate(Element root) { if (root.getAttributeNode(PLUGIN_VERSION_ATTR) == null) { final List<Element> features = toList(root.getElementsByTagName(FEATURE_ELEM)); final String version = features.stream() .filter(elem -> elem.getAttribute(FEATURE_ID_ATTR).equals("package.version")) .findFirst() .map(elem -> elem.getAttribute(FEATURE_VALUE_ATTR)) .orElse("0.0.0"); root.setAttribute(PLUGIN_VERSION_ATTR, version); } return root; }
java
private Element migrate(Element root) { if (root.getAttributeNode(PLUGIN_VERSION_ATTR) == null) { final List<Element> features = toList(root.getElementsByTagName(FEATURE_ELEM)); final String version = features.stream() .filter(elem -> elem.getAttribute(FEATURE_ID_ATTR).equals("package.version")) .findFirst() .map(elem -> elem.getAttribute(FEATURE_VALUE_ATTR)) .orElse("0.0.0"); root.setAttribute(PLUGIN_VERSION_ATTR, version); } return root; }
[ "private", "Element", "migrate", "(", "Element", "root", ")", "{", "if", "(", "root", ".", "getAttributeNode", "(", "PLUGIN_VERSION_ATTR", ")", "==", "null", ")", "{", "final", "List", "<", "Element", ">", "features", "=", "toList", "(", "root", ".", "ge...
Migrate from deprecated plugin format to new format
[ "Migrate", "from", "deprecated", "plugin", "format", "to", "new", "format" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/PluginParser.java#L128-L139
train
dita-ot/dita-ot
src/main/java/org/dita/dost/platform/PluginParser.java
PluginParser.addExtensionPoint
private void addExtensionPoint(final Element elem) { final String id = elem.getAttribute(EXTENSION_POINT_ID_ATTR); if (id == null) { throw new IllegalArgumentException(EXTENSION_POINT_ID_ATTR + " attribute not set on extension-point"); } final String name = elem.getAttribute(EXTENSION_POINT_NAME_ATTR); features.addExtensionPoint(new ExtensionPoint(id, name, currentPlugin)); }
java
private void addExtensionPoint(final Element elem) { final String id = elem.getAttribute(EXTENSION_POINT_ID_ATTR); if (id == null) { throw new IllegalArgumentException(EXTENSION_POINT_ID_ATTR + " attribute not set on extension-point"); } final String name = elem.getAttribute(EXTENSION_POINT_NAME_ATTR); features.addExtensionPoint(new ExtensionPoint(id, name, currentPlugin)); }
[ "private", "void", "addExtensionPoint", "(", "final", "Element", "elem", ")", "{", "final", "String", "id", "=", "elem", ".", "getAttribute", "(", "EXTENSION_POINT_ID_ATTR", ")", ";", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentE...
Add extension point. @param elem extension point element attributes @throws IllegalArgumentException if extension ID is {@code null}
[ "Add", "extension", "point", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/PluginParser.java#L158-L165
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/DitaLinksWriter.java
DitaLinksWriter.domToSax
private void domToSax(final Node root) throws SAXException { try { final Result result = new SAXResult(new FilterHandler(getContentHandler())); final NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node links = rewriteLinks((Element) children.item(i)); final Source source = new DOMSource(links); saxToDomTransformer.transform(source, result); } } catch (TransformerException e) { throw new SAXException("Failed to serialize DOM node to SAX: " + e.getMessage(), e); } }
java
private void domToSax(final Node root) throws SAXException { try { final Result result = new SAXResult(new FilterHandler(getContentHandler())); final NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node links = rewriteLinks((Element) children.item(i)); final Source source = new DOMSource(links); saxToDomTransformer.transform(source, result); } } catch (TransformerException e) { throw new SAXException("Failed to serialize DOM node to SAX: " + e.getMessage(), e); } }
[ "private", "void", "domToSax", "(", "final", "Node", "root", ")", "throws", "SAXException", "{", "try", "{", "final", "Result", "result", "=", "new", "SAXResult", "(", "new", "FilterHandler", "(", "getContentHandler", "(", ")", ")", ")", ";", "final", "Nod...
DOM to SAX conversion methods
[ "DOM", "to", "SAX", "conversion", "methods" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/DitaLinksWriter.java#L161-L173
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java
RelaxNGDefaultsComponent.onStartElement
private void onStartElement(QName name, XMLAttributes atts) { if (detecting) { detecting = false; loadDefaults(); } if (defaults != null) { checkAndAddDefaults(name, atts); } }
java
private void onStartElement(QName name, XMLAttributes atts) { if (detecting) { detecting = false; loadDefaults(); } if (defaults != null) { checkAndAddDefaults(name, atts); } }
[ "private", "void", "onStartElement", "(", "QName", "name", ",", "XMLAttributes", "atts", ")", "{", "if", "(", "detecting", ")", "{", "detecting", "=", "false", ";", "loadDefaults", "(", ")", ";", "}", "if", "(", "defaults", "!=", "null", ")", "{", "che...
On start element @param name The element name @param atts The attributes
[ "On", "start", "element" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java#L220-L228
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java
RelaxNGDefaultsComponent.nullOrValue
private boolean nullOrValue(String test, String value) { if (test == null) return true; if (test.equals(value)) return true; return false; }
java
private boolean nullOrValue(String test, String value) { if (test == null) return true; if (test.equals(value)) return true; return false; }
[ "private", "boolean", "nullOrValue", "(", "String", "test", ",", "String", "value", ")", "{", "if", "(", "test", "==", "null", ")", "return", "true", ";", "if", "(", "test", ".", "equals", "(", "value", ")", ")", "return", "true", ";", "return", "fal...
Test if a string is either null or equal to a certain value @param test The string to test @param value The value to compare to @return <code>true</code> if a string is either null or equal to a certain value
[ "Test", "if", "a", "string", "is", "either", "null", "or", "equal", "to", "a", "certain", "value" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java#L489-L495
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java
RelaxNGDefaultsComponent.getFromPIDataPseudoAttribute
private String getFromPIDataPseudoAttribute(String data, String name, boolean unescapeValue) { int pos = 0; while (pos <= data.length() - 4) { // minimum length of x="" int nextQuote = -1; for (int q = pos; q < data.length(); q++) { if (data.charAt(q) == '"' || data.charAt(q) == '\'') { nextQuote = q; break; } } if (nextQuote < 0) { return null; // if (nextQuote+1 == name.length()) return null; } int closingQuote = data.indexOf(data.charAt(nextQuote), nextQuote + 1); if (closingQuote < 0) { return null; } int nextName = data.indexOf(name, pos); if (nextName < 0) { return null; } if (nextName < nextQuote) { // check only spaces and equal signs between the name and the quote boolean found = true; for (int s = nextName + name.length(); s < nextQuote; s++) { char c = data.charAt(s); if (!Character.isWhitespace(c) && c != '=') { found = false; break; } } if (found) { String val = data.substring(nextQuote + 1, closingQuote); return unescapeValue ? unescape(val) : val; } } pos = closingQuote + 1; } return null; }
java
private String getFromPIDataPseudoAttribute(String data, String name, boolean unescapeValue) { int pos = 0; while (pos <= data.length() - 4) { // minimum length of x="" int nextQuote = -1; for (int q = pos; q < data.length(); q++) { if (data.charAt(q) == '"' || data.charAt(q) == '\'') { nextQuote = q; break; } } if (nextQuote < 0) { return null; // if (nextQuote+1 == name.length()) return null; } int closingQuote = data.indexOf(data.charAt(nextQuote), nextQuote + 1); if (closingQuote < 0) { return null; } int nextName = data.indexOf(name, pos); if (nextName < 0) { return null; } if (nextName < nextQuote) { // check only spaces and equal signs between the name and the quote boolean found = true; for (int s = nextName + name.length(); s < nextQuote; s++) { char c = data.charAt(s); if (!Character.isWhitespace(c) && c != '=') { found = false; break; } } if (found) { String val = data.substring(nextQuote + 1, closingQuote); return unescapeValue ? unescape(val) : val; } } pos = closingQuote + 1; } return null; }
[ "private", "String", "getFromPIDataPseudoAttribute", "(", "String", "data", ",", "String", "name", ",", "boolean", "unescapeValue", ")", "{", "int", "pos", "=", "0", ";", "while", "(", "pos", "<=", "data", ".", "length", "(", ")", "-", "4", ")", "{", "...
This method is copied from com.icl.saxon.ProcInstParser and used in the PIFinder. Get a pseudo-attribute. This is useful only if the processing instruction data part uses pseudo-attribute syntax, which it does not have to. This syntax is as described in the W3C Recommendation "Associating Style Sheets with XML Documents". @param data The PI Data. @param name The attr name. @param unescapeValue True to unescape value before return @return the value of the pseudo-attribute if present, or null if not
[ "This", "method", "is", "copied", "from", "com", ".", "icl", ".", "saxon", ".", "ProcInstParser", "and", "used", "in", "the", "PIFinder", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java#L514-L556
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java
RelaxNGDefaultsComponent.unescape
private String unescape(String value) { if (value.indexOf('&') < 0) { return value; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '&') { if (i + 2 < value.length() && value.charAt(i + 1) == '#') { if (value.charAt(i + 2) == 'x') { int x = i + 3; int charval = 0; while (x < value.length() && value.charAt(x) != ';') { int digit = "0123456789abcdef".indexOf(value.charAt(x)); if (digit < 0) { digit = "0123456789ABCDEF".indexOf(value.charAt(x)); } if (digit < 0) { return null; } charval = charval * 16 + digit; x++; } char hexchar = (char) charval; sb.append(hexchar); i = x; } else { int x = i + 2; int charval = 0; while (x < value.length() && value.charAt(x) != ';') { int digit = "0123456789".indexOf(value.charAt(x)); if (digit < 0) { return null; } charval = charval * 10 + digit; x++; } char decchar = (char) charval; sb.append(decchar); i = x; } } else if (value.substring(i + 1).startsWith("lt;")) { sb.append('<'); i += 3; } else if (value.substring(i + 1).startsWith("gt;")) { sb.append('>'); i += 3; } else if (value.substring(i + 1).startsWith("amp;")) { sb.append('&'); i += 4; } else if (value.substring(i + 1).startsWith("quot;")) { sb.append('"'); i += 5; } else if (value.substring(i + 1).startsWith("apos;")) { sb.append('\''); i += 5; } else { return null; } } else { sb.append(c); } } return sb.toString(); }
java
private String unescape(String value) { if (value.indexOf('&') < 0) { return value; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (c == '&') { if (i + 2 < value.length() && value.charAt(i + 1) == '#') { if (value.charAt(i + 2) == 'x') { int x = i + 3; int charval = 0; while (x < value.length() && value.charAt(x) != ';') { int digit = "0123456789abcdef".indexOf(value.charAt(x)); if (digit < 0) { digit = "0123456789ABCDEF".indexOf(value.charAt(x)); } if (digit < 0) { return null; } charval = charval * 16 + digit; x++; } char hexchar = (char) charval; sb.append(hexchar); i = x; } else { int x = i + 2; int charval = 0; while (x < value.length() && value.charAt(x) != ';') { int digit = "0123456789".indexOf(value.charAt(x)); if (digit < 0) { return null; } charval = charval * 10 + digit; x++; } char decchar = (char) charval; sb.append(decchar); i = x; } } else if (value.substring(i + 1).startsWith("lt;")) { sb.append('<'); i += 3; } else if (value.substring(i + 1).startsWith("gt;")) { sb.append('>'); i += 3; } else if (value.substring(i + 1).startsWith("amp;")) { sb.append('&'); i += 4; } else if (value.substring(i + 1).startsWith("quot;")) { sb.append('"'); i += 5; } else if (value.substring(i + 1).startsWith("apos;")) { sb.append('\''); i += 5; } else { return null; } } else { sb.append(c); } } return sb.toString(); }
[ "private", "String", "unescape", "(", "String", "value", ")", "{", "if", "(", "value", ".", "indexOf", "(", "'", "'", ")", "<", "0", ")", "{", "return", "value", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(...
This method is copied from com.icl.saxon.ProcInstParser and used in the PIFinder Interpret character references and built-in entity references
[ "This", "method", "is", "copied", "from", "com", ".", "icl", ".", "saxon", ".", "ProcInstParser", "and", "used", "in", "the", "PIFinder" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java#L564-L629
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java
RelaxNGDefaultsComponent.setProperty
public void setProperty(String propertyId, Object value) throws XMLConfigurationException { // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() && propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) { fSymbolTable = (SymbolTable) value; } else if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() && propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) { fResolver = (XMLEntityResolver) value; } } }
java
public void setProperty(String propertyId, Object value) throws XMLConfigurationException { // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() && propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) { fSymbolTable = (SymbolTable) value; } else if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() && propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) { fResolver = (XMLEntityResolver) value; } } }
[ "public", "void", "setProperty", "(", "String", "propertyId", ",", "Object", "value", ")", "throws", "XMLConfigurationException", "{", "// Xerces properties", "if", "(", "propertyId", ".", "startsWith", "(", "Constants", ".", "XERCES_PROPERTY_PREFIX", ")", ")", "{",...
Sets the value of a property during parsing.
[ "Sets", "the", "value", "of", "a", "property", "during", "parsing", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultsComponent.java#L786-L802
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.write
@Override public void write(final File filename) throws DITAOTException { assert filename.isAbsolute(); super.write(new File(currentFile)); }
java
@Override public void write(final File filename) throws DITAOTException { assert filename.isAbsolute(); super.write(new File(currentFile)); }
[ "@", "Override", "public", "void", "write", "(", "final", "File", "filename", ")", "throws", "DITAOTException", "{", "assert", "filename", ".", "isAbsolute", "(", ")", ";", "super", ".", "write", "(", "new", "File", "(", "currentFile", ")", ")", ";", "}"...
Process key references. @param filename file to process @throws DITAOTException if key reference resolution failed
[ "Process", "key", "references", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L211-L215
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.writeAlt
private void writeAlt(Element srcElem) throws SAXException { final AttributesImpl atts = new AttributesImpl(); XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_CLASS, TOPIC_ALT.toString()); getContentHandler().startElement(NULL_NS_URI, TOPIC_ALT.localName, TOPIC_ALT.localName, atts); domToSax(srcElem, false); getContentHandler().endElement(NULL_NS_URI, TOPIC_ALT.localName, TOPIC_ALT.localName); }
java
private void writeAlt(Element srcElem) throws SAXException { final AttributesImpl atts = new AttributesImpl(); XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_CLASS, TOPIC_ALT.toString()); getContentHandler().startElement(NULL_NS_URI, TOPIC_ALT.localName, TOPIC_ALT.localName, atts); domToSax(srcElem, false); getContentHandler().endElement(NULL_NS_URI, TOPIC_ALT.localName, TOPIC_ALT.localName); }
[ "private", "void", "writeAlt", "(", "Element", "srcElem", ")", "throws", "SAXException", "{", "final", "AttributesImpl", "atts", "=", "new", "AttributesImpl", "(", ")", ";", "XMLUtils", ".", "addOrSetAttribute", "(", "atts", ",", "ATTRIBUTE_NAME_CLASS", ",", "TO...
Write alt element @param srcElem element content
[ "Write", "alt", "element" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L428-L434
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.fallbackToNavtitleOrHref
private boolean fallbackToNavtitleOrHref(final Element elem) { final String hrefValue = elem.getAttribute(ATTRIBUTE_NAME_HREF); final String locktitleValue = elem.getAttribute(ATTRIBUTE_NAME_LOCKTITLE); return ((ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.equals(locktitleValue)) || ("".equals(hrefValue)) || !(isLocalDita(elem))); }
java
private boolean fallbackToNavtitleOrHref(final Element elem) { final String hrefValue = elem.getAttribute(ATTRIBUTE_NAME_HREF); final String locktitleValue = elem.getAttribute(ATTRIBUTE_NAME_LOCKTITLE); return ((ATTRIBUTE_NAME_LOCKTITLE_VALUE_YES.equals(locktitleValue)) || ("".equals(hrefValue)) || !(isLocalDita(elem))); }
[ "private", "boolean", "fallbackToNavtitleOrHref", "(", "final", "Element", "elem", ")", "{", "final", "String", "hrefValue", "=", "elem", ".", "getAttribute", "(", "ATTRIBUTE_NAME_HREF", ")", ";", "final", "String", "locktitleValue", "=", "elem", ".", "getAttribut...
Return true when keyref text resolution should use navtitle as a final fallback. @param elem Key definition element
[ "Return", "true", "when", "keyref", "text", "resolution", "should", "use", "navtitle", "as", "a", "final", "fallback", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L656-L662
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.domToSax
private void domToSax(final Element elem, final boolean retainElements, final boolean swapMapClass) throws SAXException { if (retainElements) { final AttributesImpl atts = new AttributesImpl(); final NamedNodeMap attrs = elem.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { final Attr a = (Attr) attrs.item(i); if (a.getNodeName().equals(ATTRIBUTE_NAME_CLASS) && swapMapClass) { XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_CLASS, changeclassValue(a.getNodeValue())); } else { XMLUtils.addOrSetAttribute(atts, a); } } getContentHandler().startElement(NULL_NS_URI, elem.getNodeName(), elem.getNodeName(), atts); } final NodeList nodeList = elem.getChildNodes(); for (int i = 0; i<nodeList.getLength(); i++) { final Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { final Element e = (Element) node; // retain tm and text elements if (TOPIC_TM.matches(e) || TOPIC_TEXT.matches(e)) { domToSax(e, true, swapMapClass); } else { domToSax(e, retainElements, swapMapClass); } } else if (node.getNodeType() == Node.TEXT_NODE) { final char[] ch = node.getNodeValue().toCharArray(); getContentHandler().characters(ch, 0, ch.length); } } if (retainElements) { getContentHandler().endElement(NULL_NS_URI, elem.getNodeName(), elem.getNodeName()); } }
java
private void domToSax(final Element elem, final boolean retainElements, final boolean swapMapClass) throws SAXException { if (retainElements) { final AttributesImpl atts = new AttributesImpl(); final NamedNodeMap attrs = elem.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { final Attr a = (Attr) attrs.item(i); if (a.getNodeName().equals(ATTRIBUTE_NAME_CLASS) && swapMapClass) { XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_CLASS, changeclassValue(a.getNodeValue())); } else { XMLUtils.addOrSetAttribute(atts, a); } } getContentHandler().startElement(NULL_NS_URI, elem.getNodeName(), elem.getNodeName(), atts); } final NodeList nodeList = elem.getChildNodes(); for (int i = 0; i<nodeList.getLength(); i++) { final Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { final Element e = (Element) node; // retain tm and text elements if (TOPIC_TM.matches(e) || TOPIC_TEXT.matches(e)) { domToSax(e, true, swapMapClass); } else { domToSax(e, retainElements, swapMapClass); } } else if (node.getNodeType() == Node.TEXT_NODE) { final char[] ch = node.getNodeValue().toCharArray(); getContentHandler().characters(ch, 0, ch.length); } } if (retainElements) { getContentHandler().endElement(NULL_NS_URI, elem.getNodeName(), elem.getNodeName()); } }
[ "private", "void", "domToSax", "(", "final", "Element", "elem", ",", "final", "boolean", "retainElements", ",", "final", "boolean", "swapMapClass", ")", "throws", "SAXException", "{", "if", "(", "retainElements", ")", "{", "final", "AttributesImpl", "atts", "=",...
Serialize DOM node into a SAX stream. @param elem element to serialize @param retainElements {@code true} to serialize elements, {@code false} to only serialize text nodes. @param swapMapClass {@code true} to change map/ to topic/ in common class attributes, {@code false} to leave as is
[ "Serialize", "DOM", "node", "into", "a", "SAX", "stream", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L681-L714
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.changeclassValue
private String changeclassValue(final String classValue) { final DitaClass cls = new DitaClass(classValue); if (cls.equals(MAP_LINKTEXT)) { return TOPIC_LINKTEXT.toString(); } else if (cls.equals(MAP_SEARCHTITLE)) { return TOPIC_SEARCHTITLE.toString(); } else if (cls.equals(MAP_SHORTDESC)) { return TOPIC_SHORTDESC.toString(); } else { return cls.toString(); } }
java
private String changeclassValue(final String classValue) { final DitaClass cls = new DitaClass(classValue); if (cls.equals(MAP_LINKTEXT)) { return TOPIC_LINKTEXT.toString(); } else if (cls.equals(MAP_SEARCHTITLE)) { return TOPIC_SEARCHTITLE.toString(); } else if (cls.equals(MAP_SHORTDESC)) { return TOPIC_SHORTDESC.toString(); } else { return cls.toString(); } }
[ "private", "String", "changeclassValue", "(", "final", "String", "classValue", ")", "{", "final", "DitaClass", "cls", "=", "new", "DitaClass", "(", "classValue", ")", ";", "if", "(", "cls", ".", "equals", "(", "MAP_LINKTEXT", ")", ")", "{", "return", "TOPI...
Change map type to topic type.
[ "Change", "map", "type", "to", "topic", "type", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L719-L730
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.normalizeHrefValue
private static URI normalizeHrefValue(final URI keyName, final String tail) { if (keyName.getFragment() == null) { return toURI(keyName + tail.replaceAll(SLASH, SHARP)); } return toURI(keyName + tail); }
java
private static URI normalizeHrefValue(final URI keyName, final String tail) { if (keyName.getFragment() == null) { return toURI(keyName + tail.replaceAll(SLASH, SHARP)); } return toURI(keyName + tail); }
[ "private", "static", "URI", "normalizeHrefValue", "(", "final", "URI", "keyName", ",", "final", "String", "tail", ")", "{", "if", "(", "keyName", ".", "getFragment", "(", ")", "==", "null", ")", "{", "return", "toURI", "(", "keyName", "+", "tail", ".", ...
change elementId into topicId if there is no topicId in key definition.
[ "change", "elementId", "into", "topicId", "if", "there", "is", "no", "topicId", "in", "key", "definition", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L735-L740
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/KeyrefPaser.java
KeyrefPaser.normalizeHrefValue
private static URI normalizeHrefValue(final URI fileName, final String tail, final String topicId) { //Insert first topic id only when topicid is not set in keydef //and keyref has elementid if (fileName.getFragment() == null && !"".equals(tail)) { return setFragment(fileName, topicId + tail); } return toURI(fileName + tail); }
java
private static URI normalizeHrefValue(final URI fileName, final String tail, final String topicId) { //Insert first topic id only when topicid is not set in keydef //and keyref has elementid if (fileName.getFragment() == null && !"".equals(tail)) { return setFragment(fileName, topicId + tail); } return toURI(fileName + tail); }
[ "private", "static", "URI", "normalizeHrefValue", "(", "final", "URI", "fileName", ",", "final", "String", "tail", ",", "final", "String", "topicId", ")", "{", "//Insert first topic id only when topicid is not set in keydef", "//and keyref has elementid", "if", "(", "file...
Insert topic id into href
[ "Insert", "topic", "id", "into", "href" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/KeyrefPaser.java#L752-L759
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/CoderefResolver.java
CoderefResolver.getRange
private Range getRange(final URI uri) { int start = 0; int end = Integer.MAX_VALUE; String startId = null; String endId = null; final String fragment = uri.getFragment(); if (fragment != null) { // RFC 5147 final Matcher m = Pattern.compile("^line=(?:(\\d+)|(\\d+)?,(\\d+)?)$").matcher(fragment); if (m.matches()) { if (m.group(1) != null) { start = Integer.parseInt(m.group(1)); end = start; } else { if (m.group(2) != null) { start = Integer.parseInt(m.group(2)); } if (m.group(3) != null) { end = Integer.parseInt(m.group(3)) - 1; } } return new LineNumberRange(start, end).handler(this); } else { final Matcher mc = Pattern.compile("^line-range\\((\\d+)(?:,\\s*(\\d+))?\\)$").matcher(fragment); if (mc.matches()) { start = Integer.parseInt(mc.group(1)) - 1; if (mc.group(2) != null) { end = Integer.parseInt(mc.group(2)) - 1; } return new LineNumberRange(start, end).handler(this); } else { final Matcher mi = Pattern.compile("^token=([^,\\s)]*)(?:,\\s*([^,\\s)]+))?$").matcher(fragment); if (mi.matches()) { if (mi.group(1) != null && mi.group(1).length() != 0) { startId = mi.group(1); } if (mi.group(2) != null) { endId = mi.group(2); } return new AnchorRange(startId, endId).handler(this); } } } } return new AllRange().handler(this); }
java
private Range getRange(final URI uri) { int start = 0; int end = Integer.MAX_VALUE; String startId = null; String endId = null; final String fragment = uri.getFragment(); if (fragment != null) { // RFC 5147 final Matcher m = Pattern.compile("^line=(?:(\\d+)|(\\d+)?,(\\d+)?)$").matcher(fragment); if (m.matches()) { if (m.group(1) != null) { start = Integer.parseInt(m.group(1)); end = start; } else { if (m.group(2) != null) { start = Integer.parseInt(m.group(2)); } if (m.group(3) != null) { end = Integer.parseInt(m.group(3)) - 1; } } return new LineNumberRange(start, end).handler(this); } else { final Matcher mc = Pattern.compile("^line-range\\((\\d+)(?:,\\s*(\\d+))?\\)$").matcher(fragment); if (mc.matches()) { start = Integer.parseInt(mc.group(1)) - 1; if (mc.group(2) != null) { end = Integer.parseInt(mc.group(2)) - 1; } return new LineNumberRange(start, end).handler(this); } else { final Matcher mi = Pattern.compile("^token=([^,\\s)]*)(?:,\\s*([^,\\s)]+))?$").matcher(fragment); if (mi.matches()) { if (mi.group(1) != null && mi.group(1).length() != 0) { startId = mi.group(1); } if (mi.group(2) != null) { endId = mi.group(2); } return new AnchorRange(startId, endId).handler(this); } } } } return new AllRange().handler(this); }
[ "private", "Range", "getRange", "(", "final", "URI", "uri", ")", "{", "int", "start", "=", "0", ";", "int", "end", "=", "Integer", ".", "MAX_VALUE", ";", "String", "startId", "=", "null", ";", "String", "endId", "=", "null", ";", "final", "String", "...
Factory method for Range implementation
[ "Factory", "method", "for", "Range", "implementation" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/CoderefResolver.java#L150-L197
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/CoderefResolver.java
CoderefResolver.getCharset
private Charset getCharset(final String value) { Charset c = null; if (value != null) { final String[] tokens = value.trim().split("[;=]"); if (tokens.length >= 3 && tokens[1].trim().equals("charset")) { try { c = Charset.forName(tokens[2].trim()); } catch (final RuntimeException e) { logger.error(MessageUtils.getMessage("DOTJ052E", tokens[2].trim()).toString()); } } } if (c == null) { final String defaultCharset = Configuration.configuration.get("default.coderef-charset"); if (defaultCharset != null) { c = Charset.forName(defaultCharset); } else { c = Charset.defaultCharset(); } } return c; }
java
private Charset getCharset(final String value) { Charset c = null; if (value != null) { final String[] tokens = value.trim().split("[;=]"); if (tokens.length >= 3 && tokens[1].trim().equals("charset")) { try { c = Charset.forName(tokens[2].trim()); } catch (final RuntimeException e) { logger.error(MessageUtils.getMessage("DOTJ052E", tokens[2].trim()).toString()); } } } if (c == null) { final String defaultCharset = Configuration.configuration.get("default.coderef-charset"); if (defaultCharset != null) { c = Charset.forName(defaultCharset); } else { c = Charset.defaultCharset(); } } return c; }
[ "private", "Charset", "getCharset", "(", "final", "String", "value", ")", "{", "Charset", "c", "=", "null", ";", "if", "(", "value", "!=", "null", ")", "{", "final", "String", "[", "]", "tokens", "=", "value", ".", "trim", "(", ")", ".", "split", "...
Get code file charset. @param value format attribute value, may be {@code null} @return charset if set, otherwise default charset
[ "Get", "code", "file", "charset", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/CoderefResolver.java#L311-L332
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/FilterUtils.java
FilterUtils.needExclude
public boolean needExclude(final Attributes atts, final QName[][] extProps) { if (filterMap.isEmpty()) { return false; } for (final QName attr: filterAttributes) { final String value = atts.getValue(attr.getNamespaceURI(), attr.getLocalPart()); if (value != null) { final Map<QName, List<String>> groups = getGroups(value); for (Map.Entry<QName, List<String>> group: groups.entrySet()) { final QName[] propList = group.getKey() != null ? new QName[]{attr, group.getKey()} : new QName[]{attr}; if (extCheckExclude(propList, group.getValue())) { return true; } } } } if (extProps != null && extProps.length != 0) { for (final QName[] propList: extProps) { int propListIndex = propList.length - 1; final QName propName = propList[propListIndex]; String propValue = atts.getValue(propName.getNamespaceURI(), propName.getLocalPart()); while ((propValue == null || propValue.trim().isEmpty()) && propListIndex > 0) { propListIndex--; final QName current = propList[propListIndex]; propValue = getLabelValue(propName, atts.getValue(current.getNamespaceURI(), current.getLocalPart())); } if (propValue != null && extCheckExclude(propList, Arrays.asList(propValue.split("\\s+")))) { return true; } } } return false; }
java
public boolean needExclude(final Attributes atts, final QName[][] extProps) { if (filterMap.isEmpty()) { return false; } for (final QName attr: filterAttributes) { final String value = atts.getValue(attr.getNamespaceURI(), attr.getLocalPart()); if (value != null) { final Map<QName, List<String>> groups = getGroups(value); for (Map.Entry<QName, List<String>> group: groups.entrySet()) { final QName[] propList = group.getKey() != null ? new QName[]{attr, group.getKey()} : new QName[]{attr}; if (extCheckExclude(propList, group.getValue())) { return true; } } } } if (extProps != null && extProps.length != 0) { for (final QName[] propList: extProps) { int propListIndex = propList.length - 1; final QName propName = propList[propListIndex]; String propValue = atts.getValue(propName.getNamespaceURI(), propName.getLocalPart()); while ((propValue == null || propValue.trim().isEmpty()) && propListIndex > 0) { propListIndex--; final QName current = propList[propListIndex]; propValue = getLabelValue(propName, atts.getValue(current.getNamespaceURI(), current.getLocalPart())); } if (propValue != null && extCheckExclude(propList, Arrays.asList(propValue.split("\\s+")))) { return true; } } } return false; }
[ "public", "boolean", "needExclude", "(", "final", "Attributes", "atts", ",", "final", "QName", "[", "]", "[", "]", "extProps", ")", "{", "if", "(", "filterMap", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "final", "QN...
Check if the given Attributes need to be excluded. @param atts attributes @param extProps {@code props} attribute specializations @return {@code true} if any profiling attribute was excluded, otherwise {@code false}
[ "Check", "if", "the", "given", "Attributes", "need", "to", "be", "excluded", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L289-L327
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/FilterUtils.java
FilterUtils.getLabelValue
private String getLabelValue(final QName propName, final String attrPropsValue) { if (attrPropsValue != null) { int propStart = -1; if (attrPropsValue.startsWith(propName + "(") || attrPropsValue.contains(" " + propName + "(")) { propStart = attrPropsValue.indexOf(propName + "("); } if (propStart != -1) { propStart = propStart + propName.toString().length() + 1; } final int propEnd = attrPropsValue.indexOf(")", propStart); if (propStart != -1 && propEnd != -1) { return attrPropsValue.substring(propStart, propEnd).trim(); } } return null; }
java
private String getLabelValue(final QName propName, final String attrPropsValue) { if (attrPropsValue != null) { int propStart = -1; if (attrPropsValue.startsWith(propName + "(") || attrPropsValue.contains(" " + propName + "(")) { propStart = attrPropsValue.indexOf(propName + "("); } if (propStart != -1) { propStart = propStart + propName.toString().length() + 1; } final int propEnd = attrPropsValue.indexOf(")", propStart); if (propStart != -1 && propEnd != -1) { return attrPropsValue.substring(propStart, propEnd).trim(); } } return null; }
[ "private", "String", "getLabelValue", "(", "final", "QName", "propName", ",", "final", "String", "attrPropsValue", ")", "{", "if", "(", "attrPropsValue", "!=", "null", ")", "{", "int", "propStart", "=", "-", "1", ";", "if", "(", "attrPropsValue", ".", "sta...
Get labelled props value. @param propName attribute name @param attrPropsValue attribute value @return props value, {@code null} if not available
[ "Get", "labelled", "props", "value", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L373-L388
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/FilterUtils.java
FilterUtils.checkRuleMapping
private void checkRuleMapping(final QName attName, final List<String> attValue) { if (attValue == null || attValue.isEmpty()) { return; } for (final String attSubValue: attValue) { final FilterKey filterKey = new FilterKey(attName, attSubValue); final Action filterAction = filterMap.get(filterKey); if (filterAction == null && logMissingAction) { if (!alreadyShowed(filterKey)) { logger.info(MessageUtils.getMessage("DOTJ031I", filterKey.toString()).toString()); } } } }
java
private void checkRuleMapping(final QName attName, final List<String> attValue) { if (attValue == null || attValue.isEmpty()) { return; } for (final String attSubValue: attValue) { final FilterKey filterKey = new FilterKey(attName, attSubValue); final Action filterAction = filterMap.get(filterKey); if (filterAction == null && logMissingAction) { if (!alreadyShowed(filterKey)) { logger.info(MessageUtils.getMessage("DOTJ031I", filterKey.toString()).toString()); } } } }
[ "private", "void", "checkRuleMapping", "(", "final", "QName", "attName", ",", "final", "List", "<", "String", ">", "attValue", ")", "{", "if", "(", "attValue", "==", "null", "||", "attValue", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "for...
Check if attribute value has mapping in filter configuration and throw messages. @param attName attribute name @param attValue attribute value
[ "Check", "if", "attribute", "value", "has", "mapping", "in", "filter", "configuration", "and", "throw", "messages", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L467-L480
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/FilterUtils.java
FilterUtils.refine
private FilterUtils refine(final Map<QName, Map<String, Set<Element>>> bindingMap) { if (bindingMap != null && !bindingMap.isEmpty()) { final Map<FilterKey, Action> buf = new HashMap<>(filterMap); for (final Map.Entry<FilterKey, Action> e: filterMap.entrySet()) { refineAction(e.getValue(), e.getKey(), bindingMap, buf); } final FilterUtils filterUtils = new FilterUtils(buf, foregroundConflictColor, backgroundConflictColor); filterUtils.setLogger(logger); filterUtils.logMissingAction = logMissingAction; return filterUtils; } else { return this; } }
java
private FilterUtils refine(final Map<QName, Map<String, Set<Element>>> bindingMap) { if (bindingMap != null && !bindingMap.isEmpty()) { final Map<FilterKey, Action> buf = new HashMap<>(filterMap); for (final Map.Entry<FilterKey, Action> e: filterMap.entrySet()) { refineAction(e.getValue(), e.getKey(), bindingMap, buf); } final FilterUtils filterUtils = new FilterUtils(buf, foregroundConflictColor, backgroundConflictColor); filterUtils.setLogger(logger); filterUtils.logMissingAction = logMissingAction; return filterUtils; } else { return this; } }
[ "private", "FilterUtils", "refine", "(", "final", "Map", "<", "QName", ",", "Map", "<", "String", ",", "Set", "<", "Element", ">", ">", ">", "bindingMap", ")", "{", "if", "(", "bindingMap", "!=", "null", "&&", "!", "bindingMap", ".", "isEmpty", "(", ...
Refine filter with subject scheme. @param bindingMap subject scheme bindings, {@code Map<AttName, Map<ElemName, Set<Element>>>} @return new filter with subject scheme information
[ "Refine", "filter", "with", "subject", "scheme", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L569-L582
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/CopyToReader.java
CopyToReader.isFormatDita
public static boolean isFormatDita(final String attrFormat) { if (attrFormat == null || attrFormat.equals(ATTR_FORMAT_VALUE_DITA)) { return true; } for (final String f : ditaFormat) { if (f.equals(attrFormat)) { return true; } } return false; }
java
public static boolean isFormatDita(final String attrFormat) { if (attrFormat == null || attrFormat.equals(ATTR_FORMAT_VALUE_DITA)) { return true; } for (final String f : ditaFormat) { if (f.equals(attrFormat)) { return true; } } return false; }
[ "public", "static", "boolean", "isFormatDita", "(", "final", "String", "attrFormat", ")", "{", "if", "(", "attrFormat", "==", "null", "||", "attrFormat", ".", "equals", "(", "ATTR_FORMAT_VALUE_DITA", ")", ")", "{", "return", "true", ";", "}", "for", "(", "...
Check if format is DITA topic. @param attrFormat format attribute value, may be {@code null} @return {@code true} if DITA topic, otherwise {@code false}
[ "Check", "if", "format", "is", "DITA", "topic", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/CopyToReader.java#L198-L208
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.buildFinished
@Override public void buildFinished(final BuildEvent event) { final Throwable error = event.getException(); final StringBuilder message = new StringBuilder(); if (error == null) { // message.append(StringUtils.LINE_SEP); // message.append(getBuildSuccessfulMessage()); } else { // message.append(StringUtils.LINE_SEP); // message.append(getBuildFailedMessage()); // message.append(StringUtils.LINE_SEP); message.append("Error: "); throwableMessage(message, error, Project.MSG_VERBOSE <= msgOutputLevel); } // message.append(StringUtils.LINE_SEP); // message.append("Total time: "); // message.append(formatTime(System.currentTimeMillis() - startTime)); final String msg = message.toString(); if (error == null && !msg.trim().isEmpty()) { printMessage(msg, out, Project.MSG_VERBOSE); } else if (!msg.isEmpty()) { printMessage(msg, err, Project.MSG_ERR); } log(msg); }
java
@Override public void buildFinished(final BuildEvent event) { final Throwable error = event.getException(); final StringBuilder message = new StringBuilder(); if (error == null) { // message.append(StringUtils.LINE_SEP); // message.append(getBuildSuccessfulMessage()); } else { // message.append(StringUtils.LINE_SEP); // message.append(getBuildFailedMessage()); // message.append(StringUtils.LINE_SEP); message.append("Error: "); throwableMessage(message, error, Project.MSG_VERBOSE <= msgOutputLevel); } // message.append(StringUtils.LINE_SEP); // message.append("Total time: "); // message.append(formatTime(System.currentTimeMillis() - startTime)); final String msg = message.toString(); if (error == null && !msg.trim().isEmpty()) { printMessage(msg, out, Project.MSG_VERBOSE); } else if (!msg.isEmpty()) { printMessage(msg, err, Project.MSG_ERR); } log(msg); }
[ "@", "Override", "public", "void", "buildFinished", "(", "final", "BuildEvent", "event", ")", "{", "final", "Throwable", "error", "=", "event", ".", "getException", "(", ")", ";", "final", "StringBuilder", "message", "=", "new", "StringBuilder", "(", ")", ";...
Prints whether the build succeeded or failed, any errors the occurred during the build, and how long the build took. @param event An event with any relevant extra information. Must not be <code>null</code>.
[ "Prints", "whether", "the", "build", "succeeded", "or", "failed", "any", "errors", "the", "occurred", "during", "the", "build", "and", "how", "long", "the", "build", "took", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L180-L205
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.targetStarted
@Override public void targetStarted(final BuildEvent event) { if (Project.MSG_INFO <= msgOutputLevel && !event.getTarget().getName().equals("")) { final String msg = StringUtils.LINE_SEP + event.getTarget().getName() + ":"; printMessage(msg, out, event.getPriority()); log(msg); } }
java
@Override public void targetStarted(final BuildEvent event) { if (Project.MSG_INFO <= msgOutputLevel && !event.getTarget().getName().equals("")) { final String msg = StringUtils.LINE_SEP + event.getTarget().getName() + ":"; printMessage(msg, out, event.getPriority()); log(msg); } }
[ "@", "Override", "public", "void", "targetStarted", "(", "final", "BuildEvent", "event", ")", "{", "if", "(", "Project", ".", "MSG_INFO", "<=", "msgOutputLevel", "&&", "!", "event", ".", "getTarget", "(", ")", ".", "getName", "(", ")", ".", "equals", "("...
Logs a message to say that the target has started if this logger allows information-level messages. @param event An event with any relevant extra information. Must not be <code>null</code>.
[ "Logs", "a", "message", "to", "say", "that", "the", "target", "has", "started", "if", "this", "logger", "allows", "information", "-", "level", "messages", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L234-L241
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.messageLogged
@Override public void messageLogged(final BuildEvent event) { final int priority = event.getPriority(); // Filter out messages based on priority if (priority <= msgOutputLevel) { final StringBuilder message = new StringBuilder(); if (event.getTask() != null && !emacsMode) { // Print out the name of the task if we're in one final String name = event.getTask().getTaskName(); String label = "[" + name + "] "; final int size = LEFT_COLUMN_SIZE - label.length(); final StringBuilder tmp = new StringBuilder(); for (int i = 0; i < size; i++) { tmp.append(" "); } tmp.append(label); label = tmp.toString(); BufferedReader r = null; try { r = new BufferedReader(new StringReader(event.getMessage())); String line = r.readLine(); boolean first = true; do { if (first) { if (line == null) { message.append(label); break; } } else { message.append(StringUtils.LINE_SEP); } first = false; message.append(label).append(line); line = r.readLine(); } while (line != null); } catch (final IOException e) { // shouldn't be possible message.append(label).append(event.getMessage()); } finally { if (r != null) { FileUtils.close(r); } } } else { // emacs mode or there is no task message.append(event.getMessage()); } final Throwable ex = event.getException(); if (Project.MSG_DEBUG <= msgOutputLevel && ex != null) { message.append(StringUtils.getStackTrace(ex)); } final String msg = message.toString(); if (priority != Project.MSG_ERR) { printMessage(msg, out, priority); } else { printMessage(msg, err, priority); } log(msg); } }
java
@Override public void messageLogged(final BuildEvent event) { final int priority = event.getPriority(); // Filter out messages based on priority if (priority <= msgOutputLevel) { final StringBuilder message = new StringBuilder(); if (event.getTask() != null && !emacsMode) { // Print out the name of the task if we're in one final String name = event.getTask().getTaskName(); String label = "[" + name + "] "; final int size = LEFT_COLUMN_SIZE - label.length(); final StringBuilder tmp = new StringBuilder(); for (int i = 0; i < size; i++) { tmp.append(" "); } tmp.append(label); label = tmp.toString(); BufferedReader r = null; try { r = new BufferedReader(new StringReader(event.getMessage())); String line = r.readLine(); boolean first = true; do { if (first) { if (line == null) { message.append(label); break; } } else { message.append(StringUtils.LINE_SEP); } first = false; message.append(label).append(line); line = r.readLine(); } while (line != null); } catch (final IOException e) { // shouldn't be possible message.append(label).append(event.getMessage()); } finally { if (r != null) { FileUtils.close(r); } } } else { // emacs mode or there is no task message.append(event.getMessage()); } final Throwable ex = event.getException(); if (Project.MSG_DEBUG <= msgOutputLevel && ex != null) { message.append(StringUtils.getStackTrace(ex)); } final String msg = message.toString(); if (priority != Project.MSG_ERR) { printMessage(msg, out, priority); } else { printMessage(msg, err, priority); } log(msg); } }
[ "@", "Override", "public", "void", "messageLogged", "(", "final", "BuildEvent", "event", ")", "{", "final", "int", "priority", "=", "event", ".", "getPriority", "(", ")", ";", "// Filter out messages based on priority", "if", "(", "priority", "<=", "msgOutputLevel...
Logs a message, if the priority is suitable. In non-emacs mode, task level messages are prefixed by the task name which is right-justified. @param event A BuildEvent containing message information. Must not be <code>null</code>.
[ "Logs", "a", "message", "if", "the", "priority", "is", "suitable", ".", "In", "non", "-", "emacs", "mode", "task", "level", "messages", "are", "prefixed", "by", "the", "task", "name", "which", "is", "right", "-", "justified", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L277-L340
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.printMessage
private void printMessage(final String message, final PrintStream stream, final int priority) { if (useColor && priority == Project.MSG_ERR) { stream.print(ANSI_RED); stream.print(message); stream.println(ANSI_RESET); } else { stream.println(message); } }
java
private void printMessage(final String message, final PrintStream stream, final int priority) { if (useColor && priority == Project.MSG_ERR) { stream.print(ANSI_RED); stream.print(message); stream.println(ANSI_RESET); } else { stream.println(message); } }
[ "private", "void", "printMessage", "(", "final", "String", "message", ",", "final", "PrintStream", "stream", ",", "final", "int", "priority", ")", "{", "if", "(", "useColor", "&&", "priority", "==", "Project", ".", "MSG_ERR", ")", "{", "stream", ".", "prin...
Prints a message to a PrintStream. @param message The message to print. Should not be <code>null</code>. @param stream A PrintStream to print the message to. Must not be <code>null</code>. @param priority The priority of the message. (Ignored in this implementation.)
[ "Prints", "a", "message", "to", "a", "PrintStream", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L364-L372
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.getTimestamp
protected String getTimestamp() { final Date date = new Date(System.currentTimeMillis()); final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return formatter.format(date); }
java
protected String getTimestamp() { final Date date = new Date(System.currentTimeMillis()); final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return formatter.format(date); }
[ "protected", "String", "getTimestamp", "(", ")", "{", "final", "Date", "date", "=", "new", "Date", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "final", "DateFormat", "formatter", "=", "DateFormat", ".", "getDateTimeInstance", "(", "DateFormat"...
Get the current time. @return the current time as a formatted string. @since Ant1.7.1
[ "Get", "the", "current", "time", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L389-L393
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/DefaultLogger.java
DefaultLogger.extractProjectName
protected String extractProjectName(final BuildEvent event) { final Project project = event.getProject(); return (project != null) ? project.getName() : null; }
java
protected String extractProjectName(final BuildEvent event) { final Project project = event.getProject(); return (project != null) ? project.getName() : null; }
[ "protected", "String", "extractProjectName", "(", "final", "BuildEvent", "event", ")", "{", "final", "Project", "project", "=", "event", ".", "getProject", "(", ")", ";", "return", "(", "project", "!=", "null", ")", "?", "project", ".", "getName", "(", ")"...
Get the project name or null @param event the event @return the project that raised this event @since Ant1.7.1
[ "Get", "the", "project", "name", "or", "null" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/DefaultLogger.java#L402-L405
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/TopicRefWriter.java
TopicRefWriter.setup
public void setup(final Map<URI, URI> conflictTable) { for (final Map.Entry<URI, URI> e: changeTable.entrySet()) { assert e.getKey().isAbsolute(); assert e.getValue().isAbsolute(); } this.conflictTable = conflictTable; }
java
public void setup(final Map<URI, URI> conflictTable) { for (final Map.Entry<URI, URI> e: changeTable.entrySet()) { assert e.getKey().isAbsolute(); assert e.getValue().isAbsolute(); } this.conflictTable = conflictTable; }
[ "public", "void", "setup", "(", "final", "Map", "<", "URI", ",", "URI", ">", "conflictTable", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "URI", ",", "URI", ">", "e", ":", "changeTable", ".", "entrySet", "(", ")", ")", "{", "assert", ...
Set up class. @param conflictTable conflictTable
[ "Set", "up", "class", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/TopicRefWriter.java#L49-L55
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/TopicRefWriter.java
TopicRefWriter.isLocalDita
private boolean isLocalDita(final Attributes atts) { final String classValue = atts.getValue(ATTRIBUTE_NAME_CLASS); if (classValue == null || (TOPIC_IMAGE.matches(classValue))) { return false; } String scopeValue = atts.getValue(ATTRIBUTE_NAME_SCOPE); if (scopeValue == null) { scopeValue = ATTR_SCOPE_VALUE_LOCAL; } String formatValue = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (formatValue == null) { formatValue = ATTR_FORMAT_VALUE_DITA; } return scopeValue.equals(ATTR_SCOPE_VALUE_LOCAL) && formatValue.equals(ATTR_FORMAT_VALUE_DITA); }
java
private boolean isLocalDita(final Attributes atts) { final String classValue = atts.getValue(ATTRIBUTE_NAME_CLASS); if (classValue == null || (TOPIC_IMAGE.matches(classValue))) { return false; } String scopeValue = atts.getValue(ATTRIBUTE_NAME_SCOPE); if (scopeValue == null) { scopeValue = ATTR_SCOPE_VALUE_LOCAL; } String formatValue = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (formatValue == null) { formatValue = ATTR_FORMAT_VALUE_DITA; } return scopeValue.equals(ATTR_SCOPE_VALUE_LOCAL) && formatValue.equals(ATTR_FORMAT_VALUE_DITA); }
[ "private", "boolean", "isLocalDita", "(", "final", "Attributes", "atts", ")", "{", "final", "String", "classValue", "=", "atts", ".", "getValue", "(", "ATTRIBUTE_NAME_CLASS", ")", ";", "if", "(", "classValue", "==", "null", "||", "(", "TOPIC_IMAGE", ".", "ma...
Check whether the attributes contains references @param atts element attributes @return {@code true} if local DITA reference, otherwise {@code false}
[ "Check", "whether", "the", "attributes", "contains", "references" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/TopicRefWriter.java#L117-L135
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/TopicRefWriter.java
TopicRefWriter.getElementID
private String getElementID(final String relativePath) { final String fragment = getFragment(relativePath); if (fragment != null) { if (fragment.lastIndexOf(SLASH) != -1) { return fragment.substring(fragment.lastIndexOf(SLASH) + 1); } else { return fragment; } } return null; }
java
private String getElementID(final String relativePath) { final String fragment = getFragment(relativePath); if (fragment != null) { if (fragment.lastIndexOf(SLASH) != -1) { return fragment.substring(fragment.lastIndexOf(SLASH) + 1); } else { return fragment; } } return null; }
[ "private", "String", "getElementID", "(", "final", "String", "relativePath", ")", "{", "final", "String", "fragment", "=", "getFragment", "(", "relativePath", ")", ";", "if", "(", "fragment", "!=", "null", ")", "{", "if", "(", "fragment", ".", "lastIndexOf",...
Retrieve the element ID from the path. If there is no element ID, return topic ID.
[ "Retrieve", "the", "element", "ID", "from", "the", "path", ".", "If", "there", "is", "no", "element", "ID", "return", "topic", "ID", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/TopicRefWriter.java#L228-L238
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/DITAOTCollator.java
DITAOTCollator.getInstance
public static DITAOTCollator getInstance(final Locale locale) { if (locale == null) { throw new NullPointerException("Locale may not be null"); } DITAOTCollator instance; instance = cache.computeIfAbsent(locale, DITAOTCollator::new); return instance; }
java
public static DITAOTCollator getInstance(final Locale locale) { if (locale == null) { throw new NullPointerException("Locale may not be null"); } DITAOTCollator instance; instance = cache.computeIfAbsent(locale, DITAOTCollator::new); return instance; }
[ "public", "static", "DITAOTCollator", "getInstance", "(", "final", "Locale", "locale", ")", "{", "if", "(", "locale", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Locale may not be null\"", ")", ";", "}", "DITAOTCollator", "instance", ...
Return the DITAOTCollator instance specifying Locale. @param locale the locale @return DITAOTCollator
[ "Return", "the", "DITAOTCollator", "instance", "specifying", "Locale", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/DITAOTCollator.java#L38-L45
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/DITAOTCollator.java
DITAOTCollator.compare
@Override public int compare(final Object source, final Object target) { try { return (Integer) compareMethod.invoke(collatorInstance, source, target); } catch (final Exception e) { throw new RuntimeException(e.getMessage(), e); } }
java
@Override public int compare(final Object source, final Object target) { try { return (Integer) compareMethod.invoke(collatorInstance, source, target); } catch (final Exception e) { throw new RuntimeException(e.getMessage(), e); } }
[ "@", "Override", "public", "int", "compare", "(", "final", "Object", "source", ",", "final", "Object", "target", ")", "{", "try", "{", "return", "(", "Integer", ")", "compareMethod", ".", "invoke", "(", "collatorInstance", ",", "source", ",", "target", ")"...
Comparing method required to compare. @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
[ "Comparing", "method", "required", "to", "compare", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/DITAOTCollator.java#L68-L75
train
dita-ot/dita-ot
src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java
IndexPreprocessor.process
public IndexPreprocessResult process(final Document theInput) throws ProcessException { final DocumentBuilder documentBuilder = XMLUtils.getDocumentBuilder(); final Document doc = documentBuilder.newDocument(); final Node rootElement = theInput.getDocumentElement(); final ArrayList<IndexEntry> indexes = new ArrayList<IndexEntry>(); final IndexEntryFoundListener listener = new IndexEntryFoundListener() { public void foundEntry(final IndexEntry theEntry) { indexes.add(theEntry); } }; final Node node = processCurrNode(rootElement, doc, listener)[0]; doc.appendChild(node); doc.getDocumentElement().setAttribute(XMLNS_ATTRIBUTE + ":" + this.prefix, this.namespace_url); return new IndexPreprocessResult(doc, (IndexEntry[]) indexes.toArray(new IndexEntry[0])); }
java
public IndexPreprocessResult process(final Document theInput) throws ProcessException { final DocumentBuilder documentBuilder = XMLUtils.getDocumentBuilder(); final Document doc = documentBuilder.newDocument(); final Node rootElement = theInput.getDocumentElement(); final ArrayList<IndexEntry> indexes = new ArrayList<IndexEntry>(); final IndexEntryFoundListener listener = new IndexEntryFoundListener() { public void foundEntry(final IndexEntry theEntry) { indexes.add(theEntry); } }; final Node node = processCurrNode(rootElement, doc, listener)[0]; doc.appendChild(node); doc.getDocumentElement().setAttribute(XMLNS_ATTRIBUTE + ":" + this.prefix, this.namespace_url); return new IndexPreprocessResult(doc, (IndexEntry[]) indexes.toArray(new IndexEntry[0])); }
[ "public", "IndexPreprocessResult", "process", "(", "final", "Document", "theInput", ")", "throws", "ProcessException", "{", "final", "DocumentBuilder", "documentBuilder", "=", "XMLUtils", ".", "getDocumentBuilder", "(", ")", ";", "final", "Document", "doc", "=", "do...
Process index terms. @param theInput input document @return read index terms @throws ProcessException if processing index terms failed
[ "Process", "index", "terms", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java#L95-L118
train
dita-ot/dita-ot
src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java
IndexPreprocessor.processCurrNode
private Node[] processCurrNode(final Node theNode, final Document theTargetDocument, final IndexEntryFoundListener theIndexEntryFoundListener) { final NodeList childNodes = theNode.getChildNodes(); if (checkElementName(theNode) && !excludedDraftSection.peek()) { return processIndexNode(theNode, theTargetDocument, theIndexEntryFoundListener); } else { final Node result = theTargetDocument.importNode(theNode, false); if (!includeDraft && checkDraftNode(theNode)) { excludedDraftSection.add(true); } for (int i = 0; i < childNodes.getLength(); i++) { final Node[] processedNodes = processCurrNode(childNodes.item(i), theTargetDocument, theIndexEntryFoundListener); for (final Node node : processedNodes) { result.appendChild(node); } } if (!includeDraft && checkDraftNode(theNode)) { excludedDraftSection.pop(); } return new Node[]{result}; } }
java
private Node[] processCurrNode(final Node theNode, final Document theTargetDocument, final IndexEntryFoundListener theIndexEntryFoundListener) { final NodeList childNodes = theNode.getChildNodes(); if (checkElementName(theNode) && !excludedDraftSection.peek()) { return processIndexNode(theNode, theTargetDocument, theIndexEntryFoundListener); } else { final Node result = theTargetDocument.importNode(theNode, false); if (!includeDraft && checkDraftNode(theNode)) { excludedDraftSection.add(true); } for (int i = 0; i < childNodes.getLength(); i++) { final Node[] processedNodes = processCurrNode(childNodes.item(i), theTargetDocument, theIndexEntryFoundListener); for (final Node node : processedNodes) { result.appendChild(node); } } if (!includeDraft && checkDraftNode(theNode)) { excludedDraftSection.pop(); } return new Node[]{result}; } }
[ "private", "Node", "[", "]", "processCurrNode", "(", "final", "Node", "theNode", ",", "final", "Document", "theTargetDocument", ",", "final", "IndexEntryFoundListener", "theIndexEntryFoundListener", ")", "{", "final", "NodeList", "childNodes", "=", "theNode", ".", "...
Processes curr node. Copies node to the target document if its is not a text node of index entry element. Otherwise it process it and creates nodes with "prefix" in given "namespace_url" from the parsed index entry text. @param theNode node to process @param theTargetDocument target document used to import and create nodes @param theIndexEntryFoundListener listener to notify that new index entry was found @return the array of nodes after processing input node
[ "Processes", "curr", "node", ".", "Copies", "node", "to", "the", "target", "document", "if", "its", "is", "not", "a", "text", "node", "of", "index", "entry", "element", ".", "Otherwise", "it", "process", "it", "and", "creates", "nodes", "with", "prefix", ...
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java#L161-L182
train
dita-ot/dita-ot
src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java
IndexPreprocessor.checkElementName
private boolean checkElementName(final Node node) { return TOPIC_INDEXTERM.matches(node) || INDEXING_D_INDEX_SORT_AS.matches(node) || INDEXING_D_INDEX_SEE.matches(node) || INDEXING_D_INDEX_SEE_ALSO.matches(node); }
java
private boolean checkElementName(final Node node) { return TOPIC_INDEXTERM.matches(node) || INDEXING_D_INDEX_SORT_AS.matches(node) || INDEXING_D_INDEX_SEE.matches(node) || INDEXING_D_INDEX_SEE_ALSO.matches(node); }
[ "private", "boolean", "checkElementName", "(", "final", "Node", "node", ")", "{", "return", "TOPIC_INDEXTERM", ".", "matches", "(", "node", ")", "||", "INDEXING_D_INDEX_SORT_AS", ".", "matches", "(", "node", ")", "||", "INDEXING_D_INDEX_SEE", ".", "matches", "("...
Check if node is an index term element or specialization of one. @param node element to test @return {@code true} if node is an index term element, otherwise {@code false}
[ "Check", "if", "node", "is", "an", "index", "term", "element", "or", "specialization", "of", "one", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java#L248-L253
train
dita-ot/dita-ot
src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java
IndexPreprocessor.processIndexString
private Node[] processIndexString(final String theIndexString, final List<Node> contents, final Document theTargetDocument, final IndexEntryFoundListener theIndexEntryFoundListener) { final IndexEntry[] indexEntries = IndexStringProcessor.processIndexString(theIndexString, contents); for (final IndexEntry indexEntrie : indexEntries) { theIndexEntryFoundListener.foundEntry(indexEntrie); } return transformToNodes(indexEntries, theTargetDocument, null); }
java
private Node[] processIndexString(final String theIndexString, final List<Node> contents, final Document theTargetDocument, final IndexEntryFoundListener theIndexEntryFoundListener) { final IndexEntry[] indexEntries = IndexStringProcessor.processIndexString(theIndexString, contents); for (final IndexEntry indexEntrie : indexEntries) { theIndexEntryFoundListener.foundEntry(indexEntrie); } return transformToNodes(indexEntries, theTargetDocument, null); }
[ "private", "Node", "[", "]", "processIndexString", "(", "final", "String", "theIndexString", ",", "final", "List", "<", "Node", ">", "contents", ",", "final", "Document", "theTargetDocument", ",", "final", "IndexEntryFoundListener", "theIndexEntryFoundListener", ")", ...
Processes index string and creates nodes with "prefix" in given "namespace_url" from the parsed index entry text. @param theIndexString index string param contents index contents @param theTargetDocument target document to create new nodes @param theIndexEntryFoundListener listener to notify that new index entry was found @return the array of nodes after processing index string
[ "Processes", "index", "string", "and", "creates", "nodes", "with", "prefix", "in", "given", "namespace_url", "from", "the", "parsed", "index", "entry", "text", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java#L269-L278
train
dita-ot/dita-ot
src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java
IndexPreprocessor.createElement
private Element createElement(final Document theTargetDocument, final String theName) { final Element indexEntryNode = theTargetDocument.createElementNS(this.namespace_url, theName); indexEntryNode.setPrefix(this.prefix); return indexEntryNode; }
java
private Element createElement(final Document theTargetDocument, final String theName) { final Element indexEntryNode = theTargetDocument.createElementNS(this.namespace_url, theName); indexEntryNode.setPrefix(this.prefix); return indexEntryNode; }
[ "private", "Element", "createElement", "(", "final", "Document", "theTargetDocument", ",", "final", "String", "theName", ")", "{", "final", "Element", "indexEntryNode", "=", "theTargetDocument", ".", "createElementNS", "(", "this", ".", "namespace_url", ",", "theNam...
Creates element with "prefix" in "namespace_url" with given name for the target document @param theTargetDocument target document @param theName name @return new element
[ "Creates", "element", "with", "prefix", "in", "namespace_url", "with", "given", "name", "for", "the", "target", "document" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.pdf2/src/com/idiominc/ws/opentopic/fo/index2/IndexPreprocessor.java#L388-L392
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/GenListModuleReader.java
GenListModuleReader.getNonTopicrefReferenceSet
public Set<URI> getNonTopicrefReferenceSet() { final Set<URI> res = new HashSet<>(nonTopicrefReferenceSet); res.removeAll(normalProcessingRoleSet); res.removeAll(resourceOnlySet); return res; }
java
public Set<URI> getNonTopicrefReferenceSet() { final Set<URI> res = new HashSet<>(nonTopicrefReferenceSet); res.removeAll(normalProcessingRoleSet); res.removeAll(resourceOnlySet); return res; }
[ "public", "Set", "<", "URI", ">", "getNonTopicrefReferenceSet", "(", ")", "{", "final", "Set", "<", "URI", ">", "res", "=", "new", "HashSet", "<>", "(", "nonTopicrefReferenceSet", ")", ";", "res", ".", "removeAll", "(", "normalProcessingRoleSet", ")", ";", ...
List of files referenced by something other than topicref @return the resource-only set
[ "List", "of", "files", "referenced", "by", "something", "other", "than", "topicref" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GenListModuleReader.java#L147-L152
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/GenListModuleReader.java
GenListModuleReader.getNonCopytoResult
public Set<Reference> getNonCopytoResult() { final Set<Reference> nonCopytoSet = new LinkedHashSet<>(128); nonCopytoSet.addAll(nonConrefCopytoTargets); for (final URI f : conrefTargets) { nonCopytoSet.add(new Reference(stripFragment(f), currentFileFormat())); } for (final URI f : copytoMap.values()) { nonCopytoSet.add(new Reference(stripFragment(f))); } for (final URI f : ignoredCopytoSourceSet) { nonCopytoSet.add(new Reference(stripFragment(f))); } for (final URI filename : coderefTargetSet) { nonCopytoSet.add(new Reference(stripFragment(filename))); } return nonCopytoSet; }
java
public Set<Reference> getNonCopytoResult() { final Set<Reference> nonCopytoSet = new LinkedHashSet<>(128); nonCopytoSet.addAll(nonConrefCopytoTargets); for (final URI f : conrefTargets) { nonCopytoSet.add(new Reference(stripFragment(f), currentFileFormat())); } for (final URI f : copytoMap.values()) { nonCopytoSet.add(new Reference(stripFragment(f))); } for (final URI f : ignoredCopytoSourceSet) { nonCopytoSet.add(new Reference(stripFragment(f))); } for (final URI filename : coderefTargetSet) { nonCopytoSet.add(new Reference(stripFragment(filename))); } return nonCopytoSet; }
[ "public", "Set", "<", "Reference", ">", "getNonCopytoResult", "(", ")", "{", "final", "Set", "<", "Reference", ">", "nonCopytoSet", "=", "new", "LinkedHashSet", "<>", "(", "128", ")", ";", "nonCopytoSet", ".", "addAll", "(", "nonConrefCopytoTargets", ")", ";...
Get all targets except copy-to. @return set of target file path with option format after {@link org.dita.dost.util.Constants#STICK STICK}
[ "Get", "all", "targets", "except", "copy", "-", "to", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GenListModuleReader.java#L245-L262
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/GenListModuleReader.java
GenListModuleReader.getNonConrefCopytoTargets
public Set<URI> getNonConrefCopytoTargets() { final Set<URI> res = new HashSet<>(nonConrefCopytoTargets.size()); for (final Reference r : nonConrefCopytoTargets) { res.add(r.filename); } return res; }
java
public Set<URI> getNonConrefCopytoTargets() { final Set<URI> res = new HashSet<>(nonConrefCopytoTargets.size()); for (final Reference r : nonConrefCopytoTargets) { res.add(r.filename); } return res; }
[ "public", "Set", "<", "URI", ">", "getNonConrefCopytoTargets", "(", ")", "{", "final", "Set", "<", "URI", ">", "res", "=", "new", "HashSet", "<>", "(", "nonConrefCopytoTargets", ".", "size", "(", ")", ")", ";", "for", "(", "final", "Reference", "r", ":...
Get non-conref and non-copyto targets. @return Returns the nonConrefCopytoTargets.
[ "Get", "non", "-", "conref", "and", "non", "-", "copyto", "targets", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GenListModuleReader.java#L314-L320
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/GenListModuleReader.java
GenListModuleReader.canFollow
public static boolean canFollow(URI href) { if (href != null && href.getScheme() != null && href.getScheme().equals("mailto")) { return false; } return true; }
java
public static boolean canFollow(URI href) { if (href != null && href.getScheme() != null && href.getScheme().equals("mailto")) { return false; } return true; }
[ "public", "static", "boolean", "canFollow", "(", "URI", "href", ")", "{", "if", "(", "href", "!=", "null", "&&", "href", ".", "getScheme", "(", ")", "!=", "null", "&&", "href", ".", "getScheme", "(", ")", ".", "equals", "(", "\"mailto\"", ")", ")", ...
Make educated guess in advance whether URI can be resolved to a file.
[ "Make", "educated", "guess", "in", "advance", "whether", "URI", "can", "be", "resolved", "to", "a", "file", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GenListModuleReader.java#L639-L644
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/GenListModuleReader.java
GenListModuleReader.isOutFile
private boolean isOutFile(final URI toCheckPath) { final String path = toCheckPath.getPath(); return !(path != null && path.startsWith(rootDir.getPath())); }
java
private boolean isOutFile(final URI toCheckPath) { final String path = toCheckPath.getPath(); return !(path != null && path.startsWith(rootDir.getPath())); }
[ "private", "boolean", "isOutFile", "(", "final", "URI", "toCheckPath", ")", "{", "final", "String", "path", "=", "toCheckPath", ".", "getPath", "(", ")", ";", "return", "!", "(", "path", "!=", "null", "&&", "path", ".", "startsWith", "(", "rootDir", ".",...
Check if path walks up in parent directories @param toCheckPath path to check @return {@code true} if path walks up, otherwise {@code false}
[ "Check", "if", "path", "walks", "up", "in", "parent", "directories" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/GenListModuleReader.java#L742-L745
train
dita-ot/dita-ot
src/main/java/org/dita/dost/platform/FileGenerator.java
FileGenerator.generate
public void generate(final File fileName) { final File outputFile = removeTemplatePrefix(fileName); templateFile = fileName; try (final InputStream in = new BufferedInputStream(new FileInputStream(fileName)); final OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) { final Transformer transformer = TransformerFactory.newInstance().newTransformer(); final SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(true); XMLReader reader = parserFactory.newSAXParser().getXMLReader(); this.setContentHandler(null); this.setParent(reader); reader = this; final Source source = new SAXSource(reader, new InputSource(in)); source.setSystemId(fileName.toURI().toString()); final Result result = new StreamResult(out); transformer.transform(source, result); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { logger.error("Failed to transform " + fileName + ": " + e.getMessage(), e); } }
java
public void generate(final File fileName) { final File outputFile = removeTemplatePrefix(fileName); templateFile = fileName; try (final InputStream in = new BufferedInputStream(new FileInputStream(fileName)); final OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) { final Transformer transformer = TransformerFactory.newInstance().newTransformer(); final SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(true); XMLReader reader = parserFactory.newSAXParser().getXMLReader(); this.setContentHandler(null); this.setParent(reader); reader = this; final Source source = new SAXSource(reader, new InputSource(in)); source.setSystemId(fileName.toURI().toString()); final Result result = new StreamResult(out); transformer.transform(source, result); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { logger.error("Failed to transform " + fileName + ": " + e.getMessage(), e); } }
[ "public", "void", "generate", "(", "final", "File", "fileName", ")", "{", "final", "File", "outputFile", "=", "removeTemplatePrefix", "(", "fileName", ")", ";", "templateFile", "=", "fileName", ";", "try", "(", "final", "InputStream", "in", "=", "new", "Buff...
Generator the output file. @param fileName filename
[ "Generator", "the", "output", "file", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/FileGenerator.java#L82-L104
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultValues.java
RelaxNGDefaultValues.update
public void update(InputSource in) throws SAXException { defaultValuesCollector = null; PropertyMapBuilder builder = new PropertyMapBuilder(); //Set the resolver builder.put(ValidateProperty.RESOLVER, resolver); builder.put(ValidateProperty.ERROR_HANDLER, eh); PropertyMap properties = builder.toPropertyMap(); try { SchemaWrapper sw = (SchemaWrapper) getSchemaReader().createSchema(in, properties); Pattern start = sw.getStart(); defaultValuesCollector = new DefaultValuesCollector(start); } catch (Exception e) { eh.warning(new SAXParseException("Error loading defaults: " + e.getMessage(), null, e)); } catch (StackOverflowError e) { //EXM-24759 Also catch stackoverflow eh.warning(new SAXParseException("Error loading defaults: " + e.getMessage(), null, null)); } }
java
public void update(InputSource in) throws SAXException { defaultValuesCollector = null; PropertyMapBuilder builder = new PropertyMapBuilder(); //Set the resolver builder.put(ValidateProperty.RESOLVER, resolver); builder.put(ValidateProperty.ERROR_HANDLER, eh); PropertyMap properties = builder.toPropertyMap(); try { SchemaWrapper sw = (SchemaWrapper) getSchemaReader().createSchema(in, properties); Pattern start = sw.getStart(); defaultValuesCollector = new DefaultValuesCollector(start); } catch (Exception e) { eh.warning(new SAXParseException("Error loading defaults: " + e.getMessage(), null, e)); } catch (StackOverflowError e) { //EXM-24759 Also catch stackoverflow eh.warning(new SAXParseException("Error loading defaults: " + e.getMessage(), null, null)); } }
[ "public", "void", "update", "(", "InputSource", "in", ")", "throws", "SAXException", "{", "defaultValuesCollector", "=", "null", ";", "PropertyMapBuilder", "builder", "=", "new", "PropertyMapBuilder", "(", ")", ";", "//Set the resolver", "builder", ".", "put", "("...
Updates the annotation model. @param in The schema input source.
[ "Updates", "the", "annotation", "model", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultValues.java#L147-L165
train
dita-ot/dita-ot
src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultValues.java
RelaxNGDefaultValues.getDefaultAttributes
public List<Attribute> getDefaultAttributes(String localName, String namespace) { if (defaultValuesCollector != null) { return defaultValuesCollector.getDefaultAttributes(localName, namespace); } return null; }
java
public List<Attribute> getDefaultAttributes(String localName, String namespace) { if (defaultValuesCollector != null) { return defaultValuesCollector.getDefaultAttributes(localName, namespace); } return null; }
[ "public", "List", "<", "Attribute", ">", "getDefaultAttributes", "(", "String", "localName", ",", "String", "namespace", ")", "{", "if", "(", "defaultValuesCollector", "!=", "null", ")", "{", "return", "defaultValuesCollector", ".", "getDefaultAttributes", "(", "l...
Get the default attributes for an element. @param localName The element local name. @param namespace The element namespace. Use null or empty for no namespace. @return A list of Attribute objects or null if no defaults.
[ "Get", "the", "default", "attributes", "for", "an", "element", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/ditang/relaxng/defaults/RelaxNGDefaultValues.java#L176-L181
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/MergeTopicParser.java
MergeTopicParser.handleID
private void handleID(final AttributesImpl atts) { String idValue = atts.getValue(ATTRIBUTE_NAME_ID); if (idValue != null) { XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OID, idValue); final URI value = setFragment(dirPath.toURI().resolve(toURI(filePath)), idValue); if (util.findId(value)) { idValue = util.getIdValue(value); } else { idValue = util.addId(value); } XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_ID, idValue); } }
java
private void handleID(final AttributesImpl atts) { String idValue = atts.getValue(ATTRIBUTE_NAME_ID); if (idValue != null) { XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OID, idValue); final URI value = setFragment(dirPath.toURI().resolve(toURI(filePath)), idValue); if (util.findId(value)) { idValue = util.getIdValue(value); } else { idValue = util.addId(value); } XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_ID, idValue); } }
[ "private", "void", "handleID", "(", "final", "AttributesImpl", "atts", ")", "{", "String", "idValue", "=", "atts", ".", "getValue", "(", "ATTRIBUTE_NAME_ID", ")", ";", "if", "(", "idValue", "!=", "null", ")", "{", "XMLUtils", ".", "addOrSetAttribute", "(", ...
Get new value for topic id attribute.
[ "Get", "new", "value", "for", "topic", "id", "attribute", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/MergeTopicParser.java#L104-L116
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/MergeTopicParser.java
MergeTopicParser.handleLocalDita
private URI handleLocalDita(final URI href, final AttributesImpl atts) { final URI attValue = href; final int sharpIndex = attValue.toString().indexOf(SHARP); URI pathFromMap; URI retAttValue; if (sharpIndex != -1) { // href value refer to an id in a topic if (sharpIndex == 0) { pathFromMap = toURI(filePath); } else { pathFromMap = toURI(filePath).resolve(attValue.toString().substring(0, sharpIndex)); } XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OHREF, toURI(pathFromMap + attValue.toString().substring(sharpIndex)).toString()); final String topicID = getTopicID(attValue.getFragment()); final int index = attValue.toString().indexOf(SLASH, sharpIndex); final String elementId = index != -1 ? attValue.toString().substring(index) : ""; final URI pathWithTopicID = setFragment(dirPath.toURI().resolve(pathFromMap), topicID); if (util.findId(pathWithTopicID)) {// topicId found retAttValue = toURI(SHARP + util.getIdValue(pathWithTopicID) + elementId); } else {// topicId not found retAttValue = toURI(SHARP + util.addId(pathWithTopicID) + elementId); } } else { // href value refer to a topic pathFromMap = toURI(filePath).resolve(attValue.toString()); URI absolutePath = dirPath.toURI().resolve(pathFromMap); XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OHREF, pathFromMap.toString()); if (util.findId(absolutePath)) { retAttValue = toURI(SHARP + util.getIdValue(absolutePath)); } else { final String fileId = util.getFirstTopicId(absolutePath, false); final URI key = setFragment(absolutePath, fileId); if (util.findId(key)) { util.addId(absolutePath, util.getIdValue(key)); retAttValue = toURI(SHARP + util.getIdValue(key)); } else { retAttValue = toURI(SHARP + util.addId(absolutePath)); util.addId(key, util.getIdValue(absolutePath)); } } } return retAttValue; }
java
private URI handleLocalDita(final URI href, final AttributesImpl atts) { final URI attValue = href; final int sharpIndex = attValue.toString().indexOf(SHARP); URI pathFromMap; URI retAttValue; if (sharpIndex != -1) { // href value refer to an id in a topic if (sharpIndex == 0) { pathFromMap = toURI(filePath); } else { pathFromMap = toURI(filePath).resolve(attValue.toString().substring(0, sharpIndex)); } XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OHREF, toURI(pathFromMap + attValue.toString().substring(sharpIndex)).toString()); final String topicID = getTopicID(attValue.getFragment()); final int index = attValue.toString().indexOf(SLASH, sharpIndex); final String elementId = index != -1 ? attValue.toString().substring(index) : ""; final URI pathWithTopicID = setFragment(dirPath.toURI().resolve(pathFromMap), topicID); if (util.findId(pathWithTopicID)) {// topicId found retAttValue = toURI(SHARP + util.getIdValue(pathWithTopicID) + elementId); } else {// topicId not found retAttValue = toURI(SHARP + util.addId(pathWithTopicID) + elementId); } } else { // href value refer to a topic pathFromMap = toURI(filePath).resolve(attValue.toString()); URI absolutePath = dirPath.toURI().resolve(pathFromMap); XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_OHREF, pathFromMap.toString()); if (util.findId(absolutePath)) { retAttValue = toURI(SHARP + util.getIdValue(absolutePath)); } else { final String fileId = util.getFirstTopicId(absolutePath, false); final URI key = setFragment(absolutePath, fileId); if (util.findId(key)) { util.addId(absolutePath, util.getIdValue(key)); retAttValue = toURI(SHARP + util.getIdValue(key)); } else { retAttValue = toURI(SHARP + util.addId(absolutePath)); util.addId(key, util.getIdValue(absolutePath)); } } } return retAttValue; }
[ "private", "URI", "handleLocalDita", "(", "final", "URI", "href", ",", "final", "AttributesImpl", "atts", ")", "{", "final", "URI", "attValue", "=", "href", ";", "final", "int", "sharpIndex", "=", "attValue", ".", "toString", "(", ")", ".", "indexOf", "(",...
Rewrite local DITA href value. @param href href attribute value @return rewritten href value
[ "Rewrite", "local", "DITA", "href", "value", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/MergeTopicParser.java#L124-L165
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/MergeTopicParser.java
MergeTopicParser.parse
public void parse(final String filename, final File dir) { filePath = stripFragment(filename); dirPath = dir; try { final File f = new File(dir, filePath); reader.setErrorHandler(new DITAOTXMLErrorHandler(f.getAbsolutePath(), logger)); logger.info("Processing " + f.getAbsolutePath()); reader.parse(f.toURI().toString()); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { throw new RuntimeException("Failed to parse " + filename + ": " + e.getMessage(), e); } }
java
public void parse(final String filename, final File dir) { filePath = stripFragment(filename); dirPath = dir; try { final File f = new File(dir, filePath); reader.setErrorHandler(new DITAOTXMLErrorHandler(f.getAbsolutePath(), logger)); logger.info("Processing " + f.getAbsolutePath()); reader.parse(f.toURI().toString()); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { throw new RuntimeException("Failed to parse " + filename + ": " + e.getMessage(), e); } }
[ "public", "void", "parse", "(", "final", "String", "filename", ",", "final", "File", "dir", ")", "{", "filePath", "=", "stripFragment", "(", "filename", ")", ";", "dirPath", "=", "dir", ";", "try", "{", "final", "File", "f", "=", "new", "File", "(", ...
Parse the file to update id. @param filename relative topic system path, may contain a fragment part @param dir topic directory system path
[ "Parse", "the", "file", "to", "update", "id", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/MergeTopicParser.java#L178-L191
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/MergeTopicParser.java
MergeTopicParser.handleHref
private void handleHref(final String classValue, final AttributesImpl atts) { final URI attValue = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); if (attValue != null) { final String scopeValue = atts.getValue(ATTRIBUTE_NAME_SCOPE); if ((scopeValue == null || ATTR_SCOPE_VALUE_LOCAL.equals(scopeValue)) && attValue.getScheme() == null) { final String formatValue = atts.getValue(ATTRIBUTE_NAME_FORMAT); // The scope for @href is local if ((TOPIC_XREF.matches(classValue) || TOPIC_LINK.matches(classValue) || TOPIC_LQ.matches(classValue) // term, keyword, cite, ph, and dt are resolved as keyref can make them links || TOPIC_TERM.matches(classValue) || TOPIC_KEYWORD.matches(classValue) || TOPIC_CITE.matches(classValue) || TOPIC_PH.matches(classValue) || TOPIC_DT.matches(classValue)) && (formatValue == null || ATTR_FORMAT_VALUE_DITA.equals(formatValue))) { // local xref or link that refers to dita file XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_HREF, handleLocalDita(attValue, atts).toString()); } else { // local @href other than local xref and link that refers to // dita file XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_HREF, handleLocalHref(attValue).toString()); } } } }
java
private void handleHref(final String classValue, final AttributesImpl atts) { final URI attValue = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); if (attValue != null) { final String scopeValue = atts.getValue(ATTRIBUTE_NAME_SCOPE); if ((scopeValue == null || ATTR_SCOPE_VALUE_LOCAL.equals(scopeValue)) && attValue.getScheme() == null) { final String formatValue = atts.getValue(ATTRIBUTE_NAME_FORMAT); // The scope for @href is local if ((TOPIC_XREF.matches(classValue) || TOPIC_LINK.matches(classValue) || TOPIC_LQ.matches(classValue) // term, keyword, cite, ph, and dt are resolved as keyref can make them links || TOPIC_TERM.matches(classValue) || TOPIC_KEYWORD.matches(classValue) || TOPIC_CITE.matches(classValue) || TOPIC_PH.matches(classValue) || TOPIC_DT.matches(classValue)) && (formatValue == null || ATTR_FORMAT_VALUE_DITA.equals(formatValue))) { // local xref or link that refers to dita file XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_HREF, handleLocalDita(attValue, atts).toString()); } else { // local @href other than local xref and link that refers to // dita file XMLUtils.addOrSetAttribute(atts, ATTRIBUTE_NAME_HREF, handleLocalHref(attValue).toString()); } } } }
[ "private", "void", "handleHref", "(", "final", "String", "classValue", ",", "final", "AttributesImpl", "atts", ")", "{", "final", "URI", "attValue", "=", "toURI", "(", "atts", ".", "getValue", "(", "ATTRIBUTE_NAME_HREF", ")", ")", ";", "if", "(", "attValue",...
Rewrite href attribute. @param classValue element class value @param atts attributes
[ "Rewrite", "href", "attribute", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/MergeTopicParser.java#L228-L251
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/MergeTopicParser.java
MergeTopicParser.handleLocalHref
private URI handleLocalHref(final URI attValue) { final URI current = new File(dirPath, filePath).toURI().normalize(); final URI reference = current.resolve(attValue); final URI merge = output.toURI(); return getRelativePath(merge, reference); }
java
private URI handleLocalHref(final URI attValue) { final URI current = new File(dirPath, filePath).toURI().normalize(); final URI reference = current.resolve(attValue); final URI merge = output.toURI(); return getRelativePath(merge, reference); }
[ "private", "URI", "handleLocalHref", "(", "final", "URI", "attValue", ")", "{", "final", "URI", "current", "=", "new", "File", "(", "dirPath", ",", "filePath", ")", ".", "toURI", "(", ")", ".", "normalize", "(", ")", ";", "final", "URI", "reference", "...
Rewrite local non-DITA href value. @param attValue href attribute value @return rewritten href value
[ "Rewrite", "local", "non", "-", "DITA", "href", "value", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/MergeTopicParser.java#L259-L264
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/Main.java
Main.start
public static void start(final String[] args, final Properties additionalUserProperties, final ClassLoader coreLoader) { final Main m = new Main(); m.startAnt(args, additionalUserProperties, coreLoader); }
java
public static void start(final String[] args, final Properties additionalUserProperties, final ClassLoader coreLoader) { final Main m = new Main(); m.startAnt(args, additionalUserProperties, coreLoader); }
[ "public", "static", "void", "start", "(", "final", "String", "[", "]", "args", ",", "final", "Properties", "additionalUserProperties", ",", "final", "ClassLoader", "coreLoader", ")", "{", "final", "Main", "m", "=", "new", "Main", "(", ")", ";", "m", ".", ...
Creates a new instance of this class using the arguments specified, gives it any extra user properties which have been specified, and then runs the build using the classloader provided. @param args Command line arguments. Must not be <code>null</code>. @param additionalUserProperties Any extra properties to use in this build. May be <code>null</code>, which is the equivalent to passing in an empty set of properties. @param coreLoader Classloader used for core classes. May be <code>null</code> in which case the system classloader is used.
[ "Creates", "a", "new", "instance", "of", "this", "class", "using", "the", "arguments", "specified", "gives", "it", "any", "extra", "user", "properties", "which", "have", "been", "specified", "and", "then", "runs", "the", "build", "using", "the", "classloader",...
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L140-L144
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/Main.java
Main.handleLogfile
private void handleLogfile() { if (args.logFile != null) { FileUtils.close(out); FileUtils.close(err); } }
java
private void handleLogfile() { if (args.logFile != null) { FileUtils.close(out); FileUtils.close(err); } }
[ "private", "void", "handleLogfile", "(", ")", "{", "if", "(", "args", ".", "logFile", "!=", "null", ")", "{", "FileUtils", ".", "close", "(", "out", ")", ";", "FileUtils", ".", "close", "(", "err", ")", ";", "}", "}" ]
Close logfiles, if we have been writing to them. @since Ant 1.6
[ "Close", "logfiles", "if", "we", "have", "been", "writing", "to", "them", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L233-L238
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/Main.java
Main.addBuildListeners
@Override protected void addBuildListeners(final Project project) { // Add the default listener project.addBuildListener(createLogger()); final int count = args.listeners.size(); for (int i = 0; i < count; i++) { final String className = args.listeners.elementAt(i); final BuildListener listener = ClasspathUtils.newInstance(className, Main.class.getClassLoader(), BuildListener.class); project.setProjectReference(listener); project.addBuildListener(listener); } }
java
@Override protected void addBuildListeners(final Project project) { // Add the default listener project.addBuildListener(createLogger()); final int count = args.listeners.size(); for (int i = 0; i < count; i++) { final String className = args.listeners.elementAt(i); final BuildListener listener = ClasspathUtils.newInstance(className, Main.class.getClassLoader(), BuildListener.class); project.setProjectReference(listener); project.addBuildListener(listener); } }
[ "@", "Override", "protected", "void", "addBuildListeners", "(", "final", "Project", "project", ")", "{", "// Add the default listener", "project", ".", "addBuildListener", "(", "createLogger", "(", ")", ")", ";", "final", "int", "count", "=", "args", ".", "liste...
Adds the listeners specified in the command line arguments, along with the default listener, to the specified project. @param project The project to add listeners to. Must not be <code>null</code>.
[ "Adds", "the", "listeners", "specified", "in", "the", "command", "line", "arguments", "along", "with", "the", "default", "listener", "to", "the", "specified", "project", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L666-L680
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/Main.java
Main.addInputHandler
private void addInputHandler(final Project project) throws BuildException { final InputHandler handler; if (args.inputHandlerClassname == null) { handler = new DefaultInputHandler(); } else { handler = ClasspathUtils.newInstance(args.inputHandlerClassname, Main.class.getClassLoader(), InputHandler.class); project.setProjectReference(handler); } project.setInputHandler(handler); }
java
private void addInputHandler(final Project project) throws BuildException { final InputHandler handler; if (args.inputHandlerClassname == null) { handler = new DefaultInputHandler(); } else { handler = ClasspathUtils.newInstance(args.inputHandlerClassname, Main.class.getClassLoader(), InputHandler.class); project.setProjectReference(handler); } project.setInputHandler(handler); }
[ "private", "void", "addInputHandler", "(", "final", "Project", "project", ")", "throws", "BuildException", "{", "final", "InputHandler", "handler", ";", "if", "(", "args", ".", "inputHandlerClassname", "==", "null", ")", "{", "handler", "=", "new", "DefaultInput...
Creates the InputHandler and adds it to the project. @param project the project instance. @throws BuildException if a specified InputHandler implementation could not be loaded.
[ "Creates", "the", "InputHandler", "and", "adds", "it", "to", "the", "project", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L689-L699
train
dita-ot/dita-ot
src/main/java/org/dita/dost/invoker/Main.java
Main.createLogger
private BuildLogger createLogger() { BuildLogger logger; if (args.loggerClassname != null) { try { logger = ClasspathUtils.newInstance(args.loggerClassname, Main.class.getClassLoader(), BuildLogger.class); } catch (final BuildException e) { printErrorMessage("The specified logger class " + args.loggerClassname + " could not be used because " + e.getMessage()); throw new RuntimeException(); } } else { logger = new DefaultLogger(); ((DefaultLogger) logger).useColor(args.useColor); } logger.setMessageOutputLevel(args.msgOutputLevel); logger.setOutputPrintStream(out); logger.setErrorPrintStream(err); logger.setEmacsMode(args.emacsMode); return logger; }
java
private BuildLogger createLogger() { BuildLogger logger; if (args.loggerClassname != null) { try { logger = ClasspathUtils.newInstance(args.loggerClassname, Main.class.getClassLoader(), BuildLogger.class); } catch (final BuildException e) { printErrorMessage("The specified logger class " + args.loggerClassname + " could not be used because " + e.getMessage()); throw new RuntimeException(); } } else { logger = new DefaultLogger(); ((DefaultLogger) logger).useColor(args.useColor); } logger.setMessageOutputLevel(args.msgOutputLevel); logger.setOutputPrintStream(out); logger.setErrorPrintStream(err); logger.setEmacsMode(args.emacsMode); return logger; }
[ "private", "BuildLogger", "createLogger", "(", ")", "{", "BuildLogger", "logger", ";", "if", "(", "args", ".", "loggerClassname", "!=", "null", ")", "{", "try", "{", "logger", "=", "ClasspathUtils", ".", "newInstance", "(", "args", ".", "loggerClassname", ",...
Creates the default build logger for sending build events to the ant log. @return the logger instance for this build.
[ "Creates", "the", "default", "build", "logger", "for", "sending", "build", "events", "to", "the", "ant", "log", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/invoker/Main.java#L711-L733
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/XsltModule.java
XsltModule.configureSaxonExtensions
private void configureSaxonExtensions(SaxonTransformerFactory tfi) { final net.sf.saxon.Configuration conf = tfi.getConfiguration(); for (ExtensionFunctionDefinition def : ServiceLoader.load(ExtensionFunctionDefinition.class)) { try { conf.registerExtensionFunction(def.getClass().newInstance()); } catch (InstantiationException e) { throw new RuntimeException("Failed to register " + def.getFunctionQName().getDisplayName() + ". Cannot create instance of " + def.getClass().getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
java
private void configureSaxonExtensions(SaxonTransformerFactory tfi) { final net.sf.saxon.Configuration conf = tfi.getConfiguration(); for (ExtensionFunctionDefinition def : ServiceLoader.load(ExtensionFunctionDefinition.class)) { try { conf.registerExtensionFunction(def.getClass().newInstance()); } catch (InstantiationException e) { throw new RuntimeException("Failed to register " + def.getFunctionQName().getDisplayName() + ". Cannot create instance of " + def.getClass().getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
[ "private", "void", "configureSaxonExtensions", "(", "SaxonTransformerFactory", "tfi", ")", "{", "final", "net", ".", "sf", ".", "saxon", ".", "Configuration", "conf", "=", "tfi", ".", "getConfiguration", "(", ")", ";", "for", "(", "ExtensionFunctionDefinition", ...
Registers Saxon full integrated function definitions. The intgrated function should be an instance of net.sf.saxon.lib.ExtensionFunctionDefinition abstract class. @see <a href="https://www.saxonica.com/html/documentation/extensibility/integratedfunctions/ext-full-J.html">Saxon Java extension functions: full interface</a>
[ "Registers", "Saxon", "full", "integrated", "function", "definitions", ".", "The", "intgrated", "function", "should", "be", "an", "instance", "of", "net", ".", "sf", ".", "saxon", ".", "lib", ".", "ExtensionFunctionDefinition", "abstract", "class", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/XsltModule.java#L272-L284
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/KeyDef.java
KeyDef.writeKeydef
public static void writeKeydef(final File keydefFile, final Collection<KeyDef> keydefs) throws DITAOTException { XMLStreamWriter keydef = null; try (OutputStream out = new FileOutputStream(keydefFile)) { keydef = XMLOutputFactory.newInstance().createXMLStreamWriter(out, "UTF-8"); keydef.writeStartDocument(); keydef.writeStartElement(ELEMENT_STUB); for (final KeyDef k : keydefs) { keydef.writeStartElement(ELEMENT_KEYDEF); keydef.writeAttribute(ATTRIBUTE_KEYS, k.keys); if (k.href != null) { keydef.writeAttribute(ATTRIBUTE_HREF, k.href.toString()); } if (k.scope != null) { keydef.writeAttribute(ATTRIBUTE_SCOPE, k.scope); } if (k.format != null) { keydef.writeAttribute(ATTRIBUTE_FORMAT, k.format); } if (k.source != null) { keydef.writeAttribute(ATTRIBUTE_SOURCE, k.source.toString()); } keydef.writeEndElement(); } keydef.writeEndDocument(); } catch (final XMLStreamException | IOException e) { throw new DITAOTException("Failed to write key definition file " + keydefFile + ": " + e.getMessage(), e); } finally { if (keydef != null) { try { keydef.close(); } catch (final XMLStreamException e) { } } } }
java
public static void writeKeydef(final File keydefFile, final Collection<KeyDef> keydefs) throws DITAOTException { XMLStreamWriter keydef = null; try (OutputStream out = new FileOutputStream(keydefFile)) { keydef = XMLOutputFactory.newInstance().createXMLStreamWriter(out, "UTF-8"); keydef.writeStartDocument(); keydef.writeStartElement(ELEMENT_STUB); for (final KeyDef k : keydefs) { keydef.writeStartElement(ELEMENT_KEYDEF); keydef.writeAttribute(ATTRIBUTE_KEYS, k.keys); if (k.href != null) { keydef.writeAttribute(ATTRIBUTE_HREF, k.href.toString()); } if (k.scope != null) { keydef.writeAttribute(ATTRIBUTE_SCOPE, k.scope); } if (k.format != null) { keydef.writeAttribute(ATTRIBUTE_FORMAT, k.format); } if (k.source != null) { keydef.writeAttribute(ATTRIBUTE_SOURCE, k.source.toString()); } keydef.writeEndElement(); } keydef.writeEndDocument(); } catch (final XMLStreamException | IOException e) { throw new DITAOTException("Failed to write key definition file " + keydefFile + ": " + e.getMessage(), e); } finally { if (keydef != null) { try { keydef.close(); } catch (final XMLStreamException e) { } } } }
[ "public", "static", "void", "writeKeydef", "(", "final", "File", "keydefFile", ",", "final", "Collection", "<", "KeyDef", ">", "keydefs", ")", "throws", "DITAOTException", "{", "XMLStreamWriter", "keydef", "=", "null", ";", "try", "(", "OutputStream", "out", "...
Write key definition XML configuration file @param keydefFile key definition file @param keydefs list of key definitions @throws DITAOTException if writing configuration file failed
[ "Write", "key", "definition", "XML", "configuration", "file" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/KeyDef.java#L87-L121
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/BranchFilterModule.java
BranchFilterModule.getTopicrefs
private List<Element> getTopicrefs(final Element root) { final List<Element> res = new ArrayList<>(); final NodeList all = root.getElementsByTagName("*"); for (int i = 0; i < all.getLength(); i++) { final Element elem = (Element) all.item(i); if (MAP_TOPICREF.matches(elem) && isDitaFormat(elem.getAttributeNode(ATTRIBUTE_NAME_FORMAT)) && !elem.getAttribute(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_EXTERNAL)) { res.add(elem); } } return res; }
java
private List<Element> getTopicrefs(final Element root) { final List<Element> res = new ArrayList<>(); final NodeList all = root.getElementsByTagName("*"); for (int i = 0; i < all.getLength(); i++) { final Element elem = (Element) all.item(i); if (MAP_TOPICREF.matches(elem) && isDitaFormat(elem.getAttributeNode(ATTRIBUTE_NAME_FORMAT)) && !elem.getAttribute(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_EXTERNAL)) { res.add(elem); } } return res; }
[ "private", "List", "<", "Element", ">", "getTopicrefs", "(", "final", "Element", "root", ")", "{", "final", "List", "<", "Element", ">", "res", "=", "new", "ArrayList", "<>", "(", ")", ";", "final", "NodeList", "all", "=", "root", ".", "getElementsByTagN...
Get all topicrefs
[ "Get", "all", "topicrefs" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/BranchFilterModule.java#L263-L275
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/BranchFilterModule.java
BranchFilterModule.generateCopies
private void generateCopies(final Element topicref, final List<FilterUtils> filters) { final List<FilterUtils> fs = combineFilterUtils(topicref, filters); final String copyTo = topicref.getAttribute(BRANCH_COPY_TO); if (!copyTo.isEmpty()) { final URI dstUri = map.resolve(copyTo); final URI dstAbsUri = job.tempDirURI.resolve(dstUri); final String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF); final URI srcUri = map.resolve(href); final URI srcAbsUri = job.tempDirURI.resolve(srcUri); final FileInfo srcFileInfo = job.getFileInfo(srcUri); if (srcFileInfo != null) { // final FileInfo fi = new FileInfo.Builder(srcFileInfo).uri(dstUri).build(); // TODO: Maybe Job should be updated earlier? // job.add(fi); logger.info("Filtering " + srcAbsUri + " to " + dstAbsUri); final ProfilingFilter writer = new ProfilingFilter(); writer.setLogger(logger); writer.setJob(job); writer.setFilterUtils(fs); writer.setCurrentFile(dstAbsUri); final List<XMLFilter> pipe = singletonList(writer); final File dstDirUri = new File(dstAbsUri.resolve(".")); if (!dstDirUri.exists() && !dstDirUri.mkdirs()) { logger.error("Failed to create directory " + dstDirUri); } try { xmlUtils.transform(srcAbsUri, dstAbsUri, pipe); } catch (final DITAOTException e) { logger.error("Failed to filter " + srcAbsUri + " to " + dstAbsUri + ": " + e.getMessage(), e); } topicref.setAttribute(ATTRIBUTE_NAME_HREF, copyTo); topicref.removeAttribute(BRANCH_COPY_TO); // disable filtering again topicref.setAttribute(SKIP_FILTER, Boolean.TRUE.toString()); } } for (final Element child: getChildElements(topicref, MAP_TOPICREF)) { if (DITAVAREF_D_DITAVALREF.matches(child)) { continue; } generateCopies(child, fs); } }
java
private void generateCopies(final Element topicref, final List<FilterUtils> filters) { final List<FilterUtils> fs = combineFilterUtils(topicref, filters); final String copyTo = topicref.getAttribute(BRANCH_COPY_TO); if (!copyTo.isEmpty()) { final URI dstUri = map.resolve(copyTo); final URI dstAbsUri = job.tempDirURI.resolve(dstUri); final String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF); final URI srcUri = map.resolve(href); final URI srcAbsUri = job.tempDirURI.resolve(srcUri); final FileInfo srcFileInfo = job.getFileInfo(srcUri); if (srcFileInfo != null) { // final FileInfo fi = new FileInfo.Builder(srcFileInfo).uri(dstUri).build(); // TODO: Maybe Job should be updated earlier? // job.add(fi); logger.info("Filtering " + srcAbsUri + " to " + dstAbsUri); final ProfilingFilter writer = new ProfilingFilter(); writer.setLogger(logger); writer.setJob(job); writer.setFilterUtils(fs); writer.setCurrentFile(dstAbsUri); final List<XMLFilter> pipe = singletonList(writer); final File dstDirUri = new File(dstAbsUri.resolve(".")); if (!dstDirUri.exists() && !dstDirUri.mkdirs()) { logger.error("Failed to create directory " + dstDirUri); } try { xmlUtils.transform(srcAbsUri, dstAbsUri, pipe); } catch (final DITAOTException e) { logger.error("Failed to filter " + srcAbsUri + " to " + dstAbsUri + ": " + e.getMessage(), e); } topicref.setAttribute(ATTRIBUTE_NAME_HREF, copyTo); topicref.removeAttribute(BRANCH_COPY_TO); // disable filtering again topicref.setAttribute(SKIP_FILTER, Boolean.TRUE.toString()); } } for (final Element child: getChildElements(topicref, MAP_TOPICREF)) { if (DITAVAREF_D_DITAVALREF.matches(child)) { continue; } generateCopies(child, fs); } }
[ "private", "void", "generateCopies", "(", "final", "Element", "topicref", ",", "final", "List", "<", "FilterUtils", ">", "filters", ")", "{", "final", "List", "<", "FilterUtils", ">", "fs", "=", "combineFilterUtils", "(", "topicref", ",", "filters", ")", ";"...
Copy and filter topics for branches. These topics have a new name and will be added to job configuration.
[ "Copy", "and", "filter", "topics", "for", "branches", ".", "These", "topics", "have", "a", "new", "name", "and", "will", "be", "added", "to", "job", "configuration", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/BranchFilterModule.java#L342-L388
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/BranchFilterModule.java
BranchFilterModule.filterTopics
private void filterTopics(final Element topicref, final List<FilterUtils> filters) { final List<FilterUtils> fs = combineFilterUtils(topicref, filters); final String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF); final Attr skipFilter = topicref.getAttributeNode(SKIP_FILTER); final URI srcAbsUri = job.tempDirURI.resolve(map.resolve(href)); if (!fs.isEmpty() && skipFilter == null && !filtered.contains(srcAbsUri) && !href.isEmpty() && !ATTR_SCOPE_VALUE_EXTERNAL.equals(topicref.getAttribute(ATTRIBUTE_NAME_SCOPE)) && !ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(topicref.getAttribute(ATTRIBUTE_NAME_PROCESSING_ROLE)) && isDitaFormat(topicref.getAttributeNode(ATTRIBUTE_NAME_FORMAT))) { final ProfilingFilter writer = new ProfilingFilter(); writer.setLogger(logger); writer.setJob(job); writer.setFilterUtils(fs); writer.setCurrentFile(srcAbsUri); final List<XMLFilter> pipe = singletonList(writer); logger.info("Filtering " + srcAbsUri); try { xmlUtils.transform(srcAbsUri, pipe); } catch (final DITAOTException e) { logger.error("Failed to filter " + srcAbsUri + ": " + e.getMessage(), e); } filtered.add(srcAbsUri); } if (skipFilter != null) { topicref.removeAttributeNode(skipFilter); } for (final Element child: getChildElements(topicref, MAP_TOPICREF)) { if (DITAVAREF_D_DITAVALREF.matches(child)) { continue; } filterTopics(child, fs); } }
java
private void filterTopics(final Element topicref, final List<FilterUtils> filters) { final List<FilterUtils> fs = combineFilterUtils(topicref, filters); final String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF); final Attr skipFilter = topicref.getAttributeNode(SKIP_FILTER); final URI srcAbsUri = job.tempDirURI.resolve(map.resolve(href)); if (!fs.isEmpty() && skipFilter == null && !filtered.contains(srcAbsUri) && !href.isEmpty() && !ATTR_SCOPE_VALUE_EXTERNAL.equals(topicref.getAttribute(ATTRIBUTE_NAME_SCOPE)) && !ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(topicref.getAttribute(ATTRIBUTE_NAME_PROCESSING_ROLE)) && isDitaFormat(topicref.getAttributeNode(ATTRIBUTE_NAME_FORMAT))) { final ProfilingFilter writer = new ProfilingFilter(); writer.setLogger(logger); writer.setJob(job); writer.setFilterUtils(fs); writer.setCurrentFile(srcAbsUri); final List<XMLFilter> pipe = singletonList(writer); logger.info("Filtering " + srcAbsUri); try { xmlUtils.transform(srcAbsUri, pipe); } catch (final DITAOTException e) { logger.error("Failed to filter " + srcAbsUri + ": " + e.getMessage(), e); } filtered.add(srcAbsUri); } if (skipFilter != null) { topicref.removeAttributeNode(skipFilter); } for (final Element child: getChildElements(topicref, MAP_TOPICREF)) { if (DITAVAREF_D_DITAVALREF.matches(child)) { continue; } filterTopics(child, fs); } }
[ "private", "void", "filterTopics", "(", "final", "Element", "topicref", ",", "final", "List", "<", "FilterUtils", ">", "filters", ")", "{", "final", "List", "<", "FilterUtils", ">", "fs", "=", "combineFilterUtils", "(", "topicref", ",", "filters", ")", ";", ...
Modify and filter topics for branches. These files use an existing file name.
[ "Modify", "and", "filter", "topics", "for", "branches", ".", "These", "files", "use", "an", "existing", "file", "name", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/BranchFilterModule.java#L391-L428
train
dita-ot/dita-ot
src/main/java/org/dita/dost/module/BranchFilterModule.java
BranchFilterModule.getFilterUtils
private FilterUtils getFilterUtils(final Element ditavalRef) { if (ditavalRef.getAttribute(ATTRIBUTE_NAME_HREF).isEmpty()) { return null; } 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; FilterUtils f = filterCache.get(ditaval); if (f == null) { ditaValReader.filterReset(); logger.info("Reading " + ditaval); ditaValReader.read(ditaval); Map<FilterUtils.FilterKey, FilterUtils.Action> filterMap = ditaValReader.getFilterMap(); f = new FilterUtils(filterMap, ditaValReader.getForegroundConflictColor(), ditaValReader.getBackgroundConflictColor()); f.setLogger(logger); filterCache.put(ditaval, f); } return f; }
java
private FilterUtils getFilterUtils(final Element ditavalRef) { if (ditavalRef.getAttribute(ATTRIBUTE_NAME_HREF).isEmpty()) { return null; } 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; FilterUtils f = filterCache.get(ditaval); if (f == null) { ditaValReader.filterReset(); logger.info("Reading " + ditaval); ditaValReader.read(ditaval); Map<FilterUtils.FilterKey, FilterUtils.Action> filterMap = ditaValReader.getFilterMap(); f = new FilterUtils(filterMap, ditaValReader.getForegroundConflictColor(), ditaValReader.getBackgroundConflictColor()); f.setLogger(logger); filterCache.put(ditaval, f); } return f; }
[ "private", "FilterUtils", "getFilterUtils", "(", "final", "Element", "ditavalRef", ")", "{", "if", "(", "ditavalRef", ".", "getAttribute", "(", "ATTRIBUTE_NAME_HREF", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "final", "URI", "href"...
Read and cache filter.
[ "Read", "and", "cache", "filter", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/BranchFilterModule.java#L433-L452
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/KeydefFilter.java
KeydefFilter.handleKeysAttr
private void handleKeysAttr(final Attributes atts) { final String attrValue = atts.getValue(ATTRIBUTE_NAME_KEYS); if (attrValue != null) { URI target = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); final URI copyTo = toURI(atts.getValue(ATTRIBUTE_NAME_COPY_TO)); if (copyTo != null) { target = copyTo; } final String keyRef = atts.getValue(ATTRIBUTE_NAME_KEYREF); // Many keys can be defined in a single definition, like // keys="a b c", a, b and c are seperated by blank. for (final String key : attrValue.trim().split("\\s+")) { if (!keysDefMap.containsKey(key)) { if (target != null && !target.toString().isEmpty()) { final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE); final String attrFormat = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (attrScope != null && (attrScope.equals(ATTR_SCOPE_VALUE_EXTERNAL) || attrScope.equals(ATTR_SCOPE_VALUE_PEER))) { keysDefMap.put(key, new KeyDef(key, target, attrScope, attrFormat, null, null)); } else { String tail = null; if (target.getFragment() != null) { tail = target.getFragment(); target = stripFragment(target); } if (!target.isAbsolute()) { target = currentDir.resolve(target); } keysDefMap.put(key, new KeyDef(key, setFragment(target, tail), ATTR_SCOPE_VALUE_LOCAL, attrFormat, null, null)); } } else if (!StringUtils.isEmptyString(keyRef)) { // store multi-level keys. keysRefMap.put(key, keyRef); } else { // target is null or empty, it is useful in the future // when consider the content of key definition keysDefMap.put(key, new KeyDef(key, null, null, null, null, null)); } } else { logger.info(MessageUtils.getMessage("DOTJ045I", key).toString()); } } } }
java
private void handleKeysAttr(final Attributes atts) { final String attrValue = atts.getValue(ATTRIBUTE_NAME_KEYS); if (attrValue != null) { URI target = toURI(atts.getValue(ATTRIBUTE_NAME_HREF)); final URI copyTo = toURI(atts.getValue(ATTRIBUTE_NAME_COPY_TO)); if (copyTo != null) { target = copyTo; } final String keyRef = atts.getValue(ATTRIBUTE_NAME_KEYREF); // Many keys can be defined in a single definition, like // keys="a b c", a, b and c are seperated by blank. for (final String key : attrValue.trim().split("\\s+")) { if (!keysDefMap.containsKey(key)) { if (target != null && !target.toString().isEmpty()) { final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE); final String attrFormat = atts.getValue(ATTRIBUTE_NAME_FORMAT); if (attrScope != null && (attrScope.equals(ATTR_SCOPE_VALUE_EXTERNAL) || attrScope.equals(ATTR_SCOPE_VALUE_PEER))) { keysDefMap.put(key, new KeyDef(key, target, attrScope, attrFormat, null, null)); } else { String tail = null; if (target.getFragment() != null) { tail = target.getFragment(); target = stripFragment(target); } if (!target.isAbsolute()) { target = currentDir.resolve(target); } keysDefMap.put(key, new KeyDef(key, setFragment(target, tail), ATTR_SCOPE_VALUE_LOCAL, attrFormat, null, null)); } } else if (!StringUtils.isEmptyString(keyRef)) { // store multi-level keys. keysRefMap.put(key, keyRef); } else { // target is null or empty, it is useful in the future // when consider the content of key definition keysDefMap.put(key, new KeyDef(key, null, null, null, null, null)); } } else { logger.info(MessageUtils.getMessage("DOTJ045I", key).toString()); } } } }
[ "private", "void", "handleKeysAttr", "(", "final", "Attributes", "atts", ")", "{", "final", "String", "attrValue", "=", "atts", ".", "getValue", "(", "ATTRIBUTE_NAME_KEYS", ")", ";", "if", "(", "attrValue", "!=", "null", ")", "{", "URI", "target", "=", "to...
Parse the keys attributes. @param atts all attributes
[ "Parse", "the", "keys", "attributes", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/KeydefFilter.java#L107-L151
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/KeydefFilter.java
KeydefFilter.getKeysList
private List<String> getKeysList(final String key, final Map<String, String> keysRefMap) { final List<String> list = new ArrayList<>(); // Iterate the map to look for multi-level keys for (Entry<String, String> entry : keysRefMap.entrySet()) { // Multi-level key found if (entry.getValue().equals(key)) { // add key into the list final String entryKey = entry.getKey(); list.add(entryKey); // still have multi-level keys if (keysRefMap.containsValue(entryKey)) { // rescuive point final List<String> tempList = getKeysList(entryKey, keysRefMap); list.addAll(tempList); } } } return list; }
java
private List<String> getKeysList(final String key, final Map<String, String> keysRefMap) { final List<String> list = new ArrayList<>(); // Iterate the map to look for multi-level keys for (Entry<String, String> entry : keysRefMap.entrySet()) { // Multi-level key found if (entry.getValue().equals(key)) { // add key into the list final String entryKey = entry.getKey(); list.add(entryKey); // still have multi-level keys if (keysRefMap.containsValue(entryKey)) { // rescuive point final List<String> tempList = getKeysList(entryKey, keysRefMap); list.addAll(tempList); } } } return list; }
[ "private", "List", "<", "String", ">", "getKeysList", "(", "final", "String", "key", ",", "final", "Map", "<", "String", ",", "String", ">", "keysRefMap", ")", "{", "final", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ...
Get multi-level keys list
[ "Get", "multi", "-", "level", "keys", "list" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/KeydefFilter.java#L156-L174
train
dita-ot/dita-ot
src/main/java/org/dita/dost/reader/KeydefFilter.java
KeydefFilter.checkMultiLevelKeys
private void checkMultiLevelKeys(final Map<String, KeyDef> keysDefMap, final Map<String, String> keysRefMap) { String key; KeyDef value; // tempMap storing values to avoid ConcurrentModificationException final Map<String, KeyDef> tempMap = new HashMap<>(); for (Entry<String, KeyDef> entry : keysDefMap.entrySet()) { key = entry.getKey(); value = entry.getValue(); // there is multi-level keys exist. if (keysRefMap.containsValue(key)) { // get multi-level keys final List<String> keysList = getKeysList(key, keysRefMap); for (final String multikey : keysList) { // update tempMap tempMap.put(multikey, value); } } } // update keysDefMap. keysDefMap.putAll(tempMap); }
java
private void checkMultiLevelKeys(final Map<String, KeyDef> keysDefMap, final Map<String, String> keysRefMap) { String key; KeyDef value; // tempMap storing values to avoid ConcurrentModificationException final Map<String, KeyDef> tempMap = new HashMap<>(); for (Entry<String, KeyDef> entry : keysDefMap.entrySet()) { key = entry.getKey(); value = entry.getValue(); // there is multi-level keys exist. if (keysRefMap.containsValue(key)) { // get multi-level keys final List<String> keysList = getKeysList(key, keysRefMap); for (final String multikey : keysList) { // update tempMap tempMap.put(multikey, value); } } } // update keysDefMap. keysDefMap.putAll(tempMap); }
[ "private", "void", "checkMultiLevelKeys", "(", "final", "Map", "<", "String", ",", "KeyDef", ">", "keysDefMap", ",", "final", "Map", "<", "String", ",", "String", ">", "keysRefMap", ")", "{", "String", "key", ";", "KeyDef", "value", ";", "// tempMap storing ...
Update keysDefMap for multi-level keys
[ "Update", "keysDefMap", "for", "multi", "-", "level", "keys" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/reader/KeydefFilter.java#L179-L199
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/ValidationFilter.java
ValidationFilter.setValidateMap
public void setValidateMap(final Map<QName, Map<String, Set<String>>> validateMap) { this.validateMap = validateMap; }
java
public void setValidateMap(final Map<QName, Map<String, Set<String>>> validateMap) { this.validateMap = validateMap; }
[ "public", "void", "setValidateMap", "(", "final", "Map", "<", "QName", ",", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", ">", "validateMap", ")", "{", "this", ".", "validateMap", "=", "validateMap", ";", "}" ]
Set valid attribute values. <p>The contents of the map is in pseudo-code {@code Map<AttName, Map<ElemName, <Set<Value>>>}. For default element mapping, the value is {@code *}.
[ "Set", "valid", "attribute", "values", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ValidationFilter.java#L56-L58
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/ValidationFilter.java
ValidationFilter.validateAttributeValues
private void validateAttributeValues(final String qName, final Attributes atts) { if (validateMap.isEmpty()) { return; } for (int i = 0; i < atts.getLength(); i++) { final QName attrName = new QName(atts.getURI(i), atts.getLocalName(i)); final Map<String, Set<String>> valueMap = validateMap.get(attrName); if (valueMap != null) { Set<String> valueSet = valueMap.get(qName); if (valueSet == null) { valueSet = valueMap.get("*"); } if (valueSet != null) { final String attrValue = atts.getValue(i); final String[] keylist = attrValue.trim().split("\\s+"); for (final String s : keylist) { if (!StringUtils.isEmptyString(s) && !valueSet.contains(s)) { logger.warn(MessageUtils.getMessage("DOTJ049W", attrName.toString(), qName, attrValue, StringUtils.join(valueSet, COMMA)).toString()); } } } } } }
java
private void validateAttributeValues(final String qName, final Attributes atts) { if (validateMap.isEmpty()) { return; } for (int i = 0; i < atts.getLength(); i++) { final QName attrName = new QName(atts.getURI(i), atts.getLocalName(i)); final Map<String, Set<String>> valueMap = validateMap.get(attrName); if (valueMap != null) { Set<String> valueSet = valueMap.get(qName); if (valueSet == null) { valueSet = valueMap.get("*"); } if (valueSet != null) { final String attrValue = atts.getValue(i); final String[] keylist = attrValue.trim().split("\\s+"); for (final String s : keylist) { if (!StringUtils.isEmptyString(s) && !valueSet.contains(s)) { logger.warn(MessageUtils.getMessage("DOTJ049W", attrName.toString(), qName, attrValue, StringUtils.join(valueSet, COMMA)).toString()); } } } } } }
[ "private", "void", "validateAttributeValues", "(", "final", "String", "qName", ",", "final", "Attributes", "atts", ")", "{", "if", "(", "validateMap", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", ...
Validate attribute values @param qName element name @param atts attributes
[ "Validate", "attribute", "values" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ValidationFilter.java#L250-L274
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/ValidationFilter.java
ValidationFilter.validateAttributeGeneralization
private void validateAttributeGeneralization(final Attributes atts) { final QName[][] d = domains.peekFirst(); if (d != null) { for (final QName[] spec: d) { for (int i = spec.length - 1; i > -1; i--) { if (atts.getValue(spec[i].getNamespaceURI(), spec[i].getLocalPart()) != null) { for (int j = i - 1; j > -1; j--) { if (atts.getValue(spec[j].getNamespaceURI(), spec[j].getLocalPart()) != null) { logger.error(MessageUtils.getMessage("DOTJ058E", spec[j].toString(), spec[i].toString()).toString()); } } } } } } }
java
private void validateAttributeGeneralization(final Attributes atts) { final QName[][] d = domains.peekFirst(); if (d != null) { for (final QName[] spec: d) { for (int i = spec.length - 1; i > -1; i--) { if (atts.getValue(spec[i].getNamespaceURI(), spec[i].getLocalPart()) != null) { for (int j = i - 1; j > -1; j--) { if (atts.getValue(spec[j].getNamespaceURI(), spec[j].getLocalPart()) != null) { logger.error(MessageUtils.getMessage("DOTJ058E", spec[j].toString(), spec[i].toString()).toString()); } } } } } } }
[ "private", "void", "validateAttributeGeneralization", "(", "final", "Attributes", "atts", ")", "{", "final", "QName", "[", "]", "[", "]", "d", "=", "domains", ".", "peekFirst", "(", ")", ";", "if", "(", "d", "!=", "null", ")", "{", "for", "(", "final",...
Validate attribute generalization. A single element may not contain both generalized and specialized values for the same attribute. @param atts attributes @see <a href="http://docs.oasis-open.org/dita/v1.2/os/spec/archSpec/attributegeneralize.html">DITA 1.2 specification</a>
[ "Validate", "attribute", "generalization", ".", "A", "single", "element", "may", "not", "contain", "both", "generalized", "and", "specialized", "values", "for", "the", "same", "attribute", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/ValidationFilter.java#L351-L367
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.addId
public String addId(final URI id) { if (id == null) { return null; } final URI localId = id.normalize(); index ++; final String newId = PREFIX + Integer.toString(index); idMap.put(localId, newId); return newId; }
java
public String addId(final URI id) { if (id == null) { return null; } final URI localId = id.normalize(); index ++; final String newId = PREFIX + Integer.toString(index); idMap.put(localId, newId); return newId; }
[ "public", "String", "addId", "(", "final", "URI", "id", ")", "{", "if", "(", "id", "==", "null", ")", "{", "return", "null", ";", "}", "final", "URI", "localId", "=", "id", ".", "normalize", "(", ")", ";", "index", "++", ";", "final", "String", "...
Add topic id to the idMap. @param id topic id @return updated topic id
[ "Add", "topic", "id", "to", "the", "idMap", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L72-L81
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.addId
public void addId(final URI id, final String value) { if (id != null && value != null) { final URI localId = id.normalize(); final String localValue = value.trim(); idMap.put(localId, localValue); } }
java
public void addId(final URI id, final String value) { if (id != null && value != null) { final URI localId = id.normalize(); final String localValue = value.trim(); idMap.put(localId, localValue); } }
[ "public", "void", "addId", "(", "final", "URI", "id", ",", "final", "String", "value", ")", "{", "if", "(", "id", "!=", "null", "&&", "value", "!=", "null", ")", "{", "final", "URI", "localId", "=", "id", ".", "normalize", "(", ")", ";", "final", ...
Add topic id-value pairs to idMap. @param id id @param value value
[ "Add", "topic", "id", "-", "value", "pairs", "to", "idMap", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L88-L94
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.getIdValue
public String getIdValue(final URI id) { if (id == null) { return null; } final URI localId = id.normalize(); return idMap.get(localId); }
java
public String getIdValue(final URI id) { if (id == null) { return null; } final URI localId = id.normalize(); return idMap.get(localId); }
[ "public", "String", "getIdValue", "(", "final", "URI", "id", ")", "{", "if", "(", "id", "==", "null", ")", "{", "return", "null", ";", "}", "final", "URI", "localId", "=", "id", ".", "normalize", "(", ")", ";", "return", "idMap", ".", "get", "(", ...
Return the value corresponding to the id. @param id id @return value
[ "Return", "the", "value", "corresponding", "to", "the", "id", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L101-L107
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.isVisited
public boolean isVisited(final URI path) { final URI localPath = stripFragment(path).normalize(); return visitSet.contains(localPath); }
java
public boolean isVisited(final URI path) { final URI localPath = stripFragment(path).normalize(); return visitSet.contains(localPath); }
[ "public", "boolean", "isVisited", "(", "final", "URI", "path", ")", "{", "final", "URI", "localPath", "=", "stripFragment", "(", "path", ")", ".", "normalize", "(", ")", ";", "return", "visitSet", ".", "contains", "(", "localPath", ")", ";", "}" ]
Return if this path has been visited before. @param path topic path, may contain a fragment @return true if has been visited
[ "Return", "if", "this", "path", "has", "been", "visited", "before", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L114-L117
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.visit
public void visit(final URI path) { final URI localPath = stripFragment(path).normalize(); visitSet.add(localPath); }
java
public void visit(final URI path) { final URI localPath = stripFragment(path).normalize(); visitSet.add(localPath); }
[ "public", "void", "visit", "(", "final", "URI", "path", ")", "{", "final", "URI", "localPath", "=", "stripFragment", "(", "path", ")", ".", "normalize", "(", ")", ";", "visitSet", ".", "add", "(", "localPath", ")", ";", "}" ]
Add topic to set of visited topics. @param path topic path, may contain a fragment
[ "Add", "topic", "to", "set", "of", "visited", "topics", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L124-L127
train
dita-ot/dita-ot
src/main/java/org/dita/dost/util/MergeUtils.java
MergeUtils.getFirstTopicId
public String getFirstTopicId(final URI file, final boolean useCatalog) { assert file.isAbsolute(); if (!(new File(file).exists())) { return null; } final StringBuilder firstTopicId = new StringBuilder(); final TopicIdParser parser = new TopicIdParser(firstTopicId); try { final XMLReader reader = XMLUtils.getXMLReader(); reader.setContentHandler(parser); if (useCatalog) { reader.setEntityResolver(CatalogUtils.getCatalogResolver()); } reader.parse(file.toString()); } catch (final Exception e) { logger.error(e.getMessage(), e) ; } return firstTopicId.toString(); }
java
public String getFirstTopicId(final URI file, final boolean useCatalog) { assert file.isAbsolute(); if (!(new File(file).exists())) { return null; } final StringBuilder firstTopicId = new StringBuilder(); final TopicIdParser parser = new TopicIdParser(firstTopicId); try { final XMLReader reader = XMLUtils.getXMLReader(); reader.setContentHandler(parser); if (useCatalog) { reader.setEntityResolver(CatalogUtils.getCatalogResolver()); } reader.parse(file.toString()); } catch (final Exception e) { logger.error(e.getMessage(), e) ; } return firstTopicId.toString(); }
[ "public", "String", "getFirstTopicId", "(", "final", "URI", "file", ",", "final", "boolean", "useCatalog", ")", "{", "assert", "file", ".", "isAbsolute", "(", ")", ";", "if", "(", "!", "(", "new", "File", "(", "file", ")", ".", "exists", "(", ")", ")...
Get the first topic id. @param file file URI @param useCatalog whether use catalog file for validation @return topic id
[ "Get", "the", "first", "topic", "id", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/MergeUtils.java#L136-L154
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/DitaIndexWriter.java
DitaIndexWriter.checkMatch
private boolean checkMatch() { if (matchList == null) { return true; } final int matchSize = matchList.size(); final int ancestorSize = topicIdList.size(); final List<String> tail = topicIdList.subList(ancestorSize - matchSize, ancestorSize); return matchList.equals(tail); }
java
private boolean checkMatch() { if (matchList == null) { return true; } final int matchSize = matchList.size(); final int ancestorSize = topicIdList.size(); final List<String> tail = topicIdList.subList(ancestorSize - matchSize, ancestorSize); return matchList.equals(tail); }
[ "private", "boolean", "checkMatch", "(", ")", "{", "if", "(", "matchList", "==", "null", ")", "{", "return", "true", ";", "}", "final", "int", "matchSize", "=", "matchList", ".", "size", "(", ")", ";", "final", "int", "ancestorSize", "=", "topicIdList", ...
check whether the hierarchy of current node match the matchList
[ "check", "whether", "the", "hierarchy", "of", "current", "node", "match", "the", "matchList" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/DitaIndexWriter.java#L95-L103
train
dita-ot/dita-ot
src/main/java/org/dita/dost/writer/DitaIndexWriter.java
DitaIndexWriter.writeStartElement
private void writeStartElement(final String qName, final Attributes atts) throws IOException { final int attsLen = atts.getLength(); output.write(LESS_THAN + qName); for (int i = 0; i < attsLen; i++) { final String attQName = atts.getQName(i); final String attValue = escapeXML(atts.getValue(i)); output.write(STRING_BLANK + attQName + EQUAL + QUOTATION + attValue + QUOTATION); } output.write(GREATER_THAN); }
java
private void writeStartElement(final String qName, final Attributes atts) throws IOException { final int attsLen = atts.getLength(); output.write(LESS_THAN + qName); for (int i = 0; i < attsLen; i++) { final String attQName = atts.getQName(i); final String attValue = escapeXML(atts.getValue(i)); output.write(STRING_BLANK + attQName + EQUAL + QUOTATION + attValue + QUOTATION); } output.write(GREATER_THAN); }
[ "private", "void", "writeStartElement", "(", "final", "String", "qName", ",", "final", "Attributes", "atts", ")", "throws", "IOException", "{", "final", "int", "attsLen", "=", "atts", ".", "getLength", "(", ")", ";", "output", ".", "write", "(", "LESS_THAN",...
SAX serializer methods
[ "SAX", "serializer", "methods" ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/writer/DitaIndexWriter.java#L339-L348
train
dita-ot/dita-ot
src/main/java/org/dita/dost/platform/Integrator.java
Integrator.readExtensions
private String readExtensions(final String featureName) { final Set<String> exts = new HashSet<>(); if (featureTable.containsKey(featureName)) { for (final Value ext : featureTable.get(featureName)) { final String e = ext.value.trim(); if (e.length() != 0) { exts.add(e); } } } return StringUtils.join(exts, CONF_LIST_SEPARATOR); }
java
private String readExtensions(final String featureName) { final Set<String> exts = new HashSet<>(); if (featureTable.containsKey(featureName)) { for (final Value ext : featureTable.get(featureName)) { final String e = ext.value.trim(); if (e.length() != 0) { exts.add(e); } } } return StringUtils.join(exts, CONF_LIST_SEPARATOR); }
[ "private", "String", "readExtensions", "(", "final", "String", "featureName", ")", "{", "final", "Set", "<", "String", ">", "exts", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "featureTable", ".", "containsKey", "(", "featureName", ")", ")", "...
Read plug-in feature. @param featureName plug-in feature name @return combined list of values
[ "Read", "plug", "-", "in", "feature", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L678-L689
train
dita-ot/dita-ot
src/main/java/org/dita/dost/platform/Integrator.java
Integrator.loadPlugin
private boolean loadPlugin(final String plugin) { if (checkPlugin(plugin)) { final Features pluginFeatures = pluginTable.get(plugin); final Map<String, List<String>> featureSet = pluginFeatures.getAllFeatures(); for (final Map.Entry<String, List<String>> currentFeature : featureSet.entrySet()) { final String key = currentFeature.getKey(); final List<Value> values = currentFeature.getValue().stream() .map(val -> new Value(plugin, val)) .collect(Collectors.toList()); if (!extensionPoints.contains(key)) { final String msg = "Plug-in " + plugin + " uses an undefined extension point " + key; throw new RuntimeException(msg); } if (featureTable.containsKey(key)) { final List<Value> value = featureTable.get(key); value.addAll(values); featureTable.put(key, value); } else { //Make shallow clone to avoid making modifications directly to list inside the current feature. List<Value> currentFeatureValue = values; featureTable.put(key, currentFeatureValue != null ? new ArrayList<>(currentFeatureValue) : null); } } for (final Value templateName : pluginFeatures.getAllTemplates()) { final String template = new File(pluginFeatures.getPluginDir().toURI().resolve(templateName.value)).getAbsolutePath(); final String templatePath = FileUtils.getRelativeUnixPath(ditaDir + File.separator + "dummy", template); templateSet.put(templatePath, templateName); } loadedPlugin.add(plugin); return true; } else { return false; } }
java
private boolean loadPlugin(final String plugin) { if (checkPlugin(plugin)) { final Features pluginFeatures = pluginTable.get(plugin); final Map<String, List<String>> featureSet = pluginFeatures.getAllFeatures(); for (final Map.Entry<String, List<String>> currentFeature : featureSet.entrySet()) { final String key = currentFeature.getKey(); final List<Value> values = currentFeature.getValue().stream() .map(val -> new Value(plugin, val)) .collect(Collectors.toList()); if (!extensionPoints.contains(key)) { final String msg = "Plug-in " + plugin + " uses an undefined extension point " + key; throw new RuntimeException(msg); } if (featureTable.containsKey(key)) { final List<Value> value = featureTable.get(key); value.addAll(values); featureTable.put(key, value); } else { //Make shallow clone to avoid making modifications directly to list inside the current feature. List<Value> currentFeatureValue = values; featureTable.put(key, currentFeatureValue != null ? new ArrayList<>(currentFeatureValue) : null); } } for (final Value templateName : pluginFeatures.getAllTemplates()) { final String template = new File(pluginFeatures.getPluginDir().toURI().resolve(templateName.value)).getAbsolutePath(); final String templatePath = FileUtils.getRelativeUnixPath(ditaDir + File.separator + "dummy", template); templateSet.put(templatePath, templateName); } loadedPlugin.add(plugin); return true; } else { return false; } }
[ "private", "boolean", "loadPlugin", "(", "final", "String", "plugin", ")", "{", "if", "(", "checkPlugin", "(", "plugin", ")", ")", "{", "final", "Features", "pluginFeatures", "=", "pluginTable", ".", "get", "(", "plugin", ")", ";", "final", "Map", "<", "...
Load the plug-ins and aggregate them by feature and fill into feature table. @param plugin plugin ID @return {@code true}> if plugin was loaded, otherwise {@code false}
[ "Load", "the", "plug", "-", "ins", "and", "aggregate", "them", "by", "feature", "and", "fill", "into", "feature", "table", "." ]
ea776b3c60c03d9f033b6f7ea072349e49dbcdd2
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/platform/Integrator.java#L698-L734
train