EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.generator.printer]

COVERAGE SUMMARY FOR SOURCE FILE [JniTypePrinter.java]

nameclass, %method, %block, %line, %
JniTypePrinter.java100% (1/1)100% (7/7)92%  (146/159)98%  (39/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JniTypePrinter100% (1/1)100% (7/7)92%  (146/159)98%  (39/40)
primitiveCxxType (Writer, Class): void 100% (1/1)83%  (64/77)95%  (19/20)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
JniTypePrinter (): void 100% (1/1)100% (3/3)100% (1/1)
arrayCxxType (Writer, Class): void 100% (1/1)100% (17/17)100% (5/5)
getInstance (): JniTypePrinter 100% (1/1)100% (2/2)100% (1/1)
objectCxxType (Writer, Class): void 100% (1/1)100% (34/34)100% (6/6)
print (Class, Writer): void 100% (1/1)100% (21/21)100% (6/6)

1//
2// (c) Copyright, Moebius Solutions, 2002
3//
4//                       All Rights Reserved
5//
6// This material may be reproduced by or for the U. S. Government
7// pursuant to the copyright license under the clause at
8// DFARS 252.227-7013 (OCT 1988).
9//
10/*
11 * $Id: JniTypePrinter.java,v 1.1.1.5 2004/05/25 20:23:30 hastings Exp $
12 */
13package com.moesol.generator.printer;
14 
15import java.io.*;
16 
17/**
18 * Print types out in a manner suitable for interfacing with JNI,
19 * including return types and parameters.
20 */
21public class JniTypePrinter extends TypePrinter {
22    protected JniTypePrinter() { }
23    private static JniTypePrinter instance = new JniTypePrinter();
24    public static JniTypePrinter getInstance() {
25        return instance;
26    }
27    public void print(Class type, Writer out) throws IOException {
28        if (type.isPrimitive()) {
29            primitiveCxxType(out, type);
30        } else if (type.isArray()) {
31            arrayCxxType(out, type);
32        } else {
33            objectCxxType(out, type);
34        }
35    }
36    protected void primitiveCxxType(Writer out, Class type) throws IOException {
37        if (type == Boolean.TYPE) {
38            out.write("jboolean");
39        } else if (type == Byte.TYPE) {
40            out.write("jbyte");
41        } else if (type == Character.TYPE) {
42            out.write("jchar");
43        } else if (type == Short.TYPE) {
44            out.write("jshort");
45        } else if (type == Integer.TYPE) {
46            out.write("jint");
47        } else if (type == Long.TYPE) {
48            out.write("jlong");
49        } else if (type == Float.TYPE) {
50            out.write("jfloat");
51        } else if (type == Double.TYPE) {
52            out.write("jdouble");
53        } else if (type == Void.TYPE) {
54            out.write("void");
55        } else {
56            throw new IllegalArgumentException("Not a known primitive type"
57                                               + type.getName());
58        }
59    }
60    protected void arrayCxxType(Writer out, Class type) throws IOException {
61        if (type.getComponentType().isPrimitive()) {
62            primitiveCxxType(out, type.getComponentType());
63        } else {
64            out.write("jobject");
65        }
66        out.write("Array");
67    }
68    protected void objectCxxType(Writer out, Class type) throws IOException {
69        if (String.class.isAssignableFrom(type)) {
70            out.write("jstring");
71        } else if (Throwable.class.isAssignableFrom(type)) {
72            out.write("jthrowable");
73        } else {
74            out.write("jobject");
75        }
76    }
77}

[all classes][com.moesol.generator.printer]
EMMA 2.0.5312 (C) Vladimir Roubtsov