<?xmlspysamplexml?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:cr="http://www.coderapid.com/" version="2.0">
<xsl:output method="text" encoding="ISO-8859-1" media-type="text" />
<xsl:include href="func.xsl" />
<xsl:template match="/" cr:name="Java">
<cr:doc>Creates Java classes and interfaces for all classes.</cr:doc>
<!---->
<xsl:for-each select="cr:classes('void', root(.))">
<xsl:variable name="className" select="cr:nameUpper(current())" />
<xsl:variable name="ends" select="cr:ends(current(), root(.))" />
<xsl:variable name="attrs" select="cr:attributes(current())" />
<xsl:variable name="visibility" select="cr:visibility(current())" />
<xsl:variable name="abstract" select="cr:abstract(current())" />
<xsl:variable name="package" select="cr:classPackage($purePackage, current(), root(.))" />
<xsl:variable name="fileName" select="cr:fileNameJava($purePackage, $className, current(), root(.))" />
<xsl:variable name="extends">
<xsl:if test="cr:extends(current(), root(.)) != ''"> extends <xsl:value-of select="cr:extends(current(), root(.))" /></xsl:if>
</xsl:variable>
<xsl:variable name="implements">
<xsl:choose>
<xsl:when test="cr:implements(current(), root(.)) != ''"> implements <xsl:value-of select="cr:implements(current(), root(.))" /></xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:result-document href="{$fileName}">
package <xsl:value-of select="$package" />;
import java.util.*;
<xsl:value-of select="cr:classImports($purePackage, '', root(.))" />
/** fileName=<xsl:value-of select="$fileName" />
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
<xsl:value-of select="concat($visibility, ' ', $abstract)" /> class <xsl:value-of select="$className" /><xsl:value-of select="$extends" /><xsl:value-of select="$implements" /> {
/**
* <!-- begin-user-doc -->
* no argument constructor
* <!-- end-user-doc -->
* @generated
*/
public <xsl:value-of select="$className" />() {
<xsl:for-each select="$ends">
<xsl:if test="cr:multiUpper(current()) = -1">
<xsl:value-of select="cr:endFieldName(current(), root(.))" />Set = new HashSet();
</xsl:if>
</xsl:for-each>
// begin-user-code
// end-user-code
}
/**
* <!-- begin-user-doc -->
* copy constructor
* <!-- end-user-doc -->
* @generated
*/
public <xsl:value-of select="$className" />(<xsl:value-of select="$className" /> o) {
<xsl:choose>
<xsl:when test="$extends != ''">super(o);</xsl:when>
<xsl:otherwise />
</xsl:choose>
<xsl:for-each select="$attrs">
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
set<xsl:value-of select="$nameUpper" />(o.get<xsl:value-of select="$nameUpper" />());</xsl:for-each>
<xsl:for-each select="$ends">
<xsl:variable name="myUpper" select="cr:multiUpper(current())" />
<xsl:variable name="myFieldNameUpper" select="cr:upper(cr:endFieldName(current(), root(.)))" />
<xsl:choose>
<xsl:when test="$myUpper = -1">
set<xsl:value-of select="$myFieldNameUpper" />Set(o.get<xsl:value-of select="$myFieldNameUpper" />Set());</xsl:when>
<xsl:otherwise>
set<xsl:value-of select="$myFieldNameUpper" />(o.get<xsl:value-of select="$myFieldNameUpper" />());</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
// begin-user-code
// end-user-code
}
/**
* <!-- begin-user-doc -->
* constructor on attributes and navigable associations
* <!-- end-user-doc -->
* @generated
*/
public <xsl:value-of select="$className" />(<xsl:for-each select="$attrs">
<xsl:value-of select="concat(cr:dataType(current(), root(.)), ' ', cr:name(current()))" /><xsl:if test="position() != last() or count($ends) > 0">, </xsl:if></xsl:for-each>
<xsl:for-each select="$ends">
<xsl:variable name="myClassName" select="cr:endClassName(current(), root(.))" />
<xsl:variable name="myFieldName" select="cr:endFieldName(current(), root(.))" />
<xsl:choose>
<xsl:when test="cr:multiUpper(current()) = -1">Set <xsl:value-of select="$myFieldName" />Set</xsl:when>
<xsl:otherwise><xsl:value-of select="concat($myClassName, ' ', $myFieldName)" /></xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">, </xsl:if></xsl:for-each>) {
<xsl:for-each select="$attrs">set<xsl:value-of select="cr:nameUpper(current())" />(<xsl:value-of select="cr:name(current())" />);
</xsl:for-each>
<xsl:for-each select="$ends">
<xsl:variable name="myFieldName" select="cr:endFieldName(current(), root(.))" />
<xsl:variable name="myFieldNameUpper" select="cr:upper(cr:endFieldName(current(), root(.)))" />
<xsl:choose>
<xsl:when test="cr:multiUpper(current()) = -1">
set<xsl:value-of select="$myFieldNameUpper" />Set(<xsl:value-of select="$myFieldName" />Set);</xsl:when>
<xsl:otherwise>
set<xsl:value-of select="$myFieldNameUpper" />(<xsl:value-of select="$myFieldName" />);</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
// begin-user-code
// end-user-code
}
/**
* <!-- begin-user-doc -->
* set attributes and imported associations
* <!-- end-user-doc -->
* @generated
*/
public void setData(<xsl:value-of select="$className" /> o) {
<xsl:for-each select="$attrs">
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
set<xsl:value-of select="$nameUpper" />(o.get<xsl:value-of select="$nameUpper" />());</xsl:for-each>
<xsl:for-each select="$ends">
<xsl:variable name="myFieldNameUpper" select="cr:upper(cr:endFieldName(current(), root(.)))" />
<xsl:choose>
<xsl:when test="cr:multiUpper(current()) = -1"><!----></xsl:when>
<xsl:otherwise>
set<xsl:value-of select="$myFieldNameUpper" />(o.get<xsl:value-of select="$myFieldNameUpper" />());</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
// begin-user-code
// end-user-code
}
<!---->
<xsl:for-each select="cr:operations(current())">
<xsl:variable name="visibility" select="cr:visibility(current())" />
<xsl:variable name="returnType" select="cr:returnType(current(), root(.))" />
<xsl:variable name="abstract" select="cr:abstract(current())" />
<xsl:variable name="static" select="cr:static(current())" />
<xsl:variable name="params" select="cr:parameters(current(), root(.))" />
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
<xsl:value-of select="concat($visibility, ' ', $abstract, ' ', $static, ' ', $returnType, ' ', @name)" />(<xsl:for-each select="$params"><xsl:value-of select="concat(cr:dataType(current(), root(.)), ' ', @name)" /><xsl:if test="position() != last()">, </xsl:if></xsl:for-each>)<xsl:choose>
<xsl:when test="$abstract">;
</xsl:when>
<xsl:otherwise> {
// begin-user-code
<xsl:if test="$returnType != 'void'">
<xsl:value-of select="$returnType" /> ret = null;
return ret;</xsl:if>
// end-user-code
}
</xsl:otherwise></xsl:choose>
</xsl:for-each>
<!---->
<xsl:for-each select="cr:staticAttributes(current())">
<xsl:variable name="name" select="cr:name(current())" />
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
<xsl:variable name="dataType" select="cr:dataType(current(), root(.))" />
<xsl:variable name="initialValue" select="cr:initialValue(current(), root(.))" />
<xsl:variable name="visibility" select="cr:visibility(current())" />
/**
* @unmodifiable
*/
static <xsl:value-of select="concat($visibility, ' ', $dataType, ' ', $name)" /><xsl:if test="$initialValue != ''"> = <xsl:value-of select="$initialValue" /></xsl:if>;
/**
* @unmodifiable
*/
public static <xsl:value-of select="$dataType" /> get<xsl:value-of select="$nameUpper" />() {
return <xsl:value-of select="$name" />;
}
/**
* @unmodifiable
*/
public static void set<xsl:value-of select="$nameUpper" />(<xsl:value-of select="concat($dataType, ' _', $name)" />) {
<xsl:value-of select="$name" /> = _<xsl:value-of select="$name" />;
}
</xsl:for-each>
<!---->
<xsl:for-each select="$attrs">
<xsl:variable name="name" select="cr:name(current())" />
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
<xsl:variable name="dataType" select="cr:dataType(current(), root(.))" />
<xsl:variable name="initialValue" select="cr:initialValue(current(), root(.))" />
<xsl:variable name="visibility" select="cr:visibility(current())" />
/**
* @unmodifiable
*/
<xsl:value-of select="concat($visibility, ' ', $dataType, ' ', $name)" /><xsl:if test="$initialValue != ''"> = <xsl:value-of select="$initialValue" /></xsl:if>;
/**
* @unmodifiable
*/
public <xsl:value-of select="$dataType" /> get<xsl:value-of select="$nameUpper" />() {
return <xsl:value-of select="$name" />;
}
/**
* @unmodifiable
*/
public void set<xsl:value-of select="$nameUpper" />(<xsl:value-of select="concat($dataType, ' ', $name)" />) {
this.<xsl:value-of select="$name" /> = <xsl:value-of select="$name" />;
}
</xsl:for-each>
<!---->
<xsl:for-each select="$ends">
<xsl:variable name="myEnd" select="current()" />
<xsl:variable name="otherEnd" select="cr:otherEnd(current(), root(.))" />
<xsl:variable name="myUpper" select="cr:multiUpper($myEnd)" />
<xsl:variable name="otherUpper" select="cr:multiUpper($otherEnd)" />
<xsl:variable name="myClassName" select="cr:endClassName($myEnd, root(.))" />
<xsl:variable name="otherClassName" select="cr:endClassName($otherEnd, root(.))" />
<xsl:variable name="myFieldName" select="cr:endFieldName($myEnd, root(.))" />
<xsl:variable name="otherFieldName" select="cr:endFieldName($otherEnd, root(.))" />
<xsl:variable name="myFieldNameUpper" select="cr:upper($myFieldName)" />
<xsl:variable name="otherFieldNameUpper" select="cr:upper($otherFieldName)" />
/**
* myUpper=<xsl:value-of select="$myUpper" /> otherUpper=<xsl:value-of select="$otherUpper" />
* @unmodifiable
*/<xsl:choose>
<xsl:when test="$myUpper = -1 and $otherUpper = 1">
protected Set <xsl:value-of select="$myFieldName" />Set;
/**
* @unmodifiable
*/
public Set get<xsl:value-of select="$myFieldNameUpper" />Set() {
return <xsl:value-of select="$myFieldName" />Set;
}
/**
* @unmodifiable
*/
public void set<xsl:value-of select="$myFieldNameUpper" />Set(Set <xsl:value-of select="$myFieldName" />Set) {
this.<xsl:value-of select="$myFieldName" />Set = <xsl:value-of select="$myFieldName" />Set;
}
/**
* @unmodifiable
*/
public void add<xsl:value-of select="$myFieldNameUpper" />(<xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />) {
<xsl:value-of select="$myFieldName" />Set.add(<xsl:value-of select="$myFieldName" />);<!---->
}
</xsl:when>
<xsl:when test="$myUpper = 1 and $otherUpper = -1">
protected <xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />;
/**
* @unmodifiable
*/
public <xsl:value-of select="$myClassName" /> get<xsl:value-of select="$myFieldNameUpper" />() {
return <xsl:value-of select="$myFieldName" />;
}
/**
* @unmodifiable
*/
public void set<xsl:value-of select="$myFieldNameUpper" />(<xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />) {
this.<xsl:value-of select="$myFieldName" /> = <xsl:value-of select="$myFieldName" />;<!---->
}
</xsl:when>
<xsl:when test="$myUpper = 1 and $otherUpper = 1">
protected <xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />;
/**
* @unmodifiable
*/
public <xsl:value-of select="$myClassName" /> get<xsl:value-of select="$myFieldNameUpper" />() {
return <xsl:value-of select="$myFieldName" />;
}
/**
* @unmodifiable
*/
public void set<xsl:value-of select="$myFieldNameUpper" />(<xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />) {
this.<xsl:value-of select="$myFieldName" /> = <xsl:value-of select="$myFieldName" />;<!---->
}
</xsl:when>
<xsl:when test="$myUpper = -1 and $otherUpper = -1">
protected Set <xsl:value-of select="$myFieldName" />Set;
/**
* @unmodifiable
*/
public Set get<xsl:value-of select="$myFieldNameUpper" />Set() {
return <xsl:value-of select="$myFieldName" />Set;
}
/**
* @unmodifiable
*/
public void set<xsl:value-of select="$myFieldNameUpper" />Set(Set <xsl:value-of select="$myFieldName" />Set) {
this.<xsl:value-of select="$myFieldName" />Set = <xsl:value-of select="$myFieldName" />Set;
}
/**
* @unmodifiable
*/
public void add<xsl:value-of select="$myFieldNameUpper" />(<xsl:value-of select="concat($myClassName, ' ', $myFieldName)" />) {
<xsl:value-of select="$myFieldName" />Set.add(<xsl:value-of select="$myFieldName" />);<!---->
}
</xsl:when>
<xsl:otherwise>
/* unsupported cardinality */
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
/**
* <!-- begin-user-doc -->
* comma separated values of all fields
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
sb.append("[");
<xsl:for-each select="$attrs">sb.append(<xsl:value-of select="cr:name(current())" />);
<xsl:if test="position() != last()">sb.append(", ");
</xsl:if></xsl:for-each>
sb.append("]");
// begin-user-code
// end-user-code
return sb.toString();
}
/**
* <!-- begin-user-doc -->
* space separated values of selected fields for display
* <!-- end-user-doc -->
* @generated
*/
public String toDisplayString() {
StringBuffer sb = new StringBuffer();
// begin-user-code
<xsl:if test="$extends != ''">
sb.append(super.toDisplayString());
sb.append(" ");</xsl:if>
<xsl:for-each select="$attrs[1]">
sb.append(<xsl:value-of select="cr:name(current())" /> == null ? "" : <xsl:value-of select="cr:name(current())" />.toString());
<xsl:if test="position() != last()">sb.append(" ");
</xsl:if>
</xsl:for-each>
// end-user-code
return sb.toString();
}
/**
* @unmodifiable
*/
public boolean equals(Object other) {
if (this == other) return true;
if (!(other instanceof <xsl:value-of select="$className" />)) return false;
if(!super.equals(other)) return false;
final <xsl:value-of select="$className" /> o = (<xsl:value-of select="$className" />) other;
<xsl:for-each select="$attrs">
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
if(o.get<xsl:value-of select="$nameUpper" />() == null) {
if (get<xsl:value-of select="$nameUpper" />() != null) return false;
}
else if (!o.get<xsl:value-of select="$nameUpper" />().equals(get<xsl:value-of select="$nameUpper" />()))
return false;
</xsl:for-each>
return true;
}
/**
* @unmodifiable
*/
public int hashCode() {
int res = 0;
<xsl:for-each select="$attrs">
<xsl:variable name="nameUpper" select="cr:nameUpper(current())" />
if(get<xsl:value-of select="$nameUpper" />() != null)
res = 29 * res + get<xsl:value-of select="$nameUpper" />().hashCode();
</xsl:for-each>
return res;
}
}
</xsl:result-document>
</xsl:for-each>
<!---->
<xsl:for-each select="cr:interfaces(root(.))">
<xsl:variable name="className" select="cr:nameUpper(current())" />
<xsl:variable name="visibility" select="cr:visibility(current())" />
<xsl:variable name="package" select="cr:classPackage($purePackage, current(), root(.))" />
<xsl:variable name="fileName" select="cr:fileNameJava($purePackage, $className, current(), root(.))" />
<xsl:variable name="extends">
<xsl:if test="cr:extends(current(), root(.)) != ''"> extends <xsl:value-of select="cr:extends(current(), root(.))" /></xsl:if>
</xsl:variable>
<xsl:result-document href="{$fileName}">
package <xsl:value-of select="$package" />;
import java.util.*;
<xsl:value-of select="cr:classImports($purePackage, 'void', root(.))" />
<xsl:value-of select="cr:classImports($purePackage, 'entity', root(.))" />
/** fileName=<xsl:value-of select="$fileName" />
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
<xsl:value-of select="$visibility" /> interface <xsl:value-of select="$className" /><xsl:value-of select="$extends" /> {
<xsl:for-each select="cr:operations(current())">
<xsl:variable name="visibility" select="cr:visibility(current())" />
<xsl:variable name="returnType" select="cr:returnType(current(), root(.))" />
<xsl:variable name="params" select="cr:parameters(current(), root(.))" />
/**
* @unmodifiable
*/
<xsl:value-of select="concat($visibility, ' ', $returnType, ' ', @name)" />(<xsl:for-each select="$params"><xsl:value-of select="concat(cr:dataType(current(), root(.)), ' ', @name)" /><xsl:if test="position() != last()">, </xsl:if></xsl:for-each>);
</xsl:for-each>
}
</xsl:result-document>
</xsl:for-each>
<!---->
<xsl:for-each select="cr:enumerations(root(.))">
<xsl:variable name="className" select="cr:nameUpper(current())" />
<xsl:variable name="attrs" select="cr:enumerationLiterals(current())" />
<xsl:variable name="visibility" select="cr:visibility(current())" />
<xsl:variable name="package" select="cr:classPackage($purePackage, current(), root(.))" />
<xsl:variable name="fileName" select="cr:fileNameJava($purePackage, $className, current(), root(.))" />
<xsl:result-document href="{$fileName}">
package <xsl:value-of select="$package" />;
/** fileName=<xsl:value-of select="$fileName" />
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
<xsl:value-of select="$visibility" /> class <xsl:value-of select="$className" /> {
private String label;
/**
* <!-- begin-user-doc -->
* private constructor for enum static members
* <!-- end-user-doc -->'
* @generated
*/
private <xsl:value-of select="$className" />(String label) {
this.label = label;
}
<xsl:for-each select="$attrs">
/**
* @unmodified
*/
public static final <xsl:value-of select="concat($className, ' ', @name)" /> = new <xsl:value-of select="$className" />("<xsl:value-of select="@name" />");
</xsl:for-each>
/**
* <!-- begin-user-doc -->
* comma separated values of all fields
* <!-- end-user-doc -->'
* @generated
*/
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
sb.append("[");
sb.append(label);
sb.append("]");
// begin-user-code
// end-user-code
return sb.toString();
}
/**
* <!-- begin-user-doc -->
* space separated values of selected fields for display
* <!-- end-user-doc -->'
* @generated
*/
public String toDisplayString() {
return label;
}
}
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>