[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/exp/util ...
Takuro Okada
t2-okada at nri.co.jp
Thu Oct 26 04:58:57 EDT 2006
User: tokada
Date: 06/10/26 04:58:57
Added: java/src/expansion/org/jboss/profiler/exp/util Tag:
JBossProfiler_Expansion CopyUtil.java
HierarchicalMap.java
Log:
Revision Changes Path
No revision
No revision
1.1.2.1 +72 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/util/Attic/CopyUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CopyUtil.java
===================================================================
RCS file: CopyUtil.java
diff -N CopyUtil.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CopyUtil.java 26 Oct 2006 08:58:57 -0000 1.1.2.1
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.exp.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * This class provides some method to copy a object.
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class CopyUtil {
+
+ /**
+ * Deep-copy a object by serializable.
+ * @param obj - serializable object
+ * @return copied object.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public static Object deepCopy(Serializable obj) throws IOException, ClassNotFoundException {
+ Object clone = null;
+ if (obj == null) return clone;
+ ByteArrayOutputStream bos = null;
+ ObjectOutputStream oos = null;
+ ByteArrayInputStream bis = null;
+ ObjectInputStream ois = null;
+ try {
+ bos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(bos);
+ oos.writeObject(obj);
+ bis = new ByteArrayInputStream(bos.toByteArray());
+ ois = new ObjectInputStream(bis);
+ clone = ois.readObject();
+ } finally {
+ if(oos!=null) oos.close();
+ if(bos!=null) bos.close();
+ if(ois!=null) ois.close();
+ if(bis!=null) bis.close();
+ }
+ return clone;
+ }
+
+}
1.1.2.1 +54 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/util/Attic/HierarchicalMap.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HierarchicalMap.java
===================================================================
RCS file: HierarchicalMap.java
diff -N HierarchicalMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HierarchicalMap.java 26 Oct 2006 08:58:57 -0000 1.1.2.1
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.exp.util;
+
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * This class provide hierarchical access for TreeMap.
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class HierarchicalMap<K, V> extends TreeMap<K, V> {
+
+ /**
+ * Returns partial map.
+ * @param key - key object
+ * @return partial map
+ */
+ public SortedMap<K, V> partialMap(K key) {
+ SortedMap<K, V> result = new TreeMap<K, V>();
+ for(K keys : this.keySet()) {
+ if(keys instanceof String && key instanceof String) {
+ if(((String)keys).contains((String)key)) {
+ result.put(keys, this.get(keys));
+ }
+ }
+ }
+ return result;
+ }
+}
More information about the jboss-cvs-commits
mailing list