-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaTemplate.php
More file actions
64 lines (53 loc) · 1.68 KB
/
JavaTemplate.php
File metadata and controls
64 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* This file is part of JsonClassified.
* @link https://github.com/akimsko/JsonClassified
*
* @copyright Copyright 2012 Bo Thinggaard
* @license http://www.apache.org/licenses/LICENSE-2.0
*/
require_once __DIR__ . '/ITemplate.php';
/**
* Template for Java
*
* @author bo@unpossiblesystems.dk
*/
class JavaTemplate implements ITemplate {
private static $_types = array(
Builder::TYPE_STRING => 'String',
Builder::TYPE_INT => 'int',
Builder::TYPE_FLOAT => 'double',
Builder::TYPE_BOOL => 'boolean',
Builder::TYPE_ARRAY => 'List<{subtype}>',
Builder::TYPE_OBJECT => '{subtype}'
);
public function getClass() {
$snippet = "public class {classname} {\n";
$snippet .= "{properties}";
$snippet .= "{methods}";
$snippet .= "}";
return $snippet;
}
public function getPropertyMethods() {
$snippet = "\n\tpublic {type} get{name.uc}() {\n";
$snippet .= "\t\treturn m{name.uc};\n";
$snippet .= "\t}\n\n";
$snippet .= "\tpublic {classname} set{name.uc}({type} {name.lc}) {\n";
$snippet .= "\t\tm{name.uc} = {name.lc};\n";
$snippet .= "\t\treturn this;\n";
$snippet .= "\t}\n";
return $snippet;
}
public function getProperty() {
return "\tprivate {type} m{name.uc};\n";
}
public function getType($typeIndex) {
return array_key_exists($typeIndex, self::$_types) ? self::$_types[$typeIndex] : self::$_types[Builder::TYPE_STRING];
}
public function getFileExtension() {
return ".java";
}
public function getExtras($properties, $class) {
}
}
?>