Skip to content

Commit 1ce95bc

Browse files
committed
Update README.md; rename template documents.
1 parent 008570e commit 1ce95bc

File tree

8 files changed

+26
-21
lines changed

8 files changed

+26
-21
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ HTTP-RPC provides the following classes for creating and consuming REST services
4848
* `WebServiceProxy` - class for invoking remote web services
4949
* `WebServiceException` - exception thrown when a service operation returns an error
5050
* `org.httprpc.beans`
51-
* `BeanAdapter` - class that presents the properties of a Java Bean object as a map and vice versa
52-
* `Key` - annotation that associates a custom key with a Bean property
51+
* `BeanAdapter` - class that presents the properties of a Java bean object as a map and vice versa
52+
* `Key` - annotation that associates a custom key with a bean property
5353
* `org.httprpc.sql`
5454
* `ResultSetAdapter` - class that presents the contents of a JDBC result set as an iterable sequence of maps or typed row values
5555
* `Parameters` - class for applying named parameters values to prepared statements
@@ -411,7 +411,7 @@ March has 31 days
411411
```
412412

413413
## BeanAdapter
414-
The `BeanAdapter` class implements the `Map` interface and exposes any properties defined by the Bean as entries in the map, allowing custom data types to be serialized as JSON objects or CSV records.
414+
The `BeanAdapter` class implements the `Map` interface and exposes any properties defined by a bean as entries in the map, allowing custom data types to be serialized as JSON objects or CSV records.
415415

416416
If a property value is `null` or an instance of one of the following types, it is returned as is:
417417

@@ -424,7 +424,7 @@ If a property value is `null` or an instance of one of the following types, it i
424424
* `java.util.time.LocalTime`
425425
* `java.util.time.LocalDateTime`
426426

427-
If a property returns an instance of `List` or `Map`, the value will be wrapped in an adapter of the same type that automatically adapts its sub-elements. Otherwise, the value is assumed to be a Bean and is wrapped in a `BeanAdapter`.
427+
If a property returns an instance of `List` or `Map`, the value will be wrapped in an adapter of the same type that automatically adapts its sub-elements. Otherwise, the value is assumed to be a bean and is wrapped in a `BeanAdapter`.
428428

429429
For example, the following class might be used to represent a node in a hierarchical object graph:
430430

@@ -531,7 +531,7 @@ If the value is already an instance of the requested type, it is returned as is.
531531
* If the target type is `java.util.time.LocalDate`, `java.util.time.LocalTime`, or `java.util.time.LocalDateTime`, the value is parsed using the appropriate `parse()` method.
532532
* If the target type is `java.util.List` or `java.util.Map`, the value is wrapped in an adapter of the same type that automatically adapts its sub-elements.
533533

534-
Otherwise, the target is assumed to be a Bean, and the value is assumed to be a map. If the target type is a concrete class, an instance of the type is dynamically created and populated using the entries in the map. Property values are adapted as described above. If a property provides multiple setters, the first applicable setter will be applied.
534+
Otherwise, the target is assumed to be a bean, and the value is assumed to be a map. If the target type is a concrete class, an instance of the type is dynamically created and populated using the entries in the map. Property values are adapted as described above. If a property provides multiple setters, the first applicable setter will be applied.
535535

536536
If the target type is an interface, the return value is an implementation of the interface that maps accessor methods to entries in the map. For example, given the following interface definition:
537537

@@ -553,7 +553,7 @@ root.getChildren().get(0).getChildren().get(0).getName(); // "January"
553553
```
554554

555555
### Custom Property Keys
556-
The `Key` annotation can be used to associate a custom key with a Bean property. For example, the following property would appear as "first_name" in the resulting map instead of "firstName":
556+
The `Key` annotation can be used to associate a custom key with a bean property. For example, the following property would appear as "first_name" in the resulting map instead of "firstName":
557557

558558
```java
559559
@Key("first_name")

httprpc-test/src/main/java/org/httprpc/test/mongodb/RestaurantService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public Iterator<Document> iterator() {
8181

8282
csvEncoder.writeValues(cursorAdapter, getResponse().getOutputStream());
8383
} else {
84-
String name = String.format("%s~%s", getRequest().getServletPath().substring(1), format);
84+
String name = String.format("%s.%s", getRequest().getServletPath().substring(1), format);
8585

8686
getResponse().setContentType(String.format("%s;charset=UTF-8", getServletContext().getMimeType(name)));
8787

88-
TemplateEncoder templateEncoder = new TemplateEncoder(getClass().getResource(String.format("%s.txt", name)));
88+
TemplateEncoder templateEncoder = new TemplateEncoder(getClass().getResource(name));
8989

9090
templateEncoder.setBaseName(getClass().getName());
9191
templateEncoder.writeValue(cursorAdapter, getResponse().getOutputStream(), getRequest().getLocale());

httprpc-test/src/main/java/org/httprpc/test/mysql/PetService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ public void getPets(String owner, String format) throws SQLException, IOExceptio
9191

9292
csvEncoder.writeValues(resultSetAdapter, getResponse().getOutputStream());
9393
} else {
94-
String name = String.format("%s~%s", getRequest().getServletPath().substring(1), format);
94+
String name = String.format("%s.%s", getRequest().getServletPath().substring(1), format);
9595

9696
getResponse().setContentType(String.format("%s;charset=UTF-8", getServletContext().getMimeType(name)));
9797

98-
TemplateEncoder templateEncoder = new TemplateEncoder(getClass().getResource(String.format("%s.txt", name)));
98+
TemplateEncoder templateEncoder = new TemplateEncoder(getClass().getResource(name));
9999

100100
templateEncoder.setBaseName(getClass().getName());
101101
templateEncoder.writeValue(resultSetAdapter, getResponse().getOutputStream(), getRequest().getLocale());

httprpc-test/src/main/resources/org/httprpc/test/mongodb/restaurants~html.txt renamed to httprpc-test/src/main/resources/org/httprpc/test/mongodb/restaurants.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body>
66
{{#.}}
77
<p>
8-
<strong>{{name:^html}}</strong></em><br/>
8+
<strong>{{name:^html}}</strong><br/>
99
{{address.building:^html}} {{address.street:^html}}, {{borough:^html}}<br/>
1010
</p>
1111
<p>{{@cuisine:^html}}: <em>{{cuisine:^html}}</em></p>

httprpc-test/src/main/resources/org/httprpc/test/mongodb/restaurants~xml.txt renamed to httprpc-test/src/main/resources/org/httprpc/test/mongodb/restaurants.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<restaurants>
4-
{{#.}}<restaurant>
4+
{{#.}}
5+
<restaurant>
56
<name>{{name:^xml}}</name>
67
<address>
78
<building>{{address.building:^xml}}</building>
@@ -12,5 +13,6 @@
1213
<grades>
1314
{{#grades}}<grade date="{{date:format=shortDate:^xml}}" score="{{score:^xml}}">{{grade:^xml}}</grade>{{/grades}}
1415
</grades>
15-
</restaurant>{{/.}}
16+
</restaurant>
17+
{{/.}}
1618
</restaurants>

httprpc-test/src/main/resources/org/httprpc/test/mysql/pets~html.txt renamed to httprpc-test/src/main/resources/org/httprpc/test/mysql/pets.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
{{@name:^html}}: {{name:^html}}<br/>
99
{{@species:^html}}: {{species:^html}}<br/>
1010
{{@sex:^html}}: {{sex:^html}}<br/>
11-
{{@birth:^html}}: {{birth:format=mediumDate:^html}}</p>
11+
{{@birth:^html}}: {{birth:format=mediumDate:^html}}<br/>
12+
</p>
1213
{{/.}}
1314
</body>
1415
</html>

httprpc-test/src/main/resources/org/httprpc/test/mysql/pets~xml.txt renamed to httprpc-test/src/main/resources/org/httprpc/test/mysql/pets.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<pets>
4-
{{#.}}<pet>
4+
{{#.}}
5+
<pet>
56
<name>{{name:^xml}}</name>
67
<species>{{species:^xml}}</species>
78
<sex>{{sex:^xml}}</sex>
89
<birth>{{birth:format=shortDate:^xml}}</birth>
9-
</pet>{{/.}}
10+
</pet>
11+
{{/.}}
1012
</pets>

httprpc/src/main/java/org/httprpc/beans/BeanAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import java.util.Set;
3737

3838
/**
39-
* Class that presents the properties of a Java Bean object as a map. Property
39+
* Class that presents the properties of a Java bean object as a map. Property
4040
* values are adapted as described for {@link #adapt(Object)}.
4141
*/
4242
public class BeanAdapter extends AbstractMap<String, Object> {
@@ -149,10 +149,10 @@ public Object setValue(Object value) {
149149
private static final String SET_PREFIX = "set";
150150

151151
/**
152-
* Constructs a new Bean adapter.
152+
* Constructs a new bean adapter.
153153
*
154154
* @param bean
155-
* The source Bean.
155+
* The source bean.
156156
*/
157157
public BeanAdapter(Object bean) {
158158
this(bean, new HashMap<>());
@@ -312,7 +312,7 @@ public Entry<String, Object> next() {
312312
* If the value is a {@link List}, it is wrapped in an adapter that will
313313
* adapt the list's elements. If the value is a {@link Map}, it is wrapped
314314
* in an adapter that will adapt the map's values. Otherwise, the value is
315-
* assumed to be a Bean and is wrapped in a {@link BeanAdapter}.
315+
* assumed to be a bean and is wrapped in a {@link BeanAdapter}.
316316
*
317317
* @param <T>
318318
* The target type.
@@ -373,7 +373,7 @@ private static Object adapt(Object value, HashMap<Class<?>, HashMap<String, Meth
373373
* that will adapt the list's elements. If the target type is a {@link Map},
374374
* the value is wrapped in an adapter that will adapt the map's values.
375375
*
376-
* Otherwise, the target is assumed to be a Bean, and the value is assumed
376+
* Otherwise, the target is assumed to be a bean, and the value is assumed
377377
* to be a map. If the target type is not an interface, an instance is
378378
* dynamically created and populated using the entries in the map. Property
379379
* values are adapted as described above. If a property provides multiple

0 commit comments

Comments
 (0)