[Jiemamy-notify] commit [2033] 命名規則を修正し、少し最適化。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 25日 (土) 18:23:52 JST


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

Log Message:
-----------
命名規則を修正し、少し最適化。

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/NotOperatorChecker.java
    artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/VariableNamingRuleChecker.java
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/NotOperatorChecker.java
===================================================================
--- artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/NotOperatorChecker.java	2008-10-25 09:13:27 UTC (rev 2032)
+++ artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/NotOperatorChecker.java	2008-10-25 09:23:52 UTC (rev 2033)
@@ -1,6 +1,8 @@
 package org.jiemamy.irenka.hack.generic;
 
-import org.ashikunep.irenka.dom.CtMethod;
+import org.ashikunep.irenka.dom.CtUnary;
+import org.ashikunep.irenka.dom.UnaryOperator;
+import org.ashikunep.irenka.toolkit.Messager;
 
 /**
  * 否定演算子をチェックするIrenka Hack。
@@ -8,19 +10,20 @@
  */
 public class NotOperatorChecker {
 	
+//	/**
+//	 * @when
+//	 */
+//	public void dummy(CtMethod<?> method) {
+//		// dummy
+//	}
+	
 	/**
-	 * @when
+	 * インターフェイスに関する命名規則チェック。
+	 * @param messager
+	 * @param unary 単項演算子
+	 * @when {@link UnaryOperator#NOT} = unary.operator
 	 */
-	public void dummy(CtMethod<?> method) {
-		// dummy
+	public void foundNotOperator(CtUnary<Boolean> unary, Messager messager) {
+		messager.warn(unary, "否定演算子は推奨されません。\"!foo\"は\"foo == false\"に書き換えて下さい。");
 	}
-//	/**
-//	 * インターフェイスに関する命名規則チェック。
-//	 * @param messager
-//	 * @param unary 単項演算子
-//	 * @when {@link UnaryOperator#NOT} = unary.operator
-//	 */
-//	public void foundNotOperator(CtUnary<Boolean> unary, Messager messager) {
-//		messager.warn(unary, "否定演算子は推奨されません。\"!foo\"は\"foo == false\"に書き換えて下さい。");
-//	}
 }

Modified: artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/VariableNamingRuleChecker.java
===================================================================
--- artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/VariableNamingRuleChecker.java	2008-10-25 09:13:27 UTC (rev 2032)
+++ artemis/trunk/org.jiemamy.irenka/src/main/java/org/jiemamy/irenka/hack/generic/VariableNamingRuleChecker.java	2008-10-25 09:23:52 UTC (rev 2033)
@@ -3,7 +3,9 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
+import java.util.Stack;
 
 import org.ashikunep.irenka.dom.CtField;
 import org.ashikunep.irenka.dom.CtVariable;
@@ -64,6 +66,12 @@
 		if (decFactory.typeOf(Set.class).isAssignableFrom(variable.getType()) && name.endsWith("Set")) {
 			return;
 		}
+		if (decFactory.typeOf(Queue.class).isAssignableFrom(variable.getType()) && name.endsWith("Queue")) {
+			return;
+		}
+		if (decFactory.typeOf(Stack.class).isAssignableFrom(variable.getType()) && name.endsWith("Stack")) {
+			return;
+		}
 		messager.warn(variable, "Collection型の識別子は、複数形もしくはList,Setで終わらなければなりません。");
 	}
 	

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 09:13:27 UTC (rev 2032)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java	2008-10-25 09:23:52 UTC (rev 2033)
@@ -50,11 +50,13 @@
 	/** 初期化済みかどうか */
 	private boolean initialized;
 	
-	private Queue<Byte> resourceQueues = new LinkedBlockingQueue<Byte>();
+	/** 出力モデルキュー */
+	private Queue<Byte> resourceQueue = new LinkedBlockingQueue<Byte>();
 	
-	private ModelWriter modelWriter = new ModelWriter(resourceQueues);
+	/** 処理中のモデル構造スタック */
+	private Stack<JiemamyModel> nextWriteModelStack = new Stack<JiemamyModel>();
 	
-	private Stack<JiemamyModel> nextWriteModelStacks = new Stack<JiemamyModel>();
+	private ModelWriter modelWriter = new ModelWriter(resourceQueue);
 	
 
 	/**
@@ -63,7 +65,7 @@
 	 * @category  instance creation
 	 */
 	public ModelInputStream(RootModel rootModel) {
-		nextWriteModelStacks.push(rootModel);
+		nextWriteModelStack.push(rootModel);
 	}
 	
 	/**
@@ -84,28 +86,28 @@
 			modelWriter.init();
 			initialized = true;
 		}
-		if (resourceQueues.size() == 0) {
+		if (resourceQueue.size() == 0) {
 			if (loadFromModel() == false) {
 				return -1;
 			}
 		}
-		return resourceQueues.poll().intValue();
+		return resourceQueue.poll().intValue();
 	}
 	
 	/**
-	 * 要求された1モデルだけを読み込み,Byteのキューに追加していく
+	 * 要求された1モデルだけを読み込み,Byteのキューに追加していく。
 	 * @return  読み込むデータがない場合false, ある場合true 
 	 * @throws IllegalArgumentException  
 	 */
 	private boolean loadFromModel() {
-		if (nextWriteModelStacks.empty()) {
+		if (nextWriteModelStack.empty()) {
 			return false;
 		}
-		List<JiemamyModel> nextObjects = modelWriter.write(nextWriteModelStacks.pop());
+		List<JiemamyModel> nextObjects = modelWriter.write(nextWriteModelStack.pop());
 		for (JiemamyModel next : nextObjects) {
-			nextWriteModelStacks.push(next);
+			nextWriteModelStack.push(next);
 		}
-		return resourceQueues.size() > 0 || nextWriteModelStacks.empty() == false;
+		return resourceQueue.size() > 0 || nextWriteModelStack.empty() == false;
 	}
 	
 
@@ -131,7 +133,7 @@
 		}
 		
 		/**
-		 * 破棄処理
+		 * 破棄処理を行う。
 		 */
 		public void dispose() {
 			try {
@@ -142,7 +144,7 @@
 		}
 		
 		/**
-		 * 初期化処理
+		 * 初期化処理を行う。
 		 */
 		public void init() {
 			try {
@@ -177,18 +179,8 @@
 								dataWriter.startElement(method.getName());
 								dataWriter.dataElement(value.getClass().getName(), (String) value);
 								dataWriter.endElement(method.getName());
-							} else if (value instanceof Integer) {
-								dataWriter.startElement(method.getName());
-								dataWriter.dataElement(value.getClass().getName(), ((Integer) value).toString());
-								dataWriter.endElement(method.getName());
-							} else if (value instanceof Long) {
-								dataWriter.startElement(method.getName());
-								dataWriter.dataElement(value.getClass().getName(), ((Long) value).toString());
-								dataWriter.endElement(method.getName());
-							} else if (value instanceof Float) {
-								dataWriter.startElement(method.getName());
-								dataWriter.dataElement(value.getClass().getName(), ((Float) value).toString());
-								dataWriter.endElement(method.getName());
+							} 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);


Jiemamy-notify メーリングリストの案内
Back to archive index