*/
package org.opendaylight.yangtools.sal.binding.generator.impl
-import java.text.SimpleDateFormat
import java.util.Collection
import java.util.Date
import java.util.List
import org.opendaylight.yangtools.yang.model.api.UsesNode
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
+import com.google.common.base.CharMatcher
class YangTemplate {
+ // FIXME: this is not thread-safe and seems to be unused!
private static var Module module = null
+ private static val CharMatcher NEWLINE_OR_TAB = CharMatcher.anyOf("\n\t")
+
def static String generateYangSnipet(SchemaNode schemaNode) {
if (schemaNode == null)
return ''
'''
}
- def static formatDate(Date moduleRevision) {
- val SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd")
- return dateFormat.format(moduleRevision)
- }
-
def static writeRevision(Date moduleRevision, String moduleDescription) {
val revisionIndent = 12
'''
- revision «formatDate(moduleRevision)» {
+ revision «SimpleDateFormatUtil.getRevisionFormat.format(moduleRevision)» {
description "«formatToParagraph(moduleDescription, revisionIndent)»";
}
'''
'''
input {
- «IF input instanceof DataSchemaNode && !input.childNodes.nullOrEmpty»
+ «IF !input.childNodes.nullOrEmpty»
«writeDataSchemaNodes(input.childNodes)»
«ENDIF»
}
'''
output {
- «IF output instanceof DataSchemaNode && !output.childNodes.nullOrEmpty»
+ «IF !output.childNodes.nullOrEmpty»
«writeDataSchemaNodes(output.childNodes)»
«ENDIF»
}
val lineIndent = computeNextLineIndent(nextLineIndent);
formattedText = formattedText.replace("*/", "*/");
- formattedText = formattedText.replace("\n", "");
- formattedText = formattedText.replace("\t", "");
+ formattedText = NEWLINE_OR_TAB.removeFrom(formattedText);
formattedText = formattedText.replaceAll(" +", " ");
val StringTokenizer tokenizer = new StringTokenizer(formattedText, " ", true);
val ns = pathElement.namespace
val localName = pathElement.localName
- sb.append("\\")
- sb.append('(')
+ sb.append("\\(")
sb.append(ns)
sb.append(')')
sb.append(localName)