Download Sources

com.liguorien.flex.generator.writers.dom4j.methods
Class GetArray

java.lang.Object
  extended by com.liguorien.flex.generator.writers.dom4j.BuilderMethodWriter
      extended by com.liguorien.flex.generator.writers.dom4j.ContextMethodWriter
          extended by com.liguorien.flex.generator.writers.dom4j.methods.GetArray
All Implemented Interfaces:
MethodWriter<Dom4jBuilderHandler>

public class GetArray
extends ContextMethodWriter

Generates a method who builds an array from a dom4j element.

The generated code looks like this :

 /**
  * Build a Person array from a dom4j element.
  * @param el A dom4j element. 
  * @return A Person array.
  */
 public static Person[] getContacts(Element el) {
     if(el == null) return null;
     final List els = el.elements();
     final int size = els.size();
     final Person[] items = new Person[size];
     for(int i = 0; i < size; i++) {
         final Element e = (Element)els.get(i);
         items[i] = PersonBuilder.getInstance(e);
     }
     return items;
 }
 

Version:
0.2
Author:
Nicolas Désy

Field Summary
 
Fields inherited from interface com.liguorien.flex.generator.writers.MethodWriter
COMPARATOR
 
Constructor Summary
GetArray(java.lang.Class<?> entryClass, java.beans.PropertyDescriptor prop)
          Create a new instance of GetArray
 
Method Summary
static java.lang.String capitalize(java.lang.String name)
          //FIXME: should not be here...
 void writeMethod(java.io.Writer w, FlexGenerator g, Dom4jBuilderHandler handler, java.lang.Class<?> clazz)
          Writes method signature and body to the writer
 
Methods inherited from class com.liguorien.flex.generator.writers.dom4j.ContextMethodWriter
equals, getTypeName, hashCode
 
Methods inherited from class com.liguorien.flex.generator.writers.dom4j.BuilderMethodWriter
acceptClass, getPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GetArray

public GetArray(java.lang.Class<?> entryClass,
                java.beans.PropertyDescriptor prop)
Create a new instance of GetArray

Parameters:
entryClass - The entry type of the array
prop - The property which requested this method generation.
Method Detail

writeMethod

public void writeMethod(java.io.Writer w,
                        FlexGenerator g,
                        Dom4jBuilderHandler handler,
                        java.lang.Class<?> clazz)
                 throws java.io.IOException
Description copied from interface: MethodWriter
Writes method signature and body to the writer

Parameters:
w - The Writer
g - The current generator
handler - The current handler
clazz - The current clazz
Throws:
java.io.IOException

capitalize

public static java.lang.String capitalize(java.lang.String name)
//FIXME: should not be here...

Parameters:
name -
Returns:
The same string with the first letter capitalized

FlexGenerator

Copyright 2006 Nicolas Désy. All rights reserved.