Compare commits

...

2 Commits

Author SHA1 Message Date
wwang-talend
8ce14c0620 fix(TUP-27184): org.talend.core.model.process.INode.getLabel() return
null when use it in javajet
2020-06-18 11:16:05 +08:00
wwang-talend
dd06612b88 fix(TUP-27184): org.talend.core.model.process.INode.getLabel() return
null when use it in javajet
2020-06-18 10:37:49 +08:00
2 changed files with 39 additions and 2 deletions

View File

@@ -1081,8 +1081,7 @@ public abstract class AbstractNode implements INode {
@Override
public void setLabel(String label) {
// TODO Auto-generated method stub
this.label = label;
}
@Override

View File

@@ -1232,4 +1232,42 @@ public class NodeUtil {
return true;
}
public static String getLabel(INode node) {
String label = node.getLabel();
if(label == null) {
return node.getUniqueName();
}
label = label.trim();
if(label.isEmpty()) {
return node.getUniqueName();
}
if(isValidJavaStringLiteral(label)) {
return "\"" + label + "\"";
}
return label;
}
private static boolean isValidJavaStringLiteral(String value) {
boolean escape = false;
for(int i=0;i<value.length();i++) {
char c = value.charAt(i);
if(c == '"' && !escape) {
return false;
}
if(c == '\\') {
escape = !escape;
} else {
escape = false;
}
}
return true;
}
}