TranslationScopeImpl.java 2.05 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.granite.translation.api.TranslationScope
 */
package com.adobe.cq.wcm.translation.impl;

import com.adobe.cq.wcm.translation.impl.TranslationBaseObject;
import com.adobe.granite.translation.api.TranslationScope;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class TranslationScopeImpl
implements TranslationScope {
    TranslationBaseObject baseObject;
    String strPrefix;

    public TranslationScopeImpl(TranslationBaseObject baseObject, String strPrefix) {
        this.baseObject = baseObject;
        this.strPrefix = strPrefix;
    }

    public int getWordCount() {
        return 0;
    }

    public int getImageCount() {
        return 0;
    }

    public int getVideoCount() {
        return 0;
    }

    public Map<String, String> getFinalScope() {
        LinkedHashMap<String, String> scopeMap = new LinkedHashMap<String, String>();
        int iCount = this.baseObject.getIntAttribute(this.strPrefix + "scopeMapCount");
        for (int index = 0; index < iCount; ++index) {
            String strKey = this.baseObject.getStringAttribute(this.strPrefix + String.format("scopeMapKey_%d", index));
            String strKeyValue = this.baseObject.getStringAttribute(this.strPrefix + String.format("scopeMapValue_%d", index));
            scopeMap.put(strKey, strKeyValue);
        }
        return scopeMap;
    }

    public void updateScope(TranslationScope scope) {
        Map scopeMap = scope.getFinalScope();
        if (scopeMap != null) {
            this.baseObject.setAttribute(this.strPrefix + "scopeMapCount", scopeMap.size());
            Set keySet = scopeMap.keySet();
            int index = 0;
            for (String key : keySet) {
                this.baseObject.setAttribute(this.strPrefix + String.format("scopeMapKey_%d", index), key);
                this.baseObject.setAttribute(this.strPrefix + String.format("scopeMapValue_%d", index), (String)scopeMap.get(key));
                ++index;
            }
        }
    }
}