commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nuno Miguel Ferreira" <Nuno.MFerre...@siemens.com>
Subject [Digester] Object Create Rule
Date Fri, 10 Dec 2004 15:37:17 GMT
  Hi there,

  I'm using Digester to parse a XML file that contains some display
information about a chart. One of the sections in the XML has color
properties as you can see below:

  THE XML FILE SAMPLE
  -------------------
  (...)

  <display-preferences>
	<series>
		<serie visible="true">
			<name>DHTAllocSR</name>
			<color r="255" g="0" b="0" a="255"/>
		</serie>

		<serie visible="true">
			<name>DHTBUSYRATE</name>
			<color r="255" g="200" b="0" a="255"/>
		</serie>
	</series>

  (...)


  THE RULES XML FILE SAMPLE
  -------------------------
  (...)
  <pattern value="display-preferences">
	<object-create-rule
classname="com.siemens.gui.pmonline.reports.setup.model.DisplayPreferenc
es"/>

	<pattern value="series">
		<object-create-rule classname="java.util.ArrayList"/>

  		   	<pattern value="serie">
   		   		<object-create-rule
classname="com.siemens.gui.pmonline.reports.setup.model.Serie"/>
	   		   		
   		   		<set-properties-rule>
					<alias attr-name="visible"
prop-name="visible"/>
				</set-properties-rule>
   		   		
   		   		<bean-property-setter-rule
pattern="name"/>
   		   		
   		   		<pattern value="color">
   		   			<object-create-rule
classname="java.awt.Color"/>
					
   		   		</pattern>
   		   		
   		   		<set-next-rule methodname="add"/>
   		   	</pattern>
 		   	
		<set-next-rule methodname="setSeriesSettings"/>
	</pattern>
  (...)

  I'm parsing this file using a XML rules file like the one above, and
what I wanted to do is create a java.awt.Color when the parser finds the
color tag. The problem is the java.awt.Color constructor ... It has no
empty constructor so the million dollar question is: can I use the
object-create-rule with extra parameters? Such as r (red), g (green), b
(blue) and a (alpha) as defined in the XML. I wanted to avoid the
creation of another object that will then map into a java.awt.Color ...
This doesn't seem right if I can do it directly ... Is there any way to
do this? Help is really needed in this matter ...

  Thanks,

  Nuno Belo

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message