[Jiemamy-notify] commit [2040] 理想の出力にちょっと近づけ。

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 25日 (土) 19:48:28 JST


Revision: 2040
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2040
Author:   daisuke_m
Date:     2008-10-25 19:48:28 +0900 (Sat, 25 Oct 2008)

Log Message:
-----------
理想の出力にちょっと近づけ。

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java	2008-10-25 10:47:32 UTC (rev 2039)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java	2008-10-25 10:48:28 UTC (rev 2040)
@@ -66,22 +66,6 @@
 	}
 	
 	/**
-	 * 要求された1モデルだけを読み込み,Byteのキューに追加していく。
-	 * @return  読み込むデータがない場合false, ある場合true 
-	 * @throws IllegalArgumentException  
-	 */
-	private boolean loadFromModel() {
-		if (nextWriteModelStack.empty()) {
-			return false;
-		}
-		List<JiemamyModel> nextObjects = modelWriter.write(nextWriteModelStack.pop());
-		for (JiemamyModel next : nextObjects) {
-			nextWriteModelStack.push(next);
-		}
-		return resourceQueue.size() > 0 || nextWriteModelStack.empty() == false;
-	}
-	
-	/**
 	 * {@inheritDoc}
 	 */
 	@Override
@@ -97,4 +81,20 @@
 		}
 		return resourceQueue.poll().intValue();
 	}
+	
+	/**
+	 * 要求された1モデルだけを読み込み,Byteのキューに追加していく。
+	 * @return  読み込むデータがない場合false, ある場合true 
+	 * @throws IllegalArgumentException  
+	 */
+	private boolean loadFromModel() {
+		if (nextWriteModelStack.empty()) {
+			return false;
+		}
+		List<JiemamyModel> nextObjects = modelWriter.write(nextWriteModelStack.pop());
+		for (JiemamyModel next : nextObjects) {
+			nextWriteModelStack.push(next);
+		}
+		return resourceQueue.size() > 0 || nextWriteModelStack.empty() == false;
+	}
 }

Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java	2008-10-25 10:47:32 UTC (rev 2039)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java	2008-10-25 10:48:28 UTC (rev 2040)
@@ -62,12 +62,6 @@
 		createWriters();
 	}
 	
-	private void createWriters() {
-		stringWriter = (new StringWriter());
-		dataWriter = (new DataWriter(stringWriter));
-		dataWriter.setIndentStep(2);
-	}
-	
 	/**
 	 * 破棄処理を行う。
 	 */
@@ -112,14 +106,11 @@
 					Object value = method.invoke(jiemamyModel, new Object[0]);
 					if (value != null) {
 						if (value instanceof String) {
-							dataWriter.startElement(method.getName());
-							dataWriter.dataElement(value.getClass().getName(), (String) value);
-							dataWriter.endElement(method.getName());
+							dataWriter.dataElement(method.getName(), (String) value);
 						} else if (value instanceof Number) {
 							dataWriter.dataElement(method.getName(), ((Number) value).toString());
 						} else if (value instanceof JiemamyModel) {
 							String refClassName = ((JiemamyModel) value).getClass().getName();
-							System.out.println(refClassName);
 							dataWriter.startElement(method.getName());
 							dataWriter.startElement(refClassName);
 							dataWriter.dataElement("refid", ((JiemamyModel) value).getId().toString());
@@ -131,9 +122,7 @@
 							}
 						} else if (value instanceof Collection) {
 							if (((Collection<?>) value).size() > 0) {
-								String refCollectionClassName = ((Collection<?>) value).getClass().getName();
 								dataWriter.startElement(method.getName());
-								dataWriter.startElement(refCollectionClassName);
 								for (Object e : ((Collection<?>) value)) {
 									if (e instanceof JiemamyModel) {
 										String refClassName = ((JiemamyModel) e).getClass().getName();
@@ -146,8 +135,9 @@
 										}
 									}
 								}
-								dataWriter.endElement(refCollectionClassName);
 								dataWriter.endElement(method.getName());
+							} else {
+								dataWriter.emptyElement(method.getName());
 							}
 						}
 					}
@@ -171,4 +161,10 @@
 		return nextWriteModelList;
 	}
 	
+	private void createWriters() {
+		stringWriter = (new StringWriter());
+		dataWriter = (new DataWriter(stringWriter));
+		dataWriter.setIndentStep(2);
+	}
+	
 }


Jiemamy-notify メーリングリストの案内
Zurück zum Archiv-Index