Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util In directory sc8-pr-cvs1:/tmp/cvs-serv14211/src/net/sf/hibernate/util Modified Files: ArrayHelper.java BytesHelper.java DTDEntityResolver.java FastHashMap.java IdentityMap.java JDBCExceptionReporter.java JoinedIterator.java LinkedHashCollectionHelper.java NamingHelper.java PropertiesHelper.java Range.java ReflectHelper.java StringHelper.java XMLHelper.java Log Message: reformatted code with beautiful, shiny, happy TABS! improved an exception Index: ArrayHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/ArrayHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ArrayHelper.java 1 Jan 2003 13:58:24 -0000 1.1.1.1 --- ArrayHelper.java 4 Jan 2003 11:15:31 -0000 1.2 *************** *** 8,12 **** public final class ArrayHelper { ! public static String[] toStringArray(Object[] objects) { int length=objects.length; --- 8,12 ---- public final class ArrayHelper { ! public static String[] toStringArray(Object[] objects) { int length=objects.length; *************** *** 36,40 **** } ! //Arrays.asList doesn't do primitive arrays public static List toList(Object array) { if ( array instanceof Object[] ) return Arrays.asList( (Object[]) array ); //faster? --- 36,40 ---- } ! //Arrays.asList doesn't do primitive arrays public static List toList(Object array) { if ( array instanceof Object[] ) return Arrays.asList( (Object[]) array ); //faster? *************** *** 71,72 **** --- 71,75 ---- } } + + + Index: BytesHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/BytesHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BytesHelper.java 1 Jan 2003 13:58:25 -0000 1.1.1.1 --- BytesHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 3,7 **** public final class BytesHelper { ! public static int toInt( byte[] bytes ) { int result = 0; --- 3,7 ---- public final class BytesHelper { ! public static int toInt( byte[] bytes ) { int result = 0; *************** *** 11,19 **** return result; } ! public static short toShort( byte[] bytes ) { ! return (short) ( ( ( - (short) Byte.MIN_VALUE + (short) bytes[0] ) << 8 ) - (short) Byte.MIN_VALUE + (short) bytes[1] ); } ! public static byte[] toBytes(int value) { byte[] result = new byte[4]; --- 11,19 ---- return result; } ! public static short toShort( byte[] bytes ) { ! return (short) ( ( ( - (short) Byte.MIN_VALUE + (short) bytes[0] ) << 8 ) - (short) Byte.MIN_VALUE + (short) bytes[1] ); } ! public static byte[] toBytes(int value) { byte[] result = new byte[4]; *************** *** 24,28 **** return result; } ! public static byte[] toBytes(short value) { byte[] result = new byte[2]; --- 24,28 ---- return result; } ! public static byte[] toBytes(short value) { byte[] result = new byte[2]; *************** *** 43,46 **** System.out.println( Integer.MAX_VALUE / 2 +"=="+ BytesHelper.toInt( BytesHelper.toBytes(Integer.MAX_VALUE / 2) ) ); } ! } --- 43,49 ---- System.out.println( Integer.MAX_VALUE / 2 +"=="+ BytesHelper.toInt( BytesHelper.toBytes(Integer.MAX_VALUE / 2) ) ); } ! } + + + Index: DTDEntityResolver.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/DTDEntityResolver.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DTDEntityResolver.java 1 Jan 2003 13:58:25 -0000 1.1.1.1 --- DTDEntityResolver.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 15,23 **** private static final String URL = "http://hibernate.sourceforge.net/"; ! public InputSource resolveEntity (String publicId, String systemId) { if ( systemId!=null && systemId.startsWith(URL) ) { log.debug("trying to locate " + systemId + " in classpath under net/sf/hibernate/"); ! // Search for DTD ClassLoader classLoader = this.getClass().getClassLoader(); InputStream dtdStream = classLoader.getResourceAsStream( "net/sf/hibernate/" + systemId.substring( URL.length() ) ); --- 15,23 ---- private static final String URL = "http://hibernate.sourceforge.net/"; ! public InputSource resolveEntity (String publicId, String systemId) { if ( systemId!=null && systemId.startsWith(URL) ) { log.debug("trying to locate " + systemId + " in classpath under net/sf/hibernate/"); ! // Search for DTD ClassLoader classLoader = this.getClass().getClassLoader(); InputStream dtdStream = classLoader.getResourceAsStream( "net/sf/hibernate/" + systemId.substring( URL.length() ) ); *************** *** 30,34 **** return new InputSource(dtdStream); } ! } else { // use the default behaviour --- 30,34 ---- return new InputSource(dtdStream); } ! } else { // use the default behaviour *************** *** 36,40 **** } } ! } ! --- 36,43 ---- } } ! } ! ! ! ! Index: FastHashMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/FastHashMap.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** FastHashMap.java 1 Jan 2003 13:58:26 -0000 1.1.1.1 --- FastHashMap.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 87,103 **** public final class FastHashMap implements Map, Serializable { ! // ----------------------------------------------------------- Constructors ! /** * Construct a an empty map. */ public FastHashMap() { ! super(); this.map = new HashMap(); ! } ! /** * Construct an empty map with the specified capacity. --- 87,103 ---- public final class FastHashMap implements Map, Serializable { ! // ----------------------------------------------------------- Constructors ! /** * Construct a an empty map. */ public FastHashMap() { ! super(); this.map = new HashMap(); ! } ! /** * Construct an empty map with the specified capacity. *************** *** 106,115 **** */ public FastHashMap(int capacity) { ! super(); this.map = new HashMap(capacity); ! } ! /** * Construct an empty map with the specified capacity and load factor. --- 106,115 ---- */ public FastHashMap(int capacity) { ! super(); this.map = new HashMap(capacity); ! } ! /** * Construct an empty map with the specified capacity and load factor. *************** *** 119,128 **** */ public FastHashMap(int capacity, float factor) { ! super(); this.map = new HashMap(capacity, factor); ! } ! /** * Construct a new map with the same mappings as the specified map. --- 119,128 ---- */ public FastHashMap(int capacity, float factor) { ! super(); this.map = new HashMap(capacity, factor); ! } ! /** * Construct a new map with the same mappings as the specified map. *************** *** 131,154 **** */ public FastHashMap(Map map) { ! super(); this.map = new HashMap(map); ! } ! // ----------------------------------------------------- Instance Variables ! /** * The underlying map we are managing. */ protected HashMap map = null; ! // --------------------------------------------------------- Public Methods ! /** * Remove all mappings from this map. */ public void clear() { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); --- 131,154 ---- */ public FastHashMap(Map map) { ! super(); this.map = new HashMap(map); ! } ! // ----------------------------------------------------- Instance Variables ! /** * The underlying map we are managing. */ protected HashMap map = null; ! // --------------------------------------------------------- Public Methods ! /** * Remove all mappings from this map. */ public void clear() { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); *************** *** 156,162 **** map = temp; } ! } ! /** * Return a shallow copy of this <code>FastHashMap</code> instance. --- 156,162 ---- map = temp; } ! } ! /** * Return a shallow copy of this <code>FastHashMap</code> instance. *************** *** 164,176 **** */ public Object clone() { ! FastHashMap results = null; ! results = new FastHashMap(map); ! return (results); ! } ! /** * Return <code>true</code> if this map contains a mapping for the --- 164,176 ---- */ public Object clone() { ! FastHashMap results = null; ! results = new FastHashMap(map); ! return (results); ! } ! /** * Return <code>true</code> if this map contains a mapping for the *************** *** 180,188 **** */ public boolean containsKey(Object key) { ! return (map.containsKey(key)); ! } ! /** * Return <code>true</code> if this map contains one or more keys mapping --- 180,188 ---- */ public boolean containsKey(Object key) { ! return (map.containsKey(key)); ! } ! /** * Return <code>true</code> if this map contains one or more keys mapping *************** *** 192,200 **** */ public boolean containsValue(Object value) { ! return (map.containsValue(value)); ! } ! /** * Return a collection view of the mappings contained in this map. Each --- 192,200 ---- */ public boolean containsValue(Object value) { ! return (map.containsValue(value)); ! } ! /** * Return a collection view of the mappings contained in this map. Each *************** *** 202,210 **** */ public Set entrySet() { ! return (map.entrySet()); ! } ! /** * Compare the specified object with this list for equality. This --- 202,210 ---- */ public Set entrySet() { ! return (map.entrySet()); ! } ! /** * Compare the specified object with this list for equality. This *************** *** 216,231 **** */ public boolean equals(Object o) { ! // Simple tests that require no synchronization if (o == this) ! return (true); else if (!(o instanceof Map)) ! return (false); Map mo = (Map) o; ! // Compare the two maps for equality ! if (mo.size() != map.size()) ! return (false); java.util.Iterator i = map.entrySet().iterator(); while (i.hasNext()) { --- 216,231 ---- */ public boolean equals(Object o) { ! // Simple tests that require no synchronization if (o == this) ! return (true); else if (!(o instanceof Map)) ! return (false); Map mo = (Map) o; ! // Compare the two maps for equality ! if (mo.size() != map.size()) ! return (false); java.util.Iterator i = map.entrySet().iterator(); while (i.hasNext()) { *************** *** 235,249 **** if (value == null) { if (!(mo.get(key) == null && mo.containsKey(key))) ! return (false); } else { if (!value.equals(mo.get(key))) ! return (false); } } return (true); ! } ! /** * Return the value to which this map maps the specified key. Returns --- 235,249 ---- if (value == null) { if (!(mo.get(key) == null && mo.containsKey(key))) ! return (false); } else { if (!value.equals(mo.get(key))) ! return (false); } } return (true); ! } ! /** * Return the value to which this map maps the specified key. Returns *************** *** 255,263 **** */ public Object get(Object key) { ! return (map.get(key)); ! } ! /** * Return the hash code value for this map. This implementation uses --- 255,263 ---- */ public Object get(Object key) { ! return (map.get(key)); ! } ! /** * Return the hash code value for this map. This implementation uses *************** *** 266,296 **** */ public int hashCode() { ! int h = 0; java.util.Iterator i = map.entrySet().iterator(); while (i.hasNext()) ! h += i.next().hashCode(); return (h); ! } ! /** * Return <code>true</code> if this map contains no mappings. */ public boolean isEmpty() { ! return (map.isEmpty()); ! } ! /** * Return a set view of the keys contained in this map. */ public Set keySet() { ! return (map.keySet()); ! } ! /** * Associate the specified value with the specified key in this map. --- 266,296 ---- */ public int hashCode() { ! int h = 0; java.util.Iterator i = map.entrySet().iterator(); while (i.hasNext()) ! h += i.next().hashCode(); return (h); ! } ! /** * Return <code>true</code> if this map contains no mappings. */ public boolean isEmpty() { ! return (map.isEmpty()); ! } ! /** * Return a set view of the keys contained in this map. */ public Set keySet() { ! return (map.keySet()); ! } ! /** * Associate the specified value with the specified key in this map. *************** *** 302,306 **** */ public Object put(Object key, Object value) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); --- 302,306 ---- */ public Object put(Object key, Object value) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); *************** *** 309,315 **** return (result); } ! } ! /** * Copy all of the mappings from the specified map to this one, replacing --- 309,315 ---- return (result); } ! } ! /** * Copy all of the mappings from the specified map to this one, replacing *************** *** 319,323 **** */ public void putAll(Map in) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); --- 319,323 ---- */ public void putAll(Map in) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); *************** *** 325,331 **** map = temp; } ! } ! /** * Remove any mapping for this key, and return any previously --- 325,331 ---- map = temp; } ! } ! /** * Remove any mapping for this key, and return any previously *************** *** 335,339 **** */ public Object remove(Object key) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); --- 335,339 ---- */ public Object remove(Object key) { ! synchronized (this) { HashMap temp = (HashMap) map.clone(); *************** *** 342,367 **** return (result); } ! } ! /** * Return the number of key-value mappings in this map. */ public int size() { ! return (map.size()); ! } ! /** * Return a collection view of the values contained in this map. */ public Collection values() { ! return (map.values()); ! } public String toString() { return map.toString(); } - } \ No newline at end of file --- 342,369 ---- return (result); } ! } ! /** * Return the number of key-value mappings in this map. */ public int size() { ! return (map.size()); ! } ! /** * Return a collection view of the values contained in this map. */ public Collection values() { ! return (map.values()); ! } public String toString() { return map.toString(); } + + } + Index: IdentityMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/IdentityMap.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** IdentityMap.java 1 Jan 2003 13:58:26 -0000 1.1.1.1 --- IdentityMap.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 6,10 **** import java.util.*; ! /** * A hashtable where keys are compared by object identity, * rather than equals(). --- 6,10 ---- import java.util.*; ! /** * A hashtable where keys are compared by object identity, * rather than equals(). *************** *** 25,33 **** return key; } ! public Object getValue() { return value; } ! public Object setValue(Object value) { Object result = this.value; --- 25,33 ---- return key; } ! public Object getValue() { return value; } ! public Object setValue(Object value) { Object result = this.value; *************** *** 73,81 **** return map.size(); } ! public boolean isEmpty() { return map.isEmpty(); } ! public boolean containsKey(Object key) { IdentityKey k = popKey(key); --- 73,81 ---- return map.size(); } ! public boolean isEmpty() { return map.isEmpty(); } ! public boolean containsKey(Object key) { IdentityKey k = popKey(key); *************** *** 84,92 **** return result; } ! public boolean containsValue(Object val) { return map.containsValue(val); } ! public Object get(Object key) { IdentityKey k = popKey(key); --- 84,92 ---- return result; } ! public boolean containsValue(Object val) { return map.containsValue(val); } ! public Object get(Object key) { IdentityKey k = popKey(key); *************** *** 95,103 **** return result; } ! public Object put(Object key, Object value) { return map.put( popKey(key), value ); } ! public Object remove(Object key) { IdentityKey k = popKey(key); --- 95,103 ---- return result; } ! public Object put(Object key, Object value) { return map.put( popKey(key), value ); } ! public Object remove(Object key) { IdentityKey k = popKey(key); *************** *** 106,110 **** return result; } ! public void putAll(Map map) { Iterator iter = map.entrySet().iterator(); --- 106,110 ---- return result; } ! public void putAll(Map map) { Iterator iter = map.entrySet().iterator(); *************** *** 114,118 **** } } ! public void clear() { Iterator iter = map.keySet().iterator(); --- 114,118 ---- } } ! public void clear() { Iterator iter = map.keySet().iterator(); *************** *** 122,135 **** map.clear(); } ! public Set keySet() { // would need an IdentitySet for this! throw new UnsupportedOperationException(); } ! public Collection values() { return map.values(); } ! public Set entrySet() { Set set = new HashSet(); --- 122,135 ---- map.clear(); } ! public Set keySet() { // would need an IdentitySet for this! throw new UnsupportedOperationException(); } ! public Collection values() { return map.values(); } ! public Set entrySet() { Set set = new HashSet(); *************** *** 142,144 **** --- 142,147 ---- } } + + + Index: JDBCExceptionReporter.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/JDBCExceptionReporter.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** JDBCExceptionReporter.java 1 Jan 2003 13:58:26 -0000 1.1.1.1 --- JDBCExceptionReporter.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 9,13 **** public final class JDBCExceptionReporter { ! private static final Log log = LogFactory.getLog(JDBCExceptionReporter.class); --- 9,13 ---- public final class JDBCExceptionReporter { ! private static final Log log = LogFactory.getLog(JDBCExceptionReporter.class); *************** *** 17,48 **** while (warning != null) { log.warn( new StringBuffer(30) ! .append("SQL Warning: ") ! .append( warning.getErrorCode() ) ! .append(", SQLState: ") ! .append( warning.getSQLState() ) ! .toString() ! ); ! log.warn( warning.getMessage() ); ! warning = warning.getNextWarning(); ! } } } ! public static void logExceptions(SQLException ex) { ! if ( log.isErrorEnabled() ) { ! if ( log.isDebugEnabled() ) log.debug( "SQL Exception", ex ); ! while (ex != null) { ! log.warn( new StringBuffer(30) ! .append("SQL Error: ") ! .append( ex.getErrorCode() ) ! .append(", SQLState: ") ! .append( ex.getSQLState() ) ! .toString() ! ); ! log.error( ex.getMessage() ); ! ex = ex.getNextException(); ! } ! } } } --- 17,51 ---- while (warning != null) { log.warn( new StringBuffer(30) ! .append("SQL Warning: ") ! .append( warning.getErrorCode() ) ! .append(", SQLState: ") ! .append( warning.getSQLState() ) ! .toString() ! ); ! log.warn( warning.getMessage() ); ! warning = warning.getNextWarning(); } } + } ! public static void logExceptions(SQLException ex) { ! if ( log.isErrorEnabled() ) { ! if ( log.isDebugEnabled() ) log.debug( "SQL Exception", ex ); ! while (ex != null) { ! log.warn( new StringBuffer(30) ! .append("SQL Error: ") ! .append( ex.getErrorCode() ) ! .append(", SQLState: ") ! .append( ex.getSQLState() ) ! .toString() ! ); ! log.error( ex.getMessage() ); ! ex = ex.getNextException(); } + } + } } + + + Index: JoinedIterator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/JoinedIterator.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** JoinedIterator.java 1 Jan 2003 13:58:26 -0000 1.1.1.1 --- JoinedIterator.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 12,16 **** this.current = 0; } ! public boolean hasNext() { for ( int i = current; i<iterators.length; i++ ) { --- 12,16 ---- this.current = 0; } ! public boolean hasNext() { for ( int i = current; i<iterators.length; i++ ) { *************** *** 19,23 **** return false; } ! public Object next() { if ( iterators[current].hasNext() ) { --- 19,23 ---- return false; } ! public Object next() { if ( iterators[current].hasNext() ) { *************** *** 29,37 **** } } ! public void remove() { iterators[current].remove(); } ! } --- 29,40 ---- } } ! public void remove() { iterators[current].remove(); } ! } + + + Index: LinkedHashCollectionHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/LinkedHashCollectionHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LinkedHashCollectionHelper.java 1 Jan 2003 13:58:26 -0000 1.1.1.1 --- LinkedHashCollectionHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 19,23 **** } } ! public static Set createLinkedHashSet() { try { --- 19,23 ---- } } ! public static Set createLinkedHashSet() { try { *************** *** 28,32 **** } } ! public static Map createLinkedHashMap() { try { --- 28,32 ---- } } ! public static Map createLinkedHashMap() { try { *************** *** 37,40 **** } } ! } --- 37,43 ---- } } ! } + + + Index: NamingHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/NamingHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NamingHelper.java 1 Jan 2003 13:58:28 -0000 1.1.1.1 --- NamingHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 18,47 **** public final class NamingHelper { ! private static final Log log = LogFactory.getLog(NamingHelper.class); ! public static InitialContext getInitialContext(Properties props) throws NamingException { ! Hashtable hash = getJndiProperties(props); log.info("JNDI InitialContext properties:" + hash); ! try { return ( hash.size()==0 ) ? ! new InitialContext() : ! new InitialContext(hash); ! } ! catch (NamingException e) { ! log.error("Could not obtain initial context", e); ! throw e; ! } } ! ! /** ! * Bind val to name in ctx, and make sure that all intermediate contexts exist. ! * ! * @param ctx the root context ! * @param name the name as a string ! * @param val the object to be bound ! * @throws NamingException ! */ public static void bind(Context ctx, String name, Object val) throws NamingException { try { --- 18,47 ---- public final class NamingHelper { ! private static final Log log = LogFactory.getLog(NamingHelper.class); ! public static InitialContext getInitialContext(Properties props) throws NamingException { ! Hashtable hash = getJndiProperties(props); log.info("JNDI InitialContext properties:" + hash); ! try { return ( hash.size()==0 ) ? ! new InitialContext() : ! new InitialContext(hash); ! } ! catch (NamingException e) { ! log.error("Could not obtain initial context", e); ! throw e; ! } } ! ! /** ! * Bind val to name in ctx, and make sure that all intermediate contexts exist. ! * ! * @param ctx the root context ! * @param name the name as a string ! * @param val the object to be bound ! * @throws NamingException ! */ public static void bind(Context ctx, String name, Object val) throws NamingException { try { *************** *** 53,57 **** while ( n.size() > 1 ) { String ctxName = n.get(0); ! Context subctx=null; try { --- 53,57 ---- while ( n.size() > 1 ) { String ctxName = n.get(0); ! Context subctx=null; try { *************** *** 60,64 **** } catch (NameNotFoundException nfe) {} ! if (subctx!=null) { log.debug("Found subcontext: " + ctxName); --- 60,64 ---- } catch (NameNotFoundException nfe) {} ! if (subctx!=null) { log.debug("Found subcontext: " + ctxName); *************** *** 72,80 **** } log.trace("binding: " + n); ! ctx.rebind(n, val); } log.debug("Bound name: " + name); } ! /** * Transform JNDI properties passed in the form <tt>hibernate.jndi.*</tt> to the --- 72,80 ---- } log.trace("binding: " + n); ! ctx.rebind(n, val); } log.debug("Bound name: " + name); } ! /** * Transform JNDI properties passed in the form <tt>hibernate.jndi.*</tt> to the *************** *** 98,113 **** } } ! ! String jndiClass = properties.getProperty(Environment.JNDI_CLASS); ! String jndiURL = properties.getProperty(Environment.JNDI_URL); ! // we want to be able to just use the defaults, ! // if JNDI environment properties are not supplied ! // so don't put null in anywhere ! if (jndiClass != null) result.put(Context.INITIAL_CONTEXT_FACTORY, jndiClass); ! if (jndiURL != null) result.put(Context.PROVIDER_URL, jndiURL); ! return result; } ! } --- 98,116 ---- } } ! ! String jndiClass = properties.getProperty(Environment.JNDI_CLASS); ! String jndiURL = properties.getProperty(Environment.JNDI_URL); ! // we want to be able to just use the defaults, ! // if JNDI environment properties are not supplied ! // so don't put null in anywhere ! if (jndiClass != null) result.put(Context.INITIAL_CONTEXT_FACTORY, jndiClass); ! if (jndiURL != null) result.put(Context.PROVIDER_URL, jndiURL); ! return result; } ! } + + + Index: PropertiesHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/PropertiesHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PropertiesHelper.java 1 Jan 2003 13:58:28 -0000 1.1.1.1 --- PropertiesHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 9,17 **** public final class PropertiesHelper { ! public static boolean getBoolean(String property, Properties properties) { return Boolean.valueOf( properties.getProperty(property) ).booleanValue(); } ! public static int getInt(String property, Properties properties, int defaultValue) { String propValue = properties.getProperty(property); --- 9,17 ---- public final class PropertiesHelper { ! public static boolean getBoolean(String property, Properties properties) { return Boolean.valueOf( properties.getProperty(property) ).booleanValue(); } ! public static int getInt(String property, Properties properties, int defaultValue) { String propValue = properties.getProperty(property); *************** *** 19,29 **** } ! ! public static Integer getInteger(String property, Properties properties) { String propValue = properties.getProperty(property); return (propValue==null) ? null : Integer.valueOf(propValue); } ! public static Map toMap(String property, String delim, Properties properties) { Map map = new HashMap(); --- 19,29 ---- } ! ! public static Integer getInteger(String property, Properties properties) { String propValue = properties.getProperty(property); return (propValue==null) ? null : Integer.valueOf(propValue); } ! public static Map toMap(String property, String delim, Properties properties) { Map map = new HashMap(); *************** *** 53,56 **** } } ! } --- 53,59 ---- } } ! } + + + Index: Range.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/Range.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Range.java 1 Jan 2003 13:58:28 -0000 1.1.1.1 --- Range.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 3,7 **** public class Range { ! public static int[] range(int begin, int length) { int[] result = new int[length]; --- 3,7 ---- public class Range { ! public static int[] range(int begin, int length) { int[] result = new int[length]; *************** *** 12,16 **** } ! } --- 12,19 ---- } ! } + + + Index: ReflectHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/ReflectHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ReflectHelper.java 1 Jan 2003 13:58:29 -0000 1.1.1.1 --- ReflectHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 30,34 **** this.propertyName=propertyName; } ! public void set(Object target, Object value) throws HibernateException { try { --- 30,34 ---- this.propertyName=propertyName; } ! public void set(Object target, Object value) throws HibernateException { try { *************** *** 54,58 **** } } ! } --- 54,58 ---- } } ! } *************** *** 91,97 **** return method; } ! } ! static { Method eq; --- 91,97 ---- return method; } ! } ! static { Method eq; *************** *** 116,120 **** } ! public static Method getMethod(Class theClass, String methodName) throws PropertyNotFoundException { --- 116,120 ---- } ! public static Method getMethod(Class theClass, String methodName) throws PropertyNotFoundException { *************** *** 172,176 **** ) { String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); if ( ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && --- 172,176 ---- ) { String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); if ( ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && *************** *** 181,192 **** } } ! } ! return potentialSetter; } public static Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { ! if (theClass==Object.class || theClass==null) throw new PropertyNotFoundException( "Could not find a getter" ); // will be swallowed ! Method result = getter(theClass, propertyName); --- 181,192 ---- } } ! } ! return potentialSetter; } public static Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { ! if (theClass==Object.class || theClass==null) throw new PropertyNotFoundException( "Could not find a getter" ); // will be swallowed ! Method result = getter(theClass, propertyName); *************** *** 203,207 **** return new Getter(theClass, result, propertyName); } ! } private static Method getter(Class theClass, String propertyName) { --- 203,207 ---- return new Getter(theClass, result, propertyName); } ! } private static Method getter(Class theClass, String propertyName) { *************** *** 211,221 **** // only carry on if the method has no parameters if(methods[i].getParameterTypes().length==0) { ! // try "get" if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) { String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if( ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && methods[i].getParameterTypes().length==0 --- 211,221 ---- // only carry on if the method has no parameters if(methods[i].getParameterTypes().length==0) { ! // try "get" if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) { String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) ); ! String testOldMethod = methods[i].getName().substring(3); ! if( ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && methods[i].getParameterTypes().length==0 *************** *** 228,242 **** String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) ); ! String testOldMethod = methods[i].getName().substring(2); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; } } ! } ! return null; } ! public static Type reflectedPropertyType(Class theClass, String name) throws MappingException { return TypeFactory.hueristicType( getGetter(theClass, name).getReturnType().getName() ); --- 228,242 ---- String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) ); ! String testOldMethod = methods[i].getName().substring(2); ! if( ! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) && ! methods[i].getParameterTypes().length==0 ! ) return methods[i]; } } ! } ! return null; } ! public static Type reflectedPropertyType(Class theClass, String name) throws MappingException { return TypeFactory.hueristicType( getGetter(theClass, name).getReturnType().getName() ); *************** *** 277,288 **** try { ! Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); if (!isPublic(clazz, constructor)) { constructor.setAccessible(true); } return constructor; ! } catch (NoSuchMethodException nme) { throw new PropertyNotFoundException( ! "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" ); --- 277,289 ---- try { ! Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); if (!isPublic(clazz, constructor)) { constructor.setAccessible(true); } return constructor; ! } ! catch (NoSuchMethodException nme) { throw new PropertyNotFoundException( ! "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" ); *************** *** 295,298 **** return (Modifier.isAbstract(modifier) || Modifier.isInterface(modifier)); } ! } --- 296,302 ---- return (Modifier.isAbstract(modifier) || Modifier.isInterface(modifier)); } ! } + + + Index: StringHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/StringHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StringHelper.java 1 Jan 2003 13:58:30 -0000 1.1.1.1 --- StringHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 7,16 **** public final class StringHelper { ! public static String join(String seperator, String[] strings) { int length = strings.length; if (length==0) return ""; StringBuffer buf = new StringBuffer( length * strings[0].length() ) ! .append(strings[0]); for (int i=1; i<length; i++) { buf.append(seperator).append(strings[i]); --- 7,16 ---- public final class StringHelper { ! public static String join(String seperator, String[] strings) { int length = strings.length; if (length==0) return ""; StringBuffer buf = new StringBuffer( length * strings[0].length() ) ! .append(strings[0]); for (int i=1; i<length; i++) { buf.append(seperator).append(strings[i]); *************** *** 34,43 **** else { return new StringBuffer( template.substring(0, loc) ) ! .append(replacement) ! .append( replace( ! template.substring( loc + placeholder.length() ), ! placeholder, ! replacement ! ) ).toString(); } } --- 34,43 ---- else { return new StringBuffer( template.substring(0, loc) ) ! .append(replacement) ! .append( replace( ! template.substring( loc + placeholder.length() ), ! placeholder, ! replacement ! ) ).toString(); } } *************** *** 51,57 **** else { return new StringBuffer( template.substring(0, loc) ) ! .append(replacement) ! .append( template.substring( loc + placeholder.length() ) ) ! .toString(); } } --- 51,57 ---- else { return new StringBuffer( template.substring(0, loc) ) ! .append(replacement) ! .append( template.substring( loc + placeholder.length() ) ) ! .toString(); } } *************** *** 100,104 **** if ( Dialect.QUOTE.indexOf(quote) > -1 ) { return table.substring( 0, table.length()-1 ) + suffix + quote; ! } else { return table + suffix; --- 100,104 ---- if ( Dialect.QUOTE.indexOf(quote) > -1 ) { return table.substring( 0, table.length()-1 ) + suffix + quote; ! } else { return table + suffix; *************** *** 114,118 **** return qualified; } ! public static String root(String qualifiedName) { int loc = qualifiedName.indexOf("."); --- 114,118 ---- return qualified; } ! public static String root(String qualifiedName) { int loc = qualifiedName.indexOf("."); *************** *** 141,145 **** return result; } ! private static String[] multiply(String[] strings, String placeholder, String[] replacements) { String[] results = new String[ replacements.length * strings.length ]; --- 141,145 ---- return result; } ! private static String[] multiply(String[] strings, String placeholder, String[] replacements) { String[] results = new String[ replacements.length * strings.length ]; *************** *** 152,170 **** return results; } ! public static String unQuote(String name) { return ( Dialect.QUOTE.indexOf( name.charAt(0) ) > -1 ) ? ! name.substring(1, name.length()-1) : ! name; ! } ! ! public static void unQuoteInPlace(String[] names) { ! for ( int i=0; i<names.length; i++ ) names[i] = unQuote( names[i] ); ! } ! public static String[] unQuote(String[] names) { ! String[] unquoted = new String[ names.length ]; ! for ( int i=0; i<names.length; i++ ) unquoted[i] = unQuote( names[i] ); ! return unquoted; ! } ! } --- 152,173 ---- return results; } ! public static String unQuote(String name) { return ( Dialect.QUOTE.indexOf( name.charAt(0) ) > -1 ) ? ! name.substring(1, name.length()-1) : ! name; ! } ! ! public static void unQuoteInPlace(String[] names) { ! for ( int i=0; i<names.length; i++ ) names[i] = unQuote( names[i] ); ! } ! public static String[] unQuote(String[] names) { ! String[] unquoted = new String[ names.length ]; ! for ( int i=0; i<names.length; i++ ) unquoted[i] = unQuote( names[i] ); ! return unquoted; ! } ! } + + + Index: XMLHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/XMLHelper.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** XMLHelper.java 1 Jan 2003 13:58:30 -0000 1.1.1.1 --- XMLHelper.java 4 Jan 2003 11:15:32 -0000 1.2 *************** *** 15,20 **** private static final Log log = LogFactory.getLog(XMLHelper.class); private static final EntityResolver dtdResolver = new DTDEntityResolver(); ! ! private XMLHelper() { //cannot be instantiated } --- 15,20 ---- private static final Log log = LogFactory.getLog(XMLHelper.class); private static final EntityResolver dtdResolver = new DTDEntityResolver(); ! ! private XMLHelper() { //cannot be instantiated } *************** *** 38,48 **** log.error( "Error parsing XML: " + file + '(' + error.getLineNumber() + ')', error ); } ! public void fatalError(SAXParseException error) { ! error(error); } public void warning(SAXParseException error) { log.warn( "Warning parsing XML: " + file + '(' + error.getLineNumber() + ')', error ); } ! } ); return builder.parse(source).getDocumentElement().getOwnerDocument(); --- 38,48 ---- log.error( "Error parsing XML: " + file + '(' + error.getLineNumber() + ')', error ); } ! public void fatalError(SAXParseException error) { ! error(error); } public void warning(SAXParseException error) { log.warn( "Warning parsing XML: " + file + '(' + error.getLineNumber() + ')', error ); } ! } ); return builder.parse(source).getDocumentElement().getOwnerDocument(); *************** *** 50,56 **** ! public static Document parseString(String xml) throws IOException, SAXException, ParserConfigurationException { return parseInputSource( new InputSource( new ByteArrayInputStream( xml.getBytes() ) ) ); } ! } --- 50,59 ---- ! public static Document parseString(String xml) throws IOException, SAXException, ParserConfigurationException { return parseInputSource( new InputSource( new ByteArrayInputStream( xml.getBytes() ) ) ); } ! } + + + |