2 package com
.interrupt
.bob
.util
;
4 import java
.io
.ByteArrayInputStream
;
5 import java
.io
.InputStream
;
6 import java
.io
.UnsupportedEncodingException
;
7 import java
.lang
.reflect
.InvocationTargetException
;
8 import java
.lang
.reflect
.Method
;
10 import org
.apache
.log4j
.Logger
;
12 import com
.interrupt
.bob
.base
.Bob
;
13 import com
.interrupt
.bob
.base
.IBob
;
17 public static final String HOME
= "bob.home";
18 public static final String BASE
= "bob.base";
19 public static final String END
= "bob.end";
20 public static final String GEN
= "bob.gen";
22 public static final String DEF
= "bob.def";
23 public static final String SYS
= "bob.sys";
25 public static boolean isInterpretable( String value
) {
32 boolean starter
= value
.trim().startsWith("${");
33 boolean ending
= value
.trim().endsWith("}");
34 if( starter
&& ending
) {
40 public static String
getInterpretableName(String name
) {
42 //String sansPrefix = name.substring(name.indexOf("${"));
43 String sansPrefix
= name
.substring(2);
44 String sansSuffix
= sansPrefix
.substring(0, sansPrefix
.indexOf("}"));
49 public static void evalReflectedAdd(IBob parent
, String tagName
, Class methodDefinitionParams
[], IBob methParams
[])
50 throws NoSuchMethodException
, IllegalAccessException
, InvocationTargetException
, Throwable
{
53 //parent.add{child}(created);
54 Class pclass
= parent
.getClass();
55 String methName
= "add" + StringUtil
.upperFirstLetter(tagName
);
56 Method setMeth
= null;
60 setMeth
= pclass
.getMethod( methName
, methodDefinitionParams
);
61 setMeth
.invoke( parent
, methParams
);
63 catch(NoSuchMethodException e
) {
67 catch(IllegalAccessException e
) {
71 catch(InvocationTargetException e
) {
79 public static IBob
loadBobFromXML(String xmlString
) {
81 Logger logger
= Logger
.getLogger(com
.interrupt
.bob
.util
.Util
.class);
82 logger
.debug("com.interrupt.bob.util.Util.loadBobFromXML:: ["+ xmlString
+"]");
84 //** load a Bob object
85 InputStream istream
= null;
87 istream
= new ByteArrayInputStream(xmlString
.getBytes("UTF-8"));
89 catch(UnsupportedEncodingException e
) {
90 throw new RuntimeException(e
);
93 IBob bob
= Bob
.loadS(istream
, System
.getProperty(Util
.DEF
));
94 logger
.debug("com.interrupt.bob.util.Util.loadBobFromXML:: Loaded Bob from XML [" + bob
.toXML(false) + "]");