View Javadoc
1 /* ==================================================================== 2 * Bigyo Software License, version 1.1 3 * 4 * Copyright (c) 2004, Zsombor Gegesy. All rights reserved. 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. Neither the name of the Bigyo Group nor the name "Bigyo" nor 18 * the names of its contributors may be used to endorse or promote 19 * products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 * ==================================================================== 36 */ 37 38 package net.sf.bigyo.container; 39 40 import java.util.Iterator; 41 import java.util.List; 42 43 import net.sf.bigyo.model.ComponentConfig; 44 import net.sf.bigyo.model.ObjectDependency; 45 46 import org.apache.avalon.fortress.util.dag.Vertex; 47 import org.apache.log4j.LogManager; 48 import org.apache.log4j.Logger; 49 50 import com.thoughtworks.xstream.XStream; 51 52 /*** 53 * Created on 2004.04.01. 54 * @author zsombor 55 * 56 * To change the template for this generated type comment go to Window - 57 * Preferences - Java - Code Generation - Code and Comments 58 */ 59 public class Util { 60 61 final static Logger LOG = LogManager.getLogger(Util.class); 62 63 /*** 64 * 65 */ 66 private Util() { 67 } 68 69 public static String convertVertexList(List list) { 70 StringBuffer buf = new StringBuffer(); 71 buf.append('['); 72 boolean first = true; 73 for (Iterator iter = list.iterator(); iter.hasNext();) { 74 Object obj = iter.next(); 75 if (!first) 76 buf.append(','); 77 first = false; 78 if (obj instanceof Vertex) { 79 buf.append(((Vertex) obj).getName()); 80 } else { 81 buf.append(obj); 82 } 83 } 84 buf.append(']'); 85 return buf.toString(); 86 } 87 88 public static XStream createXStream() { 89 XStream xstream = new XStream(); 90 xstream.alias("description", ComponentDescription.class); 91 xstream.alias("config", ComponentConfig.class); 92 xstream.alias("depend", ObjectDependency.class); 93 xstream.alias("class-depend", ClassDependency.class); 94 return xstream; 95 } 96 97 public static Object toObject(Object obj) { 98 return obj; 99 } 100 101 public static Object toObject(int obj) { 102 return new Integer(obj); 103 } 104 105 public static Object toObject(double obj) { 106 return new Double(obj); 107 } 108 109 public static Object toObject(float obj) { 110 return new Float(obj); 111 } 112 113 public static Object toObject(boolean obj) { 114 return Boolean.valueOf(obj); 115 } 116 117 public static Object toObject(char obj) { 118 return new Character(obj); 119 } 120 121 public static int toint(Object obj) { 122 return ((Number) obj).intValue(); 123 } 124 125 public static long tolong(Object obj) { 126 return ((Number) obj).longValue(); 127 } 128 129 public static double todouble(Object obj) { 130 return ((Number) obj).doubleValue(); 131 } 132 133 public static float tofloat(Object obj) { 134 return ((Number) obj).floatValue(); 135 } 136 137 public static boolean toboolean(Object obj) { 138 return ((Boolean) obj).booleanValue(); 139 } 140 141 }

This page was automatically generated by Maven