[Uml-devel] [Bug 53374] Java interface inheritance, abstract classes and generics in code generation
Harald Wallus
wallus at results-hannover.de
Wed Nov 26 04:30:02 UTC 2003
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=53374
------- Additional Comments From wallus at results-hannover.de 2003-11-26 13:29 -------
To 1)
Yes. Java do not need the keyword abstract:
interface Material
{
int HART = 0,
WEICH = HART + 1,
FLAUSCHIG = WEICH + 1;
int berechneGewicht();
}
class Wolle implements Material
{
public int berechneGewicht() { return 234; }
}
class Synthetik implements Material
{
public int berechneGewicht() { return 452; }
}
abstract class Stahl implements Material
{
boolean glänzend;
}
Some more special in java:
If java have an abstract class, it can be extends
abstract class Tier
{
int alter = -1;
void alterSetzen( int a ) { alter = a; }
abstract boolean istSäuger();
abstract void ausgabe();
}
abstract class Säugetier extends Tier
{
boolean istSäuger() { return true; }
}
class Mensch extends Säugetier
{
void ausgabe() {
System.out.println( "Ich bin ein Mensch" );
}
}
class Delfin extends Säugetier
{
void ausgabe() {
System.out.println( "Ich bin ein Delfin" );
}
}
And Java can be implements and extends:
Which means, you can implement an Interface and extend a abstract class.
This is used e.g. in ejb or ozone (for serializing objects)
package srv;
import ozoneDB.OzoneRemote;
abstract public interface Car implements OzoneRemote {
public String getCarBez ( );
public boolean setCarBez ( String CarBez);
public boolean setCarColor ( String CarColor);
public String getCarColor ( );
public boolean setMonthKm ( int Month, int Km);
public int getMonthKm ( int Month);
}
and (I cut the methodscoding off):
package srv;
import ozoneDB.OzoneObject;
public class CarImpl implements Car extends OzoneObject {
static public long serialVersionUID = 1L;
private String m_CarBez;
private String m_CarColor;
private int m_MonthKm[];
public String getCarBez ( ) {
}
public boolean setCarBez ( String CarBez) {
}
public String getCarColor ( ) {
}
public boolean setCarColor ( String CarColor) {
}
public boolean setMonthKm ( int Month, int Km) {
}
public int getMonthKm ( int Month) {
}
May this helps.
Oh, one think:
at the moment (tarball vom 11/23/03) the package and import
statements are written at the bottom of the source code!
More information about the umbrello-devel
mailing list