Browse Source

Added interface for Message, Identity, Blob

JNI-106
heck 5 years ago
parent
commit
1a08fa3682
  1. 2
      src/foundation/pEp/jniadapter/Blob.java
  2. 5
      src/foundation/pEp/jniadapter/BlobInterface.java
  3. 2
      src/foundation/pEp/jniadapter/Identity.java
  4. 5
      src/foundation/pEp/jniadapter/IdentityInterface.java
  5. 79
      src/gen_java_Message.ysl2

2
src/foundation/pEp/jniadapter/Blob.java

@ -2,7 +2,7 @@ package foundation.pEp.jniadapter;
import java.io.Serializable;
public class Blob implements Serializable {
public class Blob implements BlobInterface, Serializable {
public byte[] data;
public String mime_type;
public String filename;

5
src/foundation/pEp/jniadapter/BlobInterface.java

@ -0,0 +1,5 @@
package foundation.pEp.jniadapter;
public interface BlobInterface {
}

2
src/foundation/pEp/jniadapter/Identity.java

@ -2,7 +2,7 @@ package foundation.pEp.jniadapter;
import java.io.Serializable;
public class Identity implements Serializable{
public class Identity implements IdentityInterface, Serializable {
public String address;
public String fpr;
public String user_id;

5
src/foundation/pEp/jniadapter/IdentityInterface.java

@ -0,0 +1,5 @@
package foundation.pEp.jniadapter;
public interface IdentityInterface {
public Rating getRating();
}

79
src/gen_java_Message.ysl2

@ -18,7 +18,7 @@ tstylesheet {
import java.util.HashMap;
import java.io.Serializable;
public class «$cname» implements AutoCloseable, Serializable {
public class «$cname» implements MessageInterface, AutoCloseable, Serializable {
private static final long serialVersionUID = 2119420428331150924L;
private long handle;
@ -60,6 +60,20 @@ tstylesheet {
`` apply "*[name(.)!='enum']", mode=entry
}
||
document("foundation/pEp/jniadapter/{$cname}Interface.java", "text")
||
package foundation.pEp.jniadapter;
import foundation.pEp.jniadapter.Message.Direction;
import java.util.Date;
import java.util.Vector;
import java.util.ArrayList;
public interface «$cname»Interface {
public String encodeMIME();
`` apply "*[name(.)!='enum']", mode=interface
}
||
}
template "enum|exception" {
@ -244,6 +258,69 @@ tstylesheet {
}
}
template "*", mode=interface {
const "ctype", "name(.)";
const "type" call "toJava" with "type", "name(.)";
const "itype" call "toIntermediate" with "type", "name(.)";
const "name" call "toJava" with "type", "name(*[position()=1])";
choose {
when "$ctype = 'identity'"
||
public «$type» get«$name»();
public void set«$name»(«$type» value);
||
when "$ctype = 'identitylist' or $ctype = 'bloblist' or $ctype = 'stringlist' or $ctype = 'stringpairlist'"
{
const "ename", "substring-after(substring($type,1,string-length($type)-1), '<')";
const "iename" choose {
when "$ctype = 'stringlist'" > byte[]
when "$ctype = 'stringpairlist'" > Pair<byte[],byte[]>
otherwise > _«$ename»
}
const "convget" choose {
when "$ctype = 'stringlist'" > AbstractEngine.toUTF16(i)
when "$ctype = 'stringpairlist'" > new Pair<String, String>(AbstractEngine.toUTF16(i.first), AbstractEngine.toUTF16(i.second))
otherwise > new «$ename»(i)
}
const "convset" choose {
when "$ctype = 'stringlist'" > AbstractEngine.toUTF8(i)
when "$ctype = 'stringpairlist'" > new Pair<byte[],byte[]>(AbstractEngine.toUTF8(i.first), AbstractEngine.toUTF8(i.second))
otherwise > new _«$ename»(i)
}
||
public «$type» get«$name»();
public void set«$name»(«$type» value);
||
}
when "$itype != $type"
||
public «$type» get«$name»();
public void set«$name»(«$type» value);
||
when "$itype != $type"
||
public «$type» get«$name»();
public void set«$name»(«$type» value);
||
when "../enum[@name=$ctype]"
||
public «$itype» get«$name»();
public void set«$name»(«$itype» value);
||
otherwise
||
public «$itype» get«$name»();
public void set«$name»(«$itype» value);
||
}
}
template "*", mode=value {
const "name" call "toJava" with "type", "name(.)";
| «$name» («.»)`if "position()!=last()" > , `

Loading…
Cancel
Save