User: user57
Date: 01/10/02 14:34:56
Added: src/main/org/jboss/survey/ejb Debug.java EJBUtils.java
Log:
o moved jboss-website/website/survey to jboss-website/survey (it's own
module)
Revision Changes Path
1.1 website-survey/src/main/org/jboss/survey/ejb/Debug.java
Index: Debug.java
===================================================================
// ----------------------------------------------------------------------------
// File: Debug.java
// Copyright ( c ) 2001 eBuilt, Inc. All rights reserved.
// Version: $Revision: 1.1 $
// Last Checked In: $Date: 2001/10/02 21:34:56 $
// Last Checked In By: $Author: user57 $
// ----------------------------------------------------------------------------
package org.jboss.survey.ejb;
/**
* Debug Constants for the Sony ADOS EJBs
*
* @author Andreas Schaefer
* @version $Revision: 1.1 $
**/
public class Debug
{
// -------------------------------------------------------------------------
// Static
// -------------------------------------------------------------------------
public static final int NONE = 0;
public static final int CRITICAL = 1;
public static final int REGULAR = 2;
public static final int VERBOSE = 3;
public static final int LEVEL = REGULAR;
public static final int DEVELOPMENT = 0;
public static final int PRODUCTION = 1;
public static final int STAGE = DEVELOPMENT;
// -------------------------------------------------------------------------
// Members
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
// EOF
1.1 website-survey/src/main/org/jboss/survey/ejb/EJBUtils.java
Index: EJBUtils.java
===================================================================
// ----------------------------------------------------------------------------
// File: EJBUtils.java
// Copyright ( c ) 2001 eBuilt, Inc. All rights reserved.
// Version: $Revision: 1.1 $
// Last Checked In: $Date: 2001/10/02 21:34:56 $
// Last Checked In By: $Author: user57 $
// ----------------------------------------------------------------------------
package org.jboss.survey.ejb;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Properties;
/**
* Utils for the Sony ADOS EJBs
*
* @author Andreas Schaefer
* @version $Revision: 1.1 $
**/
public class EJBUtils
{
// -------------------------------------------------------------------------
// Static
// -------------------------------------------------------------------------
private static Properties mMessageProperties;
static
{
mMessageProperties = getProperties( "message.properties" );
}
/**
* If defined it loads the given properties file and then returns
* the given properties instance
*
* @param pFileName File Name of the Properties file. If null then no file will
* be loaded.
*
* @return Properties instance
**/
public static Properties getProperties( String pFileName )
{
Properties aReturn = System.getProperties();
try
{
if( pFileName != null && !pFileName.equals( "" ) )
{
InputStream aPropertyStream =
EJBUtils.class.getClassLoader().getResourceAsStream(
"conf/" + pFileName
);
if( aPropertyStream != null )
{
aReturn.load( aPropertyStream );
}
}
}
catch( IOException ioe )
{
ioe.printStackTrace( System.err );
}
return aReturn;
}
public static String getMessage( String pMessageHandler, Object pParameters )
{
String aMessage = mMessageProperties.getProperty( pMessageHandler );
if( aMessage == null || aMessage.equals( "" ) )
{
return pMessageHandler;
}
// Check the given parameters and convert them to a collection if neccessary
Collection aParameters = null;
if( pParameters != null )
{
if( pParameters instanceof Collection )
{
aParameters = (Collection) pParameters;
}
else
{
if( pParameters instanceof Object[] )
{
aParameters = new ArrayList( Arrays.asList( (Object[]) pParameters )
);
}
else
{
aParameters = new ArrayList();
aParameters.add( pParameters );
}
}
}
if( aParameters != null )
{
Iterator i = aParameters.iterator();
int j = 1;
while( i.hasNext() )
{
String aPattern = "%" + j + "%";
String aParameter = "" + i.next();
int aIndex = aMessage.indexOf( aPattern );
if( aIndex >= 0 )
{
if( aIndex >= ( aMessage.length() - aPattern.length() ) )
{
aMessage = aMessage.substring( 0, aIndex ) + aParameter;
}
else
{
aMessage = aMessage.substring( 0, aIndex ) +
aParameter +
aMessage.substring( aIndex + aPattern.length(),
aMessage.length() );
}
}
j++;
}
}
// Add the message handler and list of parameters as the first line if
development
if( Debug.STAGE == Debug.DEVELOPMENT )
{
aMessage = "Handler: " + pMessageHandler + ", " + pParameters + "\\n" +
aMessage;
}
return aMessage;
}
/**
* Checks if the given Date is a SQL-Date and if not then
* converts to it
*
* @param pDate Date to be checked. If null or already a SQL Date then
* it will return the object itself
*
* @param SQL Date if the given date was not null but then a null
**/
public static java.sql.Date checkDate( Date pDate )
{
if( pDate != null && !( pDate instanceof java.sql.Date ) )
{
return new java.sql.Date( pDate.getTime() );
}
return (java.sql.Date) pDate;
}
// -------------------------------------------------------------------------
// Members
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
// EOF
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development