public String toAttributeValue( final Object o ) throws BeanException { if ( o instanceof Enum == false ) { throw new BeanException(); } final Enum e = (Enum) o; return e.name(); }
/** * Converts a string to a {@link Integer}. * * @param s * the string. * @return a {@link Integer}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Short( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse number", be ); } } }
public static BeanException getInstance( final String message, final Throwable cause ) { if ( useCause == null ) { useCause = ( "true".equals( ClassicEngineBoot.getInstance().getGlobalConfig().getConfigProperty( "org.pentaho.reporting.engine.classic.core.util.beans.BeanExceptionWithDetailedCause" ) ) ); } if ( Boolean.TRUE.equals( useCause ) ) { return new BeanException( message, cause ); } final BeanException o = (BeanException) localInstance.get(); if ( o == null ) { final BeanException retval = new BeanException( message ); localInstance.set( retval ); return retval; } o.fillInStackTrace(); o.message = message; o.printStackTrace(); return o; }
private Object getPropertyForSpecification( final PropertySpecification name ) throws BeanException { final PropertyDescriptor pd = properties.get( name.getName() ); if ( pd == null ) { throw new BeanException( "No such property:" + name ); final Method readMethod = ipd.getIndexedReadMethod(); if ( readMethod == null ) { throw new BeanException( "Property is not readable: " + name ); throw BeanException.getInstance( "InvokationError", e ); throw BeanException.getInstance( "Property is not readable: " + name, null ); throw new BeanException( "The property contains no array." ); throw iob; } catch ( Exception e ) { throw new BeanException( "Failed to read indexed property." ); return readMethod.invoke( bean ); } catch ( Exception e ) { throw BeanException.getInstance( "InvokationError", e );
private void setProperty( final PropertySpecification name, final Object o ) throws BeanException { final PropertyDescriptor pd = properties.get( name.getName() ); if ( pd == null ) { throw new BeanException( "No such property:" + name ); writeMethod.invoke( bean, new Integer( name.getIndex() ), o ); } catch ( Exception e ) { throw BeanException.getInstance( "InvokationError", e ); throw BeanException.getInstance( "Property is not writeable: " + name, null ); writeMethod.invoke( bean, o ); } catch ( Exception e ) { throw BeanException.getInstance( "InvokationError on property '" + name + "' on bean type " + bean.getClass(), e );
public Object toPropertyValue( final String s ) throws BeanException { try { return Enum.valueOf( enumClass, s ); } catch ( Exception e ) { throw new BeanException( "Failed to convert enum from string " + s, e ); } } }
/** * Converts a string to a {@link Integer}. * * @param s * the string. * @return a {@link Integer}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Long( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o == null ) { throw new NullPointerException(); } if ( o instanceof FontSmooth ) { return String.valueOf( o ); } else { throw new BeanException( "Invalid value specified for FontSmooth" ); } }
/** * Converts a string to a {@link Float}. * * @param s * the string. * @return a {@link Float}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Float( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o instanceof TextWrap ) { return String.valueOf( o ); } else { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a TextWrap." ); } }
/** * Converts a string to a {@link Double}. * * @param s * the string. * @return a {@link Double}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Double( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o instanceof TextRotation ) { return String.valueOf( o ); } else { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a TextRotation." ); } }
/** * Converts a string to a {@link java.math.BigInteger}. * * @param s * the string. * @return a {@link java.math.BigInteger}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new BigInteger( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse string as number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o instanceof TextDirection ) { return String.valueOf( o ); } else { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a TextWrap." ); } }
/** * Converts a string to a {@link BigDecimal}. * * @param s * the string. * @return a {@link BigDecimal}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new BigDecimal( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to convert", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o == null ) { throw new NullPointerException(); } if ( o instanceof BoxSizing ) { return String.valueOf( o ); } else { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a BoxSizing." ); } }
/** * Converts a string to a {@link Byte}. * * @param s * the string. * @return a {@link Byte}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Byte( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o == null ) { throw new NullPointerException(); } if ( o instanceof BorderStyle ) { return String.valueOf( o ); } else { throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a BorderStyle." ); } }
/** * Converts a string to a {@link Integer}. * * @param s * the string. * @return a {@link Integer}. */ public Object toPropertyValue( final String s ) throws BeanException { if ( s == null ) { throw new NullPointerException(); } final String val = s.trim(); if ( val.length() == 0 ) { throw BeanException.getInstance( "Failed to convert empty string to number", null ); } try { return new Integer( val ); } catch ( NumberFormatException be ) { throw BeanException.getInstance( "Failed to parse Number", be ); } } }
public String toAttributeValue( final Object o ) throws BeanException { if ( o == null ) { throw new NullPointerException(); } if ( o instanceof VerticalTextAlign ) { return String.valueOf( o ); } throw new BeanException( "Failed to convert object of type " + o.getClass() + ": Not a VerticalTextAlign." ); }