commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Marendo <jmare...@yahoo.com>
Subject Using Digester to store info into a Map
Date Mon, 12 Jun 2006 15:04:03 GMT
Hello,
  
  Would anyone be able to tell me how to structure an XML rules file so  that the Digester
can create objects (from the example file below) and  store them into a Map as opposed to
a Collection?
  
  <?xml version="1.0" encoding="UTF-8"?>
  <user>
      <id>doej01</id>
      <demographic-info>
              <firstName>John</firstName>
              <lastName>Doe</lastName>
      </demographic-info>
      <skills>
          <skill>
              <name>COBOL</name>
              <acquiredDate>2/8/1985</acquiredDate>
              <updateDate>1/19/2006</updateDate>
              <experience>
                  <level>10</level>
                  <description>Adept</description>
              </experience>
          </skill>
          <skill>
              <name>JCL</name>
              <acquiredDate>2/8/1985</acquiredDate>
              <updateDate>1/19/2006</updateDate>
              <experience>
                  <level>10</level>
                  <description>Adept</description>
              </experience>
          </skill>
      </skills>
  </user>
  
  I want to store the User instance in a Map and use the value in the  "id" element as the
key.  There does not appear to be much  documentation available on how to do this--especially
by way of a rules  file.
  
  Jeff
  
  p.s. Here's my rules file that works with a Collection:
  
  <?xml version="1.0" encoding="UTF-8"?>
  
  <digester-rules>
      <pattern value="user">
          <object-create-rule classname="src.gov.ohio.jfs.model.User" />
          <bean-property-setter-rule pattern="id"/>
          <pattern value="demographic-info">
               <object-create-rule     classname="src.gov.ohio.jfs.model.DemographicInformation"
/>
              <bean-property-setter-rule pattern="firstName"/>
              <bean-property-setter-rule pattern="lastName"/>
              <set-next-rule methodname="setDemographicInfo" />
          </pattern>
          <pattern value="skills/skill">
               <object-create-rule     classname="src.gov.ohio.jfs.model.Skill" />
              <bean-property-setter-rule pattern="name"/>
              <bean-property-setter-rule pattern="acquiredDate"/>
              <bean-property-setter-rule pattern="updateDate"/>
              <pattern value="experience">
                   <object-create-rule     classname="src.gov.ohio.jfs.model.Experience"
/>
                  <bean-property-setter-rule pattern="level"/>
                   <bean-property-setter-rule  pattern="description"/>
                  <set-next-rule methodname="setExperience" />
              </pattern>
              <set-next-rule methodname="addSkill" />
          </pattern>
          <set-next-rule methodname="addUser" />
      </pattern>
  </digester-rules>
  
 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message