/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.model.api.elements.structures;

import org.eclipse.birt.report.model.core.Structure;

public abstract class FormatValue extends Structure
{

	/**
	 * Name of the config variable name member.
	 */

	public static final String CATEGORY_MEMBER = "category"; //$NON-NLS-1$

	/**
	 * Name of the config variable value member.
	 */

	public static final String PATTERN_MEMBER = "pattern"; //$NON-NLS-1$

	/**
	 * The config variable name.
	 */

	private String name = null;

	/**
	 * The config variable value.
	 */

	private String value = null;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.Structure#getIntrinsicProperty(java.lang.String)
	 */

	protected Object getIntrinsicProperty( String memberName )
	{
		if ( CATEGORY_MEMBER.equals( memberName ) )
			return name;
		if ( PATTERN_MEMBER.equals( memberName ) )
			return value;

		assert false;
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.model.core.Structure#setIntrinsicProperty(java.lang.String,
	 *      java.lang.Object)
	 */

	protected void setIntrinsicProperty( String memberName, Object value )
	{
		if ( CATEGORY_MEMBER.equals( memberName ) )
			name = (String) value;
		else if ( PATTERN_MEMBER.equals( memberName ) )
			this.value = (String) value;
		else
			assert false;
	}

	/**
	 * Returns the variable name.
	 * 
	 * @return the variable name
	 */

	public String getCategory( )
	{
		return (String) getProperty( null, CATEGORY_MEMBER );
	}

	/**
	 * Sets the variable name.
	 * 
	 * @param name
	 *            the name to set
	 */

	public void setCategory( String name )
	{
		setProperty( CATEGORY_MEMBER, name );
	}

	/**
	 * Returns the variable value.
	 * 
	 * @return the variable value
	 */

	public String getPattern( )
	{
		return (String) getProperty( null, PATTERN_MEMBER );
	}

	/**
	 * Sets the variable value.
	 * 
	 * @param value
	 *            the value to set
	 */

	public void setPattern( String value )
	{
		setProperty( PATTERN_MEMBER, value );
	}

}

@@ -588,16 +588,74 @@
 tures;%0A%0A
+import org.eclipse.birt.report.model.api.util.StringUtil;%0A
 import o
@@ -792,20 +792,24 @@
 ariable 
-name
+category
  member.
@@ -925,21 +925,23 @@
 ariable 
-value
+pattern
  member.
@@ -1043,28 +1043,32 @@
 ig variable 
-name
+category
 .%0A%09 */%0A%0A%09pri
@@ -1079,20 +1079,24 @@
  String 
-name
+category
  = null;
@@ -1122,29 +1122,31 @@
 ig variable 
-value
+pattern
 .%0A%09 */%0A%0A%09pri
@@ -1157,21 +1157,23 @@
  String 
-value
+pattern
  = null;
@@ -1419,20 +1419,24 @@
 %09return 
-name
+category
 ;%0A%09%09if (
@@ -1484,21 +1484,23 @@
 %09return 
-value
+pattern
 ;%0A%0A%09%09ass
@@ -1806,20 +1806,24 @@
  ) )%0A%09%09%09
-name
+category
  = (Stri
@@ -1891,21 +1891,23 @@
 %09%09%09this.
-value
+pattern
  = (Stri
@@ -2644,10 +2644,263 @@
  );%0A%09%7D%0A%0A
+%09/*%0A%09 * (non-Javadoc)%0A%09 * %0A%09 * @see java.lang.Object#toString()%0A%09 */%0A%0A%09public String toString( )%0A%09%7B%0A%09%09if ( ! StringUtil.isEmpty( pattern ) )%0A%09%09%09return pattern;%0A%09%09if( ! StringUtil.isEmpty( category ) )%0A%09%09%09return category;%0A%09%09return %22%22; //$NON-NLS-1$%0A%09%7D%0A%0A%0A
 %7D%0A

fix bug 159247:Implement toString() in class StringFormatValue, NumberFormatValue and DateTimeFormatValue