tbrugz avatar tbrugz committed c35d506

AbstractDump: added 'defaults' substitution props: defaults.<snippet-id>.{<substitution-id>}=<default-value>

Comments (0)

Files changed (3)

src/tbrugz/graphml/model/NodeXY.java

 		setStereotype("xynode");
 	}
 	
-	float x,y;
+	Float x,y;
 	
-	public float getX() {
+	public Float getX() {
 		return x;
 	}
 
-	public void setX(float x) {
+	public void setX(Float x) {
 		this.x = x;
 	}
 
-	public float getY() {
+	public Float getY() {
 		return y;
 	}
 
-	public void setY(float y) {
+	public void setY(Float y) {
 		this.y = y;
 	}
 
 			case 0:
 				return getLabel();
 			case 1:
-				return String.valueOf(x);
+				return x==null?null:String.valueOf(x);
 			case 2:
-				return String.valueOf(y);
+				return y==null?null:String.valueOf(y);
 		}
 		return null;
 	}

src/tbrugz/graphml/model/NodeXYWH.java

 		setStereotype("xynode.whnode");
 	}
 	
-	float width, height;
+	Float width, height;
 
-	public float getWidth() {
+	public Float getWidth() {
 		return width;
 	}
 
-	public void setWidth(float width) {
+	public void setWidth(Float width) {
 		this.width = width;
 	}
 
-	public float getHeight() {
+	public Float getHeight() {
 		return height;
 	}
 
-	public void setHeight(float height) {
+	public void setHeight(Float height) {
 		this.height = height;
 	}
 
 	public String getStereotypeParam(int i) {
 		switch (i) {
 			case 3:
-				return String.valueOf(width);
+				return width==null?null:String.valueOf(width);
 			case 4:
-				return String.valueOf(height);
+				return height==null?null:String.valueOf(height);
 		}
 		return super.getStereotypeParam(i);
 	}

src/tbrugz/xml/AbstractDump.java

 			String paramGroup = matcher.group(1);
 			String replacement = regexutil.procFunc(paramGroup, params);
 			log.debug("param: "+paramGroup+"; replacement: "+replacement);
-			if(replacement!=null) {
-				xtraOffset += replace(sb, replacement, matcher, xtraOffset);
+			
+			String tmpSnippetId = snippetId;
+			while(replacement==null) {
+				replacement = snippets.getProperty("defaults."+tmpSnippetId+"."+paramGroup);
+				log.debug("replacement NULL: "+snippetId+"/"+tmpSnippetId+"/"+paramGroup+"; new replacement: "+replacement);
+				
+				int index = tmpSnippetId.lastIndexOf(".");
+				if(index<=0) { break; }
+				tmpSnippetId = tmpSnippetId.substring(0, index);
+				
+				//replacement = "nullid_"+ReplacerSequence.getNext();
 				/*sb.replace(matcher.start()+xtraOffset, matcher.end()+xtraOffset, replacement);
 				int originalSize = matcher.end()-matcher.start();
 				xtraOffset += replacement.length()-originalSize;*/
 				//matcher.replaceFirst(replacement);
 				//matcher = paramPattern.matcher(s);
 			}
-			else {
-				//TODOne: handle null ids
-				replacement = "nullid_"+ReplacerSequence.getNext();
-				xtraOffset += replace(sb, replacement, matcher, xtraOffset);
-			}
+			if(replacement==null) { replacement = "nullid_"+ReplacerSequence.getNext(); }
+			xtraOffset += replace(sb, replacement, matcher, xtraOffset);
 		}
 		
 		/*if(params!=null) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.