Skip to content

Commit 9dfdb6f

Browse files
authored
Merge pull request #94 from yumaoka/cust-filter-example
Custom filter example with GP maven
2 parents e4bd53c + 98280b9 commit 9dfdb6f

25 files changed

Lines changed: 188 additions & 15 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
/*
3+
* Copyright IBM Corp. 2018
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
-->
18+
# Globalization Pipeline Custom Resource Filter Example
19+
20+
This folder contains an example custom resource filter implementation code
21+
and the usage example with Globalization Pipeline Maven Plugin.
22+
23+
- csv-filter : A custom resource filter processing resource strings stored in CSV
24+
(comma separated version) files.
25+
- maven : An example Maven project using the CSV filter.
File renamed without changes.
File renamed without changes.

examples/custom-res-filter/.project renamed to examples/custom-res-filter/csv-filter/.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>custom-res-filter</name>
3+
<name>csv-filter</name>
44
<comment></comment>
55
<projects>
66
</projects>

examples/custom-res-filter/.settings/org.eclipse.core.resources.prefs renamed to examples/custom-res-filter/csv-filter/.settings/org.eclipse.core.resources.prefs

File renamed without changes.

examples/custom-res-filter/.settings/org.eclipse.jdt.core.prefs renamed to examples/custom-res-filter/csv-filter/.settings/org.eclipse.jdt.core.prefs

File renamed without changes.

examples/custom-res-filter/.settings/org.eclipse.jdt.ui.prefs renamed to examples/custom-res-filter/csv-filter/.settings/org.eclipse.jdt.ui.prefs

File renamed without changes.

examples/custom-res-filter/.settings/org.eclipse.m2e.core.prefs renamed to examples/custom-res-filter/csv-filter/.settings/org.eclipse.m2e.core.prefs

File renamed without changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!--
2+
/*
3+
* Copyright IBM Corp. 2018
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
-->
18+
# Custom Resource Filter Example - CSV Filter
19+
20+
[Globalization Pipeline Resource Filter](https://github.com/IBM-Cloud/gp-java-tools/tree/master/gp-res-filter) provides
21+
a mechanism to implement your own custom filter, that can be used through
22+
Globalization Pipeline Maven Plugin/Ant Task and other tools.
23+
24+
This example filter implementation read and write resource strings in CSV (Comman Separated Version) format.
25+
26+
There are two types of resource filters.
27+
28+
- [ResourceFilter](https://github.com/IBM-Cloud/gp-java-tools/blob/master/gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/ResourceFilter.java) :
29+
This filter type parses a single resource data and produce a single Globalization
30+
Pipeline bundle. It also writes out a single Globalization Pipeline bundle into a
31+
single resource data.
32+
- [MultiBundleResourceFilter](https://github.com/IBM-Cloud/gp-java-tools/blob/master/gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/MultiBundleResourceFilter.java) :
33+
This filter type parses a single resource data and produces one ore more Globalization
34+
Pipeline bundles. It also writes out one or more Globalization Pipeline bundles
35+
into a single resource data.
36+
37+
A custom resource filter must extends one of above abstract class. Once you have
38+
one or more filter implementations ready, you need to impelment a concrete subclass
39+
of [ResourceFilterProvider](https://github.com/IBM-Cloud/gp-java-tools/blob/master/gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/ResourceFilterProvider.java).
40+
41+
In this example, [CSVFilter](https://github.com/IBM-Cloud/gp-java-tools/blob/master/examples/custom-res-filter/csv-filter/src/main/java/com/ibm/g11n/pipeline/example/CSVFilter.java)
42+
extends `ResourceFilter` and [MultiBundleCSVFilter](https://github.com/IBM-Cloud/gp-java-tools/blob/master/examples/custom-res-filter/csv-filter/src/main/java/com/ibm/g11n/pipeline/example/MultiBundleCSVFilter.java) extends `MultiBundleResourceFilter`.
43+
44+
To integrate your custom filter implementation, you must create a text file
45+
`com.ibm.g11n.pipeline.resfilter.ResourceFilterProvider` specifying your
46+
`ResourceFilterProvider` implementation class, then place the file under
47+
`META-INF/services` in a jar file. In this CSV filter example, the service
48+
description file is found [here](https://github.com/IBM-Cloud/gp-java-tools/blob/master/examples/custom-res-filter/csv-filter/src/main/resources/META-INF/services/com.ibm.g11n.pipeline.resfilter.ResourceFilterProvider).
49+
50+
Once your custom filter jar file is ready, you just need to put the file in
51+
your runtime class path of Globalization Pipeline tools integrated with
52+
`gp-res-filter`.

examples/custom-res-filter/pom.xml renamed to examples/custom-res-filter/csv-filter/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.ibm.g11n.pipeline</groupId>
5-
<artifactId>custom-res-filter</artifactId>
6-
<version>1.2.0-SNAPSHOT</version>
7-
<name>Custom resource filter example</name>
5+
<artifactId>csv-filter</artifactId>
6+
<version>1.0.0</version>
7+
<name>Custom resource filter example - CSV filter</name>
88

99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.ibm.g11n.pipeline</groupId>
2323
<artifactId>gp-res-filter</artifactId>
24-
<version>1.2.0-SNAPSHOT</version>
24+
<version>1.2.0</version>
2525
</dependency>
2626
<!-- JUnit -->
2727
<dependency>

0 commit comments

Comments
 (0)