You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Christopher Hunt <hu...@internode.on.net> on 2008/09/04 06:27:02 UTC

How to suppress generics warnings

Hi there,

I'm generating JDK 1.5 xmlbeans source but finding that I'm still  
getting warnings of the nature:

	ArrayList is a raw type. References to generic type ArrayList<E>  
should be parameterized...

In my case, the above can be found in methods like:

         /**
          * Gets array of all "Schedule" elements
          */
         public  
com 
.classactionpl.schemas.flightTimes.TimeTableType.Schedules.Schedule[]  
getScheduleArray()
         {
             synchronized (monitor())
             {
                 check_orphaned();
                 java.util.List targetList = new java.util.ArrayList();
   <snip>

with the last line yielding the warning of course.

I do like to eliminate all project warnings so is there a way I can do  
this? Here's my configuration (specified as a xmlbeans-maven-plugin  
which pretty much maps to the ant task from what I understand):

	<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>xmlbeans-maven-plugin</artifactId>
		<version>2.3.1</version>
		<executions>
			<execution>
				<goals>
					<goal>xmlbeans</goal>
				</goals>
			</execution>
		</executions>
		<inherited>true</inherited>
		<configuration>
			<download>true</download>
			<memoryMaximumSize>512m</memoryMaximumSize>
			<schemaDirectory> src/main/resources </schemaDirectory>
			<javaSource>1.5</javaSource>
		</configuration>
	</plugin>
...
	<dependency>
		<groupId>org.apache.xmlbeans</groupId>
		<artifactId>xmlbeans</artifactId>
		<version>2.4.0</version>
	</dependency>

I've also verified that the source produced is indeed for 1.5 and I  
can see other bits of the same source file above that uses generics.

Thanks for any help.

Cheers,
-C

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


RE: Problem compiling a set of schemas with xmlbeans 2.0.0

Posted by Christopher Hunt <hu...@internode.on.net>.
Hi there,

I was experiencing the same problem even with the latest GML schemas.  
The problem is that GML defines a Pos and a PosList element. xmlbeans  
accordingly declares a getPosList() method twice - once for return a  
list of pos elements, and the other for returning a single posList  
element i.e.

     /**
      * Gets a List of "pos" elements
      */
     public java.util.List<net.opengis.gml.x32.DirectPositionType>  
getPosList()

and

     /**
      * Gets the "posList" element
      */
     public net.opengis.gml.x32.DirectPositionListType getPosList()

...of course there are two identical method signatures with different  
return types. This causes scomp to yield the error:

.../target/generated-sources/net/opengis/gml/x32/impl/ 
LinearRingTypeImpl.java:506: getPosList() is already defined in  
net.opengis.gml.x32.impl.LinearRingTypeImpl
     public net.opengis.gml.x32.DirectPositionListType getPosList()

To avoid this error you have to tell xmlbeans to override one of the  
names. I decided that instead of xmlbeans mapping GML "pos" elements  
to Java "pos" members, they map to "position" instead. To achieve this  
use a command line similar to the following:

scomp -d target/generated-classes/ -src target/generated-sources/ -dl - 
javasource 1.5 -mx 512m src/main/resources/gml.xsd src/main/resources/ 
gml.xsdconfig

and an xsdconfig of:

<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/ 
config"
            xmlns:gml="http://www.opengis.net/gml/3.2">
      <xb:qname name="gml:pos" javaname="Position"/>
</xb:config>

'hope that this helps someone else using xmlbeans with GML.

Cheers,
-C

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