I18nContentProcessor.java
2.39 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
65
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.cq.wcm.translation.impl;
import com.adobe.cq.wcm.translation.impl.I18nStringExtractor;
import java.util.HashMap;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.jcr.Node;
import org.apache.sling.api.resource.ResourceResolver;
public abstract class I18nContentProcessor {
protected I18nStringExtractor i18nStringExtractor;
protected HashSet<String> existingI18nStringSet;
protected ResourceResolver resourceResolver;
public I18nContentProcessor(I18nStringExtractor i18nStringExtractor, HashSet<String> existingI18nStringSet, ResourceResolver resourceResolver) {
this.i18nStringExtractor = i18nStringExtractor;
this.existingI18nStringSet = existingI18nStringSet;
this.resourceResolver = resourceResolver;
}
private void addI18nString(String i18nString, String comment, HashMap<String, String> i18nStringMap) {
String i18nKey = i18nString;
if (comment != null) {
i18nKey = i18nString + " ((" + comment + "))";
}
if (!this.existingI18nStringSet.contains(i18nKey)) {
i18nStringMap.put(i18nKey, i18nString);
}
}
protected boolean searchAndAddI18nString(String content, HashMap<String, String> i18nStringMap, String regEx, int stringGroup) {
boolean bSave = false;
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
this.addI18nString(matcher.group(stringGroup), null, i18nStringMap);
bSave = true;
}
return bSave;
}
protected boolean searchAndAddI18nStringWithComment(String content, HashMap<String, String> i18nStringMap, String regEx, int stringGroup, int commentGroup) {
boolean bSave = false;
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
this.addI18nString(matcher.group(stringGroup), matcher.group(commentGroup), i18nStringMap);
bSave = true;
}
return bSave;
}
abstract boolean processFileForI18nStrings(Node var1, HashMap<String, String> var2);
abstract boolean processFileForIncludes(Node var1);
}