text:
package org.apache.kylin.gridtable;

import java.io.IOException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.io.IOUtils;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.ByteArray;
import org.apache.kylin.common.util.BytesSerializer;
import org.apache.kylin.common.util.BytesUtil;
import org.apache.kylin.common.util.ImmutableBitSet;
import org.apache.kylin.common.util.SerializeToByteBuffer;
import org.apache.kylin.cube.gridtable.CuboidToGridTableMapping;
import org.apache.kylin.measure.BufferedMeasureCodec;
import org.apache.kylin.metadata.datatype.DataType;
import org.apache.kylin.metadata.expression.TupleExpression;
import org.apache.kylin.metadata.expression.TupleExpressionSerializer;
import org.apache.kylin.metadata.filter.StringCodeSystem;
import org.apache.kylin.metadata.filter.TupleFilter;
import org.apache.kylin.metadata.filter.TupleFilterSerializer;
import org.apache.kylin.metadata.model.TblColRef;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

public class GTScanRequest {

    private static final Logger logger = LoggerFactory.getLogger(GTScanRequest.class);

    //it's not necessary to increase the checkInterval to very large because the check cost is not high
    //changing it might break org.apache.kylin.query.ITKylinQueryTest.testTimeoutQuery()
    public static final int terminateCheckInterval = 100;

    private CuboidToGridTableMapping mapping;
    private GTInfo info;
    private List<GTScanRange> ranges;
    private ImmutableBitSet columns;
    private transient ImmutableBitSet selectedColBlocks;

    // optional expression
    private ImmutableBitSet rtAggrMetrics;

    private ImmutableBitSet dynamicCols;
    private Map<Integer, TupleExpression> tupleExpressionMap;

    // optional filtering
    private TupleFilter filterPushDown;
    private TupleFilter havingFilterPushDown;

    // optional aggregation
    private ImmutableBitSet aggrGroupBy;
    private ImmutableBitSet aggrMetrics;
    private String[] aggrMetricsFuncs;//

    // hint to storage behavior
    private String storageBehavior;
    private long startTime;
    private long timeout;
    private boolean allowStorageAggregation;
    private double aggCacheMemThreshold;
    private int storageScanRowNumThreshold;
    //valid value iff GTCubeStorageQueryBase.enableStorageLimitIfPossible is true
    private int storagePushDownLimit;
    private StorageLimitLevel storageLimitLevel;

    // runtime computed fields
    private transient boolean doingStorageAggregation = false;

    GTScanRequest(GTInfo info, List<GTScanRange> ranges, ImmutableBitSet dimensions, ImmutableBitSet aggrGroupBy, //
            ImmutableBitSet aggrMetrics, String[] aggrMetricsFuncs, ImmutableBitSet rtAggrMetrics, //
            ImmutableBitSet dynamicCols, Map<Integer, TupleExpression> tupleExpressionMap, //
            TupleFilter filterPushDown, TupleFilter havingFilterPushDown, //
            boolean allowStorageAggregation, double aggCacheMemThreshold, int storageScanRowNumThreshold, //
            int storagePushDownLimit, StorageLimitLevel storageLimitLevel, String storageBehavior, long startTime,
            long timeout) {
        this.info = info;
        if (ranges == null) {
            this.ranges = Lists.newArrayList(new GTScanRange(new GTRecord(info), new GTRecord(info)));
        } else {
            this.ranges = ranges;
        }
        this.columns = dimensions;
        this.filterPushDown = filterPushDown;
        this.havingFilterPushDown = havingFilterPushDown;

        this.aggrGroupBy = aggrGroupBy;
        this.aggrMetrics = aggrMetrics;
        this.aggrMetricsFuncs = aggrMetricsFuncs;

        this.rtAggrMetrics = rtAggrMetrics;

        this.dynamicCols = dynamicCols;
        this.tupleExpressionMap = tupleExpressionMap;

        this.storageBehavior = storageBehavior;
        this.startTime = startTime;
        this.timeout = timeout;
        this.allowStorageAggregation = allowStorageAggregation;
        this.aggCacheMemThreshold = aggCacheMemThreshold;
        this.storageScanRowNumThreshold = storageScanRowNumThreshold;
        this.storagePushDownLimit = storagePushDownLimit;
        this.storageLimitLevel = storageLimitLevel;

        validate(info);
    }

    private void validate(GTInfo info) {
        if (hasAggregation()) {
            if (aggrGroupBy.intersects(aggrMetrics) || aggrGroupBy.intersects(rtAggrMetrics))
                throw new IllegalStateException();
            if (aggrMetrics.cardinality() != aggrMetricsFuncs.length)
                throw new IllegalStateException();

            if (columns == null)
                columns = ImmutableBitSet.EMPTY;

            columns = columns.or(aggrGroupBy);
            columns = columns.or(aggrMetrics);
        }

        if (columns == null)
            columns = info.colAll;

        if (hasFilterPushDown()) {
            validateFilterPushDown(info);
        }

        this.selectedColBlocks = info.selectColumnBlocks(columns.or(rtAggrMetrics).andNot(dynamicCols));

    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    private void validateFilterPushDown(GTInfo info) {
        if (!hasFilterPushDown())
            return;

        Set<TblColRef> filterColumns = Sets.newHashSet();
        TupleFilter.collectColumns(filterPushDown, filterColumns);

        for (TblColRef col : filterColumns) {
            // filter columns must belong to the table
            info.validateColRef(col);
            // filter columns must be returned to satisfy upper layer evaluation (calcite)
            columns = columns.set(col.getColumnDesc().getZeroBasedIndex());
        }

        // un-evaluatable filter must be removed
        if (!TupleFilter.isEvaluableRecursively(filterPushDown)) {
            Set<TblColRef> unevaluableColumns = Sets.newHashSet();
            filterPushDown = GTUtil.convertFilterUnevaluatable(filterPushDown, info, unevaluableColumns);

            // columns in un-evaluatable filter must be returned without loss so upper layer can do final evaluation
            if (hasAggregation()) {
                for (TblColRef col : unevaluableColumns) {
                    aggrGroupBy = aggrGroupBy.set(col.getColumnDesc().getZeroBasedIndex());
                }
            }
        }
    }

    public IGTScanner decorateScanner(IGTScanner scanner) throws IOException {
        return decorateScanner(scanner, true, true);
    }

    /**
     * filterToggledOn,aggrToggledOn are only for profiling/test use.
     * in normal cases they are all true.
     *
     * Refer to CoprocessorBehavior for explanation
     */
    public IGTScanner decorateScanner(IGTScanner scanner, boolean filterToggledOn, boolean aggrToggledOn)
            throws IOException {
        return decorateScanner(scanner, filterToggledOn, aggrToggledOn, false, true);
    }

    /**
     * hasPreFiltered indicate the data has been filtered before scanning
     */
    public IGTScanner decorateScanner(IGTScanner scanner, boolean filterToggledOn, boolean aggrToggledOn,
            boolean hasPreFiltered, boolean spillEnabled) throws IOException {
        IGTScanner result = scanner;
        if (!filterToggledOn) { //Skip reading this section if you're not profiling!
            lookAndForget(result);
            return new EmptyGTScanner();
        } else {

            if (this.hasFilterPushDown() && !hasPreFiltered) {
                result = new GTFilterScanner(result, this, null);
            } else {
                result = new GTForwardingScanner(result);//need its check function
            }

            if (tupleExpressionMap != null && !tupleExpressionMap.isEmpty()) {
                logger.info("GTFunctionScanner will be used with expressions " + tupleExpressionMap);
                result = new GTFunctionScanner(result, this);
            }

            if (!aggrToggledOn) {//Skip reading this section if you're not profiling!
                lookAndForget(result);
                return new EmptyGTScanner();
            }

            if (!this.isAllowStorageAggregation() && havingFilterPushDown == null) {
                logger.info("pre aggregation is not beneficial, skip it");
            } else if (this.hasAggregation()) {
                logger.info("pre aggregating results before returning");
                this.doingStorageAggregation = true;
                result = new GTAggregateScanner(result, this, spillEnabled);
            } else {
                logger.info("has no aggregation, skip it");
            }
            return result;
        }
    }

    public BufferedMeasureCodec createMeasureCodec() {
        DataType[] metricTypes = new DataType[aggrMetrics.trueBitCount()];
        for (int i = 0; i < metricTypes.length; i++) {
            metricTypes[i] = info.getColumnType(aggrMetrics.trueBitAt(i));
        }

        BufferedMeasureCodec codec = new BufferedMeasureCodec(metricTypes);
        codec.setBufferSize(info.getMaxColumnLength(aggrMetrics));
        return codec;
    }

    public boolean isDoingStorageAggregation() {
        return doingStorageAggregation;
    }

    //touch every byte of the cell so that the cost of scanning will be truly reflected
    private int lookAndForget(IGTScanner scanner) {
        byte meaninglessByte = 0;
        int scanned = 0;
        for (GTRecord gtRecord : scanner) {
            scanned++;
            for (ByteArray col : gtRecord.getInternal()) {
                if (col != null) {
                    int endIndex = col.offset() + col.length();
                    for (int i = col.offset(); i < endIndex; ++i) {
                        meaninglessByte += col.array()[i];
                    }
                }
            }
        }
        logger.info("Meaningless byte is " + meaninglessByte);
        IOUtils.closeQuietly(scanner);
        return scanned;
    }

    public boolean hasFilterPushDown() {
        return filterPushDown != null;
    }

    //TODO BUG?  select sum() from fact, no aggr by
    public boolean hasAggregation() {
        return !aggrGroupBy.isEmpty() || !aggrMetrics.isEmpty();
    }

    public CuboidToGridTableMapping getMapping() {
        return mapping;
    }

    public void setMapping(CuboidToGridTableMapping mapping) {
        this.mapping = mapping;
    }

    public GTInfo getInfo() {
        return info;
    }

    public List<GTScanRange> getGTScanRanges() {
        return ranges;
    }

    public void clearScanRanges() {
        this.ranges = Lists.newArrayList();
    }

    public ImmutableBitSet getSelectedColBlocks() {
        return selectedColBlocks;
    }

    public ImmutableBitSet getColumns() {
        return columns;
    }

    public TupleFilter getFilterPushDown() {
        return filterPushDown;
    }

    public TupleFilter getHavingFilterPushDown() {
        return havingFilterPushDown;
    }

    public ImmutableBitSet getDimensions() {
        return this.columns.andNot(this.aggrMetrics);
    }

    public ImmutableBitSet getAggrGroupBy() {
        return aggrGroupBy;
    }

    public ImmutableBitSet getAggrMetrics() {
        return aggrMetrics;
    }

    public String[] getAggrMetricsFuncs() {
        return aggrMetricsFuncs;
    }

    public ImmutableBitSet getDynamicCols() {
        return dynamicCols;
    }

    public ImmutableBitSet getRtAggrMetrics() {
        return rtAggrMetrics;
    }

    public Map<Integer, TupleExpression> getTupleExpressionMap() {
        return tupleExpressionMap;
    }

    public boolean isAllowStorageAggregation() {
        return allowStorageAggregation;
    }

    public double getAggCacheMemThreshold() {
        if (aggCacheMemThreshold < 0)
            return 0;
        else
            return aggCacheMemThreshold;
    }

    public void disableAggCacheMemCheck() {
        this.aggCacheMemThreshold = 0;
    }

    public int getStorageScanRowNumThreshold() {
        return storageScanRowNumThreshold;
    }

    public int getStoragePushDownLimit() {
        return this.storagePushDownLimit;
    }

    public StorageLimitLevel getStorageLimitLevel() {
        return storageLimitLevel;
    }

    public String getStorageBehavior() {
        return storageBehavior;
    }

    public long getStartTime() {
        return startTime;
    }

    public long getTimeout() {
        return timeout;
    }

    @Override
    public String toString() {
        return "GTScanRequest [range=" + ranges + ", columns=" + columns + ", filterPushDown=" + filterPushDown
                + ", aggrGroupBy=" + aggrGroupBy + ", aggrMetrics=" + aggrMetrics + ", aggrMetricsFuncs="
                + Arrays.toString(aggrMetricsFuncs) + "]";
    }

    public byte[] toByteArray() {
        ByteBuffer byteBuffer = SerializeToByteBuffer.retrySerialize(new SerializeToByteBuffer.IWriter() {
            @Override
            public void write(ByteBuffer byteBuffer) throws BufferOverflowException {
                GTScanRequest.serializer.serialize(GTScanRequest.this, byteBuffer);
            }
        });
        return Arrays.copyOf(byteBuffer.array(), byteBuffer.position());
    }

    private static final int SERIAL_0_BASE = 0;
    private static final int SERIAL_1_HAVING_FILTER = 1;

    public static final BytesSerializer<GTScanRequest> serializer = new BytesSerializer<GTScanRequest>() {
        @Override
        public void serialize(GTScanRequest value, ByteBuffer out) {
            final int serialLevel = KylinConfig.getInstanceFromEnv().getGTScanRequestSerializationLevel();

            GTInfo.serializer.serialize(value.info, out);

            BytesUtil.writeVInt(value.ranges.size(), out);
            for (GTScanRange range : value.ranges) {
                serializeGTRecord(range.pkStart, out);
                serializeGTRecord(range.pkEnd, out);
                BytesUtil.writeVInt(range.fuzzyKeys.size(), out);
                for (GTRecord f : range.fuzzyKeys) {
                    serializeGTRecord(f, out);
                }
            }

            ImmutableBitSet.serializer.serialize(value.columns, out);
            BytesUtil.writeByteArray(GTUtil.serializeGTFilter(value.filterPushDown, value.info), out);

            if (serialLevel >= SERIAL_1_HAVING_FILTER) {
                BytesUtil.writeByteArray(
                        TupleFilterSerializer.serialize(value.havingFilterPushDown, StringCodeSystem.INSTANCE), out);
            }

            ImmutableBitSet.serializer.serialize(value.aggrGroupBy, out);
            ImmutableBitSet.serializer.serialize(value.aggrMetrics, out);
            BytesUtil.writeAsciiStringArray(value.aggrMetricsFuncs, out);
            BytesUtil.writeVInt(value.allowStorageAggregation ? 1 : 0, out);
            out.putDouble(value.aggCacheMemThreshold);
            BytesUtil.writeUTFString(value.getStorageLimitLevel().name(), out);
            BytesUtil.writeVInt(value.storageScanRowNumThreshold, out);
            BytesUtil.writeVInt(value.storagePushDownLimit, out);
            BytesUtil.writeVLong(value.startTime, out);
            BytesUtil.writeVLong(value.timeout, out);
            BytesUtil.writeUTFString(value.storageBehavior, out);

            // for dynamic related info
            ImmutableBitSet.serializer.serialize(value.dynamicCols, out);

            BytesUtil.writeVInt(value.tupleExpressionMap.size(), out);
            for (int c : value.tupleExpressionMap.keySet()) {
                TupleExpression tupleExpr = value.tupleExpressionMap.get(c);
                BytesUtil.writeVInt(c, out);
                BytesUtil.writeByteArray(TupleExpressionSerializer.serialize(tupleExpr,
                        GTUtil.wrap(value.info.codeSystem.getComparator())), out);
            }
            ImmutableBitSet.serializer.serialize(value.rtAggrMetrics, out);
        }

        @Override
        public GTScanRequest deserialize(ByteBuffer in) {
            final int serialLevel = KylinConfig.getInstanceFromEnv().getGTScanRequestSerializationLevel();

            GTInfo sInfo = GTInfo.serializer.deserialize(in);

            List<GTScanRange> sRanges = Lists.newArrayList();
            int sRangesCount = BytesUtil.readVInt(in);
            for (int rangeIdx = 0; rangeIdx < sRangesCount; rangeIdx++) {
                GTRecord sPkStart = deserializeGTRecord(in, sInfo);
                GTRecord sPkEnd = deserializeGTRecord(in, sInfo);
                List<GTRecord> sFuzzyKeys = Lists.newArrayList();
                int sFuzzyKeySize = BytesUtil.readVInt(in);
                for (int i = 0; i < sFuzzyKeySize; i++) {
                    sFuzzyKeys.add(deserializeGTRecord(in, sInfo));
                }
                GTScanRange sRange = new GTScanRange(sPkStart, sPkEnd, sFuzzyKeys);
                sRanges.add(sRange);
            }

            ImmutableBitSet sColumns = ImmutableBitSet.serializer.deserialize(in);
            TupleFilter sGTFilter = GTUtil.deserializeGTFilter(BytesUtil.readByteArray(in), sInfo);

            TupleFilter sGTHavingFilter = null;
            if (serialLevel >= SERIAL_1_HAVING_FILTER) {
                sGTHavingFilter = TupleFilterSerializer.deserialize(BytesUtil.readByteArray(in),
                        StringCodeSystem.INSTANCE);
            }

            ImmutableBitSet sAggGroupBy = ImmutableBitSet.serializer.deserialize(in);
            ImmutableBitSet sAggrMetrics = ImmutableBitSet.serializer.deserialize(in);
            String[] sAggrMetricFuncs = BytesUtil.readAsciiStringArray(in);
            boolean sAllowPreAggr = (BytesUtil.readVInt(in) == 1);
            double sAggrCacheGB = in.getDouble();
            StorageLimitLevel storageLimitLevel = StorageLimitLevel.valueOf(BytesUtil.readUTFString(in));
            int storageScanRowNumThreshold = BytesUtil.readVInt(in);
            int storagePushDownLimit = BytesUtil.readVInt(in);
            long startTime = BytesUtil.readVLong(in);
            long timeout = BytesUtil.readVLong(in);
            String storageBehavior = BytesUtil.readUTFString(in);

            ImmutableBitSet aDynCols = ImmutableBitSet.serializer.deserialize(in);

            int nTupleExprs = BytesUtil.readVInt(in);
            Map<Integer, TupleExpression> sTupleExpressionMap = Maps.newHashMapWithExpectedSize(nTupleExprs);
            for (int i = 0; i < nTupleExprs; i++) {
                int sC = BytesUtil.readVInt(in);
                TupleExpression sTupleExpr = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(in),
                        GTUtil.wrap(sInfo.codeSystem.getComparator()));
                sTupleExpressionMap.put(sC, sTupleExpr);
            }
            ImmutableBitSet aRuntimeAggrMetrics = ImmutableBitSet.serializer.deserialize(in);

            return new GTScanRequestBuilder().setInfo(sInfo).setRanges(sRanges).setDimensions(sColumns)
                    .setAggrGroupBy(sAggGroupBy).setAggrMetrics(sAggrMetrics).setAggrMetricsFuncs(sAggrMetricFuncs)
                    .setRtAggrMetrics(aRuntimeAggrMetrics).setDynamicColumns(aDynCols)
                    .setExprsPushDown(sTupleExpressionMap)
                    .setFilterPushDown(sGTFilter).setHavingFilterPushDown(sGTHavingFilter)
                    .setAllowStorageAggregation(sAllowPreAggr).setAggCacheMemThreshold(sAggrCacheGB)
                    .setStorageScanRowNumThreshold(storageScanRowNumThreshold)
                    .setStoragePushDownLimit(storagePushDownLimit).setStorageLimitLevel(storageLimitLevel)
                    .setStartTime(startTime).setTimeout(timeout).setStorageBehavior(storageBehavior)
                    .createGTScanRequest();
        }

        private void serializeGTRecord(GTRecord gtRecord, ByteBuffer out) {
            BytesUtil.writeVInt(gtRecord.cols.length, out);
            for (ByteArray col : gtRecord.cols) {
                col.exportData(out);
            }
        }

        private GTRecord deserializeGTRecord(ByteBuffer in, GTInfo sInfo) {
            int colLength = BytesUtil.readVInt(in);
            ByteArray[] sCols = new ByteArray[colLength];
            for (int i = 0; i < colLength; i++) {
                sCols[i] = ByteArray.importData(in);
            }
            return new GTRecord(sInfo, sCols);
        }

    };
}


text:
<?php

if (!defined('PGV_PHPGEDVIEW')) {
	header('HTTP/1.0 403 Forbidden');
	exit;
}

$png["autosearch_ssurname"] = "Inkludér ægtefælles efternavn:";
$pgv_lang["autosearch_sgivennames"] = "Inkludér ægtefælles fornavn(e):";
$pgv_lang["autosearch_plugin_name_gensearchhelp"] = "Genealogy-Search-Help.com plugin";

$pgv_lang["add_task_inst"]              = "Hvis der endnu ikke er oprettet en opgave til dine forskningsresultater, bør du oprette opgaven først, og derefter vælge at gemme og færdiggøre opgaven.";
$pgv_lang["complete_task_inst"] = "Vælg en opgave fra den nedenstående opgaveliste for at færdiggøre opgaven og indtast så dine resultater:";
$pgv_lang["enter_results"]              = "Indtast resultater";
$pgv_lang["auto_gen_inst"]              = "Nogle programmer lader dig indtaste forskningsopgaver som TODO emner i din GEDCOM fil. Denne indstilling vil søge i din GEDCOM fil og automatisk konvertere alle TODO emner til en forskingsopgave.";
$pgv_lang["choose_search_site"] = "Vælg et søgewebsite";
$pgv_lang["pid_search_for"]             = "Hvem ønsker du at søge efter?";
$pgv_lang["manage_research_inst"]       = "Disse punkter vil hjælpe dig med at håndtere dine forskingsopgaver.  Forskningsopgaver hjælper dig med at holde styr på din forskning og at samarbejde med andre forskere.";
$pgv_lang["manage_research"]    = "Håndtér forskning";
$pgv_lang["manage_sources"]             = "Håndtér kilder";
$pgv_lang["part_of"]                    = "Del af (valgfri)";
$pgv_lang["search_fhl"]                 = "Søg i Family History Library kataloget";
$pgv_lang["determine_sources"]  = "Stadfæst mulige kilder";
$pgv_lang["analyze_database"]   = "Analysér database";
$pgv_lang["pid_know_more"]              = "Hvem ønsker du at vide mere om?";
$pgv_lang["analyze_people"]             = "Analysér personer";
$pgv_lang["analyze_data"]               = "Analysér mine data";
$pgv_lang["missing_info"] 		= "Mangler oplysninger";
$pgv_lang["auto_search"]		= "Denne funktion vil automatisk søge på Ancestry og FamilySearch, du kan vælge at søge på navn og født/død dato
";
$pgv_lang["auto_search_text"]	= "Autosøgning";
$pgv_lang["task_list"]			= "Opgaver";
$pgv_lang["task_list_text"]		= "Dette område viser opgaver du har oprettet, klik på Vis for at se opgaverne";

// -- MENU ITEM MESSAGES
$pgv_lang["my_tasks"]							= "Mine opgaver";
$pgv_lang["add_task"]							= "Tilføj opgave";
$pgv_lang["view_folders"]						= "Vis foldere";
$pgv_lang["view_probabilities"]					= "Vis sandsynligheder";
$pgv_lang["up_folder"]							= "Mappe tilbage";
$pgv_lang["edit_folder"]						= "Tilføj/rediger folder";
$pgv_lang["gen_tasks"]							= "Opret automatisk opgaver";

// -- RA GENERAL MESSAGES
$pgv_lang["edit_task"]							= "Rediger opgave";
$pgv_lang["completed"]							= "Færdig";
$pgv_lang["complete"]							= "Færdige";
$pgv_lang["incomplete"]							= "Ikke færdige";
$pgv_lang["created"]							= "Oprettet";
$pgv_lang["details"]							= "Detaljer";
$pgv_lang["result"]                     		= "Resultat";
$pgv_lang["okay"]                               = "Ok";
$pgv_lang["editform"]							= "Rediger formulardata";
$pgv_lang["FilterBy"]							= "Filtrer via";
$pgv_lang["Recalculate"]						= "Genudregn";
$pgv_lang["LocalData"]							= "Lokale data";
$pgv_lang["RelatedRecord"]						= "Relateret post";
$pgv_lang["RelatedData"]						= "Relateret data";
$pgv_lang["Percent"]							= "Procent";
$pgv_lang["Fields"]								= "Antal felter";
$pgv_lang["FieldName"]							= "Feltnavn";
$pgv_lang["InputType"]							= "Inputtype";
$pgv_lang["Values"]								= "Værdier";
$pgv_lang["FormBuilder"]                                                = "FormBuilder";
$pgv_lang["FormName"]							= "Indtast formularnavnet";
$pgv_lang["MultiplePeople"]						= "Angår formularen flere personer?";
$pgv_lang["EnterGEDCOMExtension"]				= "Indtast venligst GEDCOM udvidelsen for formularens fakta-type";
$pgv_lang['FormDesciption']						= "Indtast venligst en beskrivelse af formularen";
$pgv_lang["FormGeneration"]						= "Formular generering færdig!";
$pgv_lang["CustomField"]						= "Tilpasset feltnavn";
$pgv_lang["txt"]							= "Tekst";
$pgv_lang["checkbox"]                                                   = "Afkrydsningsfelt";
$pgv_lang["radiobutton"]                                                = "Radioknap";
$pgv_lang["EnterResults"]                                               = "Indtast resultater";
$pgv_lang["ra_submit"]                                                  = "Indsend";
$pgv_lang["ra_generate_tasks"]                                  = "Generér opgaver fra TODO'er";
$pgv_lang["TaskDescription"]                                    = "Opgavebeskrivelse";
$pgv_lang["SelectFolder"]                       = "Vælg folder:";
$pgv_lang["ra_done"]                                                    = "Færdig";
$pgv_lang["ra_generate"]                                                = "Generer";
$pgv_lang["LocalPercent"]                                               = "Lokal procentdel";
$pgv_lang["GlobalPercent"]                                              = "Global procentdel";
$pgv_lang["Average"]                                                    = "Gennemsnit";
$pgv_lang["NoData"]                                                             = "Ingen data!";
$pgv_lang["NotEnoughData"]                                              = "Ikke nok data!";
$pgv_lang["InferIndvBirthPlac"]                                 = "Der er %PERCENT% chance for at fødselsstedet er:";
$pgv_lang["InferIndvDeathPlac"]                                 = "Der er %PERCENT% chance for at dødsstedet er:";
$pgv_lang["InferIndvSurn"]                                              = "Der er %PERCENT% chance for at efternavnet er:";
$pgv_lang["InferIndvMarriagePlace"]                             = "Der er %PERCENT% chance for at giftestedet er:";
$pgv_lang["InferIndvGivn"]                                              = "Der er %PERCENT% chance for at fornavnet er:";
$pgv_lang["All"]                                                                = "Alle";
$pgv_lang["More"]                                                               = "Mere";
$pgv_lang["ThereIsChance"]                                              = "Mulige kilder kan indeholde:";
$pgv_lang["TheMostLikely"]                                              = "Det mest sandsynlige sted for denne kilde er:";

// -- RA EXPLANATION
$pgv_lang["DataCorrelations"]                                   = "Data sammenhæng";
$pgv_lang["ViewProbExplanation"]					= "Denne side analyserer data fra den aktive GEDCOM's datasæt, og viser sammenhæng i mellem forskellige dataelementer. For eksempel kunne der være en 95% sammenhæng i at efternavnet på den aktuelle post er det samme som efternavnet på faderens post.  Dette ville betyde at 95% af personerne i denne GEDCOM database har samme efternavn som deres far. I denne version af Forskningsassistenten bruges disse beregninger ikke i andre dele af programmet, og vises kun som en hjælp til din forskning.  Vi har dog planer om i fremtiden at bruge disse data til hjælpe dig med meningsfulde forslag til fremtidige forskning. ";

// -- RA_FOLDER MESSAGES
$pgv_lang["Folder"]                             = "Folder:";
$pgv_lang["Edit_Gen_Task"]                              = "Rediger genereret opgave";
$pgv_lang["Start_Date"]                 		= "Startdato";
$pgv_lang["Task_Name"]                			= "Opgavenavn";
$pgv_lang["Folder_Name"]                		= "Foldernavn";
$pgv_lang["Folder_View"]                		= "Foldervisning";
$pgv_lang["Task_View"]                  		= "Opgavevisning";
$pgv_lang["page_header"]						= "Forskningsassistent mapper";
$pgv_lang["no_folder_name"]             		= "Feltet foldernavn skal udfyldes.";
$pgv_lang["add_folder"]                 		= "Tilføj folder";
$pgv_lang["folder_name"]                		= "Foldernavn:";
$pgv_lang["Parent_Folder:"]             		= "Overliggende folder:";
$pgv_lang["No_Parent"]                  		= "Ingen overliggende";
$pgv_lang["Folder_Description:"]        		= "Folderbeskrivelse:";
$pgv_lang["Folder_names_must_be_unique"]		= "Foldernavne skal være unikke.";
$pgv_lang["folder_submitted"]          			= "Din folder er indsendt";
$pgv_lang["folder_problem"]             		= "Der var et problem med tilføjelsen af din folder, prøv venligst igen.";

// -- Missing Information Help
$pgv_lang["ra_missing_info_help"] = "Dette område viser manglende information om posten. Vælg en markeringsboks og en folder, og tryk derefter på Tilføj opgave for at oprette en opgave for det manglende emne. Opgaver der allerede er oprettet vil vise vis i stedet for en markeringsboks.
";

// -- RA_LISTLOGS MESSAGES
$pgv_lang["task_entry"]						= "Opret ny opgave.";

//-- ERROR MESSAGES
$pgv_lang["no_folder"]						= "Der eksisterer ikke nogen foldere endnu. Opret venligst en ny folder først.";

//-- HELP MESSAGES
$pgv_lang["ra_fold_name_help"]			= "~Foldervisning~

Foldernavn: Denne kolonne indeholder navnene på alle de foldere du har oprettet.

Beskrivelse: Denne kolonne indeholder beskrivelsen af folderne.

";
$pgv_lang["ra_add_task_help"]				= "~Tilføj ny opgave~

Titel: Her bør titlen på den opgave du laver stå.

Folder: Her kan du vælge hvilken mappe du ønsker at tilknytte den nye opgave til.

Beskrivelse: Indtast en beskrivelse af den opgave du ønsker at tilføje.

Kilder: Tilkny de eventuelle kilder du har til denne opgave.

Personer: Tilkny eventuelle personer der relateret til den nye opgave.

";
$pgv_lang["ra_edit_folder_help"]			= "
Edit Folder:

Folder Name: This is where you should add the title of the folder that you are editing.

Parent folder: You can assign the parent folder, if any, of the folder you are editing.

Folder description: This is the description of the folder you are editing.

";
$pgv_lang["ra_add_folder_help"]				= "
Add Folder:

Folder Name: This is where you should add the title of the folder that you are adding.

Parent folder: You can assign the parent folder, if any, of the folder you are adding.

Folder description: This is the description of the folder you are adding.

";
$pgv_lang["ra_view_task_help"]				= "
Task View:

Task Name: This column contains the name of all of the tasks you.

Description: This column contains the description of the tasks.

Start Date: This will contain the start dates of all the tasks.

Completed: This will show whether or not a task is completed.

Details: This will show all the details of a task.

Delete: This will delete the task.

";
$pgv_lang["ra_task_view_help"]				= "
View Task:

Title: This should contain the title of the task that you are adding.

People: Assign any people associated for the new task.

Description: Enter a description of the task you want to add.

Sources: Assign any sources that you have for the task.

Click the 'Edit Task' button to edit the details of the task.

";
$pgv_lang["ra_comments_help"]				= "
Comments:

This will contain any comments related to the task. Click the 'Add New Comment' button to add any comments.

";
$pgv_lang["ra_GenerateTasks_help"]			= "
Generate Tasks:

This form generates tasks from the _TODO tags in your GEDCOM file.

Generate: check each task to generate when you press the Generate button.

Task Name: This is the name the task will be given.  This defaults to the text in the actual _TODO tag, excluding any CONT tag"s

Task Description: The description the task will be given.  This is generated from the text in the _TODO tag plus all of the associated CONT tag&quots.

Edit: click the link to edit that task.

Select Folder: select the folder to put the generated tasks in.

Generate: generates the tasks that have been checked.

Done: redirects you to the Folder View page.

";
$pgv_lang["ra_EditGenerateTasks_help"]		= "
Edit Generated Task:

This form allows you to edit the tasks generated from _TODO tags in your GEDCOM file.

Task Name: This is the name the task will be given.

Task Description: The description the task will be given.

People: click the link to select the person to associate the task with.

Source: click the link to select the source to associate the task with.

Save: saves all your changes and redirects you to the Generate tasks page.

Cancel: disregards all your changes and redirects you to the Generate tasks page.

";
$pgv_lang["ra_configure_privacy_help"]		= "
Configure Privacy:

Show To Public: Makes specified task available to everyone.

Show Only To Authenticated Users: Makes specified task available to authenticated users only.

 Show To Admin Users: Makes specified task available to admin users only.

 Hide Even From Admin Users: Makes specified task not available to anyone.

";
$pgv_lang["ra_edit_task_help"]				= "
Edit Task:

Title: This should contain the title of the task that you are editing.

Folder: In this field you can assign which folder you want your new task to go to.

Description: Enter a description of the task you want to edit.

Sources: Assign or edit any sources that you have for the task.

People: Assign or edit any people associated for the task.

";

//-- RA_VIEWTASK MESSAGES
$pgv_lang["view_task"]						= "Vis opgave";
$pgv_lang["add_new_comment"]				= "Tilføj ny kommentar";
$pgv_lang["no_indi_tasks"]					= "Ingen opgaver tilknyttet dette individ.";
$pgv_lang["no_sour_tasks"]					= "Ingen opgaver tilknyttet denne kilde.";
$pgv_lang["edit_comment"]					= "Rediger kommentar";
$pgv_lang["comment_success"]				= "Din kommentar er korrekt tilføjet.";
$pgv_lang['comment_body']					= 'Kommentar';

//-- RA_COMMENT MESSAGES
$pgv_lang["comment_delete_check"]		= "Er du sikker på at du ønsker at slette denne kommentar?";

//-- RA_ADDTASK MESSAGES
$pgv_lang["add_new_task"]				= "Tilføj ny opgave";
$pgv_lang["submit"]						= "Indsend";
$pgv_lang["save_and_complete"]          = "Gem og færdiggør";
$pgv_lang["assign_task"]				= "Tildel opgave";
$pgv_lang["AddTask"]					= "Tilføj opgave";

//-- RA_CONFIGURE PRIVACY MESSAGES
$pgv_lang["configure_privacy"]		    = "Configure Privacy";
$pgv_lang["show_my_tasks"]              = "Vis mine opgaver";
$pgv_lang["show_add_task"]		        = "Vis Tilføj opgave";
$pgv_lang["show_auto_gen_task"]         = "Show Auto Generate Task";
$pgv_lang["show_view_folders"]		    = "Vis Vis mapper";
$pgv_lang["show_add_folder"]		    = "Vis Tilføj mappe";
$pgv_lang["show_add_unlinked_source"]   = "Show Add Unlinked Source";
$pgv_lang["show_view_probabilities"]	= "Show View Probabilities";

//-- Census Forms
$pgv_lang["rows"]                       = "Antal rækker";
$pgv_lang["state"]                      = "Stat";
$pgv_lang["call/url"]                   = "Call Number/URL";
$pgv_lang["enumDate"]                   = "Enumeration Date";
$pgv_lang["county"]                     = "Amt";
$pgv_lang["city"]                       = "By";
$pgv_lang["complete_title"]				= "Færdiggør opgaven";
$pgv_lang["select_form"]				= "Vælg formular";
$pgv_lang['choose_form_label']			= "Choose a common research form:";
$pgv_lang["book"]                 		= "Bog";
$pgv_lang["folio"]                   	= "Folio";
$pgv_lang["uk_county"]					= "Amt";
$pgv_lang["uk_boro"]					= "By eller område";
$pgv_lang["uk_place"]					= "Sted";

$pgv_lang["AssIndiFacts"]                               = "Associate Individual Facts";
$pgv_lang["AssFamFacts"]                                = "Associate Family Facts";
$pgv_lang["ra_facts"]                                   = "Fakta";
$pgv_lang["ra_fact"]                                    = "Fakta";
$pgv_lang["ra_remove"]                                  = "fjern";
$pgv_lang["ra_inferred_facts"]                  = "Inferred Facts";
$pgv_lang["ra_person"]                                  = "Person";
$pgv_lang["ra_reason"]                                  = "Årsag";
$pgv_lang["success"]                                    = "Succes!";

$pgv_lang["registration_no"]                    = "Registreringsnummer:"; //@@
$pgv_lang["serial_no"]                                  = "Serienr.:"; //@@
$pgv_lang["ra_no"]                                              = "Nummer:"; //@@
$pgv_lang["order_no"]                                   = "Ordrenummer:"; //@@

//-- MY TASK BLOCK
$pgv_lang["mytasks_block_descr"]		= "The #pgv_lang[my_tasks]# shows the task for the current user and can be configured to show completed tasks or to show task that are currently unassigned";
$pgv_lang["mytasks_block"] 				= "Research Assistant";
$pgv_lang["mytasks_edit"]               = "Rediger";
$pgv_lang["mytasks_unassigned"]			= "Ikke tildelt";
$pgv_lang["mytasks_takeOn"]				= "TakeOn";
$pgv_lang["mytasks_help"]				= "~MY TASK BLOCK~

The My Task Block shows the task for the current user
and can be configured to show completed tasks or to show
task that are currently unassigned";
$pgv_lang["mytask_show_tasks"]   		= "Vis ikke tildelte opgaver?";
$pgv_lang["mytask_show_completed"]		= "Vis færdige opgaver?";

//-- Auto Search Assistant
$pgv_lang["autosearch_surname"]		    = "Inkluder efternavn:";
$pgv_lang["autosearch_givenname"]	    = "Inkluder fornavne:";
$pgv_lang["autosearch_byear"]		    = "Inkluder fødselsår:";
$pgv_lang["autosearch_bloc"]		    = "Inkluder fødselssted:";
$pgv_lang["autosearch_dyear"]		    = "Inkluder dødsår:";
$pgv_lang["autosearch_dloc"]		    = "Inkluder dødssted:";
$pgv_lang["autosearch_gender"]          = "Inkluder køn:";
$pgv_lang["autosearch_plugin_name"]     = "";
$pgv_lang["autosearch_fsurname"]		= "Inkluder faders efternavn:";
$pgv_lang["autosearch_fgivennames"]		= "Inkluder faders fornavne:";
$pgv_lang["autosearch_msurname"]		= "Inkluder moders efternavn:";
$pgv_lang["autosearch_mgivennames"]	    = "Inkluder moders fornavne:";
$pgv_lang["autosearch_country"]  	    = "Inkluder land:";
$pgv_lang["autosearch_plugin_name_ancestry"] = "Ancestry.com Plug-in";
$pgv_lang["autosearch_plugin_name_ancestrycouk"] = "Ancestry.co.uk Plug-in";
$pgv_lang["autosearch_plugin_name_ellisIsland"] = "EllisIslandRecords.org Plug-in";
$pgv_lang["autosearch_plugin_name_genNet"] = "GeneaNet.com Plug-in";
$pgv_lang["autosearch_plugin_name_gen"]  = "Genealogy.com Plug-in";
$pgv_lang["autosearch_plugin_name_fs"]   = "FamilySearch.org Plug-in";
$pgv_lang["autosearch_plugin_name_werelate"]   = "Werelate.org Plug-in";
$pgv_lang["autosearch_search"]           = "Søg";
$pgv_lang["autosearch_keywords"] = "Nøgleord:";

//Folder deletion error messages
$pgv_lang["has_tasks"]                 ="Denne mappe indeholder i øjeblikket opgaver og kan ikke slettes";
$pgv_lang["has_folders"]               ="Denne mappe indeholder i øjeblikket mapper og kan ikke slettes";
?>

redpajama_set_name: RedPajamaGithub


text:
package javax.naming.spi;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.NamingException;
import javax.naming.CannotProceedException;
import javax.naming.directory.DirContext;
import javax.naming.directory.Attributes;

import com.sun.naming.internal.ResourceManager;
import com.sun.naming.internal.FactoryEnumeration;

/**
  * This class contains methods for supporting <tt>DirContext</tt>
  * implementations.
  *

  * This class is an extension of <tt>NamingManager</tt>.  It contains methods
  * for use by service providers for accessing object factories and
  * state factories, and for getting continuation contexts for
  * supporting federation.
  *

  * <tt>DirectoryManager</tt> is safe for concurrent access by multiple threads.
  *

  * Except as otherwise noted,
  * a <tt>Name</tt>, <tt>Attributes</tt>, or environment parameter
  * passed to any method is owned by the caller.
  * The implementation will not modify the object or keep a reference
  * to it, although it may keep a reference to a clone or copy.
  *
  * @author Rosanna Lee
  * @author Scott Seligman
  *
  * @see DirObjectFactory
  * @see DirStateFactory
  * @since 1.3
  */

public class DirectoryManager extends NamingManager {

    /*
     * Disallow anyone from creating one of these.
     */
    DirectoryManager() {}

    /**
      * Creates a context in which to continue a <tt>DirContext</tt> operation.
      * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
      * only the continuation context returned is a <tt>DirContext</tt>.
      *
      * @param cpe
      *         The non-null exception that triggered this continuation.
      * @return A non-null <tt>DirContext</tt> object for continuing the operation.
      * @exception NamingException If a naming exception occurred.
      *
      * @see NamingManager#getContinuationContext(CannotProceedException)
      */
    @SuppressWarnings("unchecked")
    public static DirContext getContinuationDirContext(
            CannotProceedException cpe) throws NamingException {

        Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
        if (env == null) {
            env = new Hashtable<>(7);
        } else {
            // Make a (shallow) copy of the environment.
            env = (Hashtable<Object,Object>) env.clone();
        }
        env.put(CPE, cpe);

        return (new ContinuationDirContext(cpe, env));
    }

    /**
      * Creates an instance of an object for the specified object,
      * attributes, and environment.
      *

      * This method is the same as <tt>NamingManager.getObjectInstance</tt>
      * except for the following differences:
      *

      *

      * It accepts an <tt>Attributes</tt> parameter that contains attributes
      * associated with the object. The <tt>DirObjectFactory</tt> might use these
      * attributes to save having to look them up from the directory.
      *

      * The object factories tried must implement either
      * <tt>ObjectFactory</tt> or <tt>DirObjectFactory</tt>.
      * If it implements <tt>DirObjectFactory</tt>,
      * <tt>DirObjectFactory.getObjectInstance()</tt> is used, otherwise,
      * <tt>ObjectFactory.getObjectInstance()</tt> is used.
      *

      * Service providers that implement the <tt>DirContext</tt> interface
      * should use this method, not <tt>NamingManager.getObjectInstance()</tt>.
      *

      *
      * @param refInfo The possibly null object for which to create an object.
      * @param name The name of this object relative to nameCtx.
      *         Specifying a name is optional; if it is
      *         omitted, name should be null.
      * @param nameCtx The context relative to which the name
      *         parameter is specified.  If null, name is
      *         relative to the default initial context.
      * @param environment The possibly null environment to
      *         be used in the creation of the object factory and the object.
      * @param attrs The possibly null attributes associated with refInfo.
      *         This might not be the complete set of attributes for refInfo;
      *         you might be able to read more attributes from the directory.
      * @return An object created using refInfo and <tt>attrs</tt>; or
      *         refInfo if an object cannot be created by
      *         a factory.
      * @exception NamingException If a naming exception was encountered
      *         while attempting to get a URL context, or if one of the
      *         factories accessed throws a NamingException.
      * @exception Exception If one of the factories accessed throws an
      *         exception, or if an error was encountered while loading
      *         and instantiating the factory and object classes.
      *         A factory should only throw an exception if it does not want
      *         other factories to be used in an attempt to create an object.
      *         See <tt>DirObjectFactory.getObjectInstance()</tt>.
      * @see NamingManager#getURLContext
      * @see DirObjectFactory
      * @see DirObjectFactory#getObjectInstance
      * @since 1.3
      */
    public static Object
        getObjectInstance(Object refInfo, Name name, Context nameCtx,
                          Hashtable<?,?> environment, Attributes attrs)
        throws Exception {

            ObjectFactory factory;

            ObjectFactoryBuilder builder = getObjectFactoryBuilder();
            if (builder != null) {
                // builder must return non-null factory
                factory = builder.createObjectFactory(refInfo, environment);
                if (factory instanceof DirObjectFactory) {
                    return ((DirObjectFactory)factory).getObjectInstance(
                        refInfo, name, nameCtx, environment, attrs);
                } else {
                    return factory.getObjectInstance(refInfo, name, nameCtx,
                        environment);
                }
            }

            // use reference if possible
            Reference ref = null;
            if (refInfo instanceof Reference) {
                ref = (Reference) refInfo;
            } else if (refInfo instanceof Referenceable) {
                ref = ((Referenceable)(refInfo)).getReference();
            }

            Object answer;

            if (ref != null) {
                String f = ref.getFactoryClassName();
                if (f != null) {
                    // if reference identifies a factory, use exclusively

                    factory = getObjectFactoryFromReference(ref, f);
                    if (factory instanceof DirObjectFactory) {
                        return ((DirObjectFactory)factory).getObjectInstance(
                            ref, name, nameCtx, environment, attrs);
                    } else if (factory != null) {
                        return factory.getObjectInstance(ref, name, nameCtx,
                                                         environment);
                    }
                    // No factory found, so return original refInfo.
                    // Will reach this point if factory class is not in
                    // class path and reference does not contain a URL for it
                    return refInfo;

                } else {
                    // if reference has no factory, check for addresses
                    // containing URLs
                    // ignore name & attrs params; not used in URL factory

                    answer = processURLAddrs(ref, name, nameCtx, environment);
                    if (answer != null) {
                        return answer;
                    }
                }
            }

            // try using any specified factories
            answer = createObjectFromFactories(refInfo, name, nameCtx,
                                               environment, attrs);
            return (answer != null) ? answer : refInfo;
    }

    private static Object createObjectFromFactories(Object obj, Name name,
            Context nameCtx, Hashtable<?,?> environment, Attributes attrs)
        throws Exception {

        FactoryEnumeration factories = ResourceManager.getFactories(
            Context.OBJECT_FACTORIES, environment, nameCtx);

        if (factories == null)
            return null;

        ObjectFactory factory;
        Object answer = null;
        // Try each factory until one succeeds
        while (answer == null && factories.hasMore()) {
            factory = (ObjectFactory)factories.next();
            if (factory instanceof DirObjectFactory) {
                answer = ((DirObjectFactory)factory).
                    getObjectInstance(obj, name, nameCtx, environment, attrs);
            } else {
                answer =
                    factory.getObjectInstance(obj, name, nameCtx, environment);
            }
        }
        return answer;
    }

    /**
      * Retrieves the state of an object for binding when given the original
      * object and its attributes.
      *

      * This method is like <tt>NamingManager.getStateToBind</tt> except
      * for the following differences:
      *

      *
It accepts an <tt>Attributes</tt> parameter containing attributes
      *    that were passed to the <tt>DirContext.bind()</tt> method.
      *
It returns a non-null <tt>DirStateFactory.Result</tt> instance
      *    containing the object to be bound, and the attributes to
      *    accompany the binding. Either the object or the attributes may be null.
      *

      * The state factories tried must each implement either
      * <tt>StateFactory</tt> or <tt>DirStateFactory</tt>.
      * If it implements <tt>DirStateFactory</tt>, then
      * <tt>DirStateFactory.getStateToBind()</tt> is called; otherwise,
      * <tt>StateFactory.getStateToBind()</tt> is called.
      *

      *
      * Service providers that implement the <tt>DirContext</tt> interface
      * should use this method, not <tt>NamingManager.getStateToBind()</tt>.
      *

      * See NamingManager.getStateToBind() for a description of how
      * the list of state factories to be tried is determined.
      *

      * The object returned by this method is owned by the caller.
      * The implementation will not subsequently modify it.
      * It will contain either a new <tt>Attributes</tt> object that is
      * likewise owned by the caller, or a reference to the original
      * <tt>attrs</tt> parameter.
      *
      * @param obj The non-null object for which to get state to bind.
      * @param name The name of this object relative to nameCtx,
      *         or null if no name is specified.
      * @param nameCtx The context relative to which the name
      *         parameter is specified, or null if name is
      *         relative to the default initial context.
      * @param environment The possibly null environment to
      *         be used in the creation of the state factory and
      *         the object's state.
      * @param attrs The possibly null Attributes that is to be bound with the
      *         object.
      * @return A non-null DirStateFactory.Result containing
      *  the object and attributes to be bound.
      *  If no state factory returns a non-null answer, the result will contain
      *  the object (<tt>obj</tt>) itself with the original attributes.
      * @exception NamingException If a naming exception was encountered
      *         while using the factories.
      *         A factory should only throw an exception if it does not want
      *         other factories to be used in an attempt to create an object.
      *         See <tt>DirStateFactory.getStateToBind()</tt>.
      * @see DirStateFactory
      * @see DirStateFactory#getStateToBind
      * @see NamingManager#getStateToBind
      * @since 1.3
      */
    public static DirStateFactory.Result
        getStateToBind(Object obj, Name name, Context nameCtx,
                       Hashtable<?,?> environment, Attributes attrs)
        throws NamingException {

        // Get list of state factories
        FactoryEnumeration factories = ResourceManager.getFactories(
            Context.STATE_FACTORIES, environment, nameCtx);

        if (factories == null) {
            // no factories to try; just return originals
            return new DirStateFactory.Result(obj, attrs);
        }

        // Try each factory until one succeeds
        StateFactory factory;
        Object objanswer;
        DirStateFactory.Result answer = null;
        while (answer == null && factories.hasMore()) {
            factory = (StateFactory)factories.next();
            if (factory instanceof DirStateFactory) {
                answer = ((DirStateFactory)factory).
                    getStateToBind(obj, name, nameCtx, environment, attrs);
            } else {
                objanswer =
                    factory.getStateToBind(obj, name, nameCtx, environment);
                if (objanswer != null) {
                    answer = new DirStateFactory.Result(objanswer, attrs);
                }
            }
        }

        return (answer != null) ? answer :
            new DirStateFactory.Result(obj, attrs); // nothing new
    }
}


text:
package com.crm.webservice;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for vgRequest complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="vgRequest">
 *   <complexContent>
 *     <extension base="{http://webservice.crm.com/}request">
 *       <sequence>
 *         <element name="content" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="isdn" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="serviceAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       </sequence>
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "vgRequest", propOrder = {
    "content",
    "isdn",
    "password",
    "serviceAddress"
})
public class VgRequest
    extends Request
{

    protected String content;
    protected String isdn;
    protected String password;
    protected String serviceAddress;

    /**
     * Gets the value of the content property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getContent() {
        return content;
    }

    /**
     * Sets the value of the content property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setContent(String value) {
        this.content = value;
    }

    /**
     * Gets the value of the isdn property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getIsdn() {
        return isdn;
    }

    /**
     * Sets the value of the isdn property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setIsdn(String value) {
        this.isdn = value;
    }

    /**
     * Gets the value of the password property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getPassword() {
        return password;
    }

    /**
     * Sets the value of the password property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setPassword(String value) {
        this.password = value;
    }

    /**
     * Gets the value of the serviceAddress property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getServiceAddress() {
        return serviceAddress;
    }

    /**
     * Sets the value of the serviceAddress property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setServiceAddress(String value) {
        this.serviceAddress = value;
    }

}


text:
input{
	border:1px solid blue;
	color:red;
}


text:
(function () {
  'use strict';

  angular
    .module('resume')
    .factory('wittyMessage', wittyMessage);

  /** @ngInject */
  function wittyMessage() {
    var messages
      , service = {};

    messages = [
      'hold your breath, I dare you ;)',
      'you\'re not in Kansas any more',
      'it is still faster than you could grab it',
      'the bits are flowing slowly today',
      'jumping into the rabbit hole',
      'I\'m moving as fast as I can',
      'pay no attention to the man behind the curtain and enjoy the elevator music',
      'a few bits tried to escape, but we caught them',
      'the server is powered by a lemon and two electrodes',
      'checking the gravitational constant in your locale',
      'we\'re testing your patience',
      'follow the white rabbit',
      'pulling Neo from the matrix',
      'dialing the 8th chevron isn\'t easy you know',
      'setting phasers to fun',
      'doo doo doo, la la la, c\'mon already...',
      'I\'m running out of witty loading messages',
      'do you ever sometimes just wake up and wonder if you\'re actually mentally handicapped' +
        ' and everyone around you is just being nice? No? Just me?... Carry on',
      'Hey look over there!',
      'You might wanna go make a sandwich',
      'I wonder if you know I intentionally slowed this process down... muahahahaha',
      'I do believe in fairies! I do! I do!',
      'Okay enough is enough, load already'
    ];

    service = {
      messages: messages,
      getRandom: getRandom
    };

    return service;

    function getRandom() {
      return messages[Math.floor(Math.random() * messages.length)];
    }

  }
}());


text:
import six

from taskflow import test
from taskflow.utils import misc

def _bytes(data):
    if six.PY3:
        return data.encode(encoding='utf-8')
    else:
        return data

class BinaryEncodeTest(test.TestCase):

    def _check(self, data, expected_result):
        result = misc.binary_encode(data)
        self.assertIsInstance(result, six.binary_type)
        self.assertEqual(result, expected_result)

    def test_simple_binary(self):
        data = _bytes('hello')
        self._check(data, data)

    def test_unicode_binary(self):
        data = _bytes('привет')
        self._check(data, data)

    def test_simple_text(self):
        self._check(u'hello', _bytes('hello'))

    def test_unicode_text(self):
        self._check(u'привет', _bytes('привет'))

    def test_unicode_other_encoding(self):
        result = misc.binary_encode(u'mañana', 'latin-1')
        self.assertIsInstance(result, six.binary_type)
        self.assertEqual(result, u'mañana'.encode('latin-1'))

class BinaryDecodeTest(test.TestCase):

    def _check(self, data, expected_result):
        result = misc.binary_decode(data)
        self.assertIsInstance(result, six.text_type)
        self.assertEqual(result, expected_result)

    def test_simple_text(self):
        data = u'hello'
        self._check(data, data)

    def test_unicode_text(self):
        data = u'привет'
        self._check(data, data)

    def test_simple_binary(self):
        self._check(_bytes('hello'), u'hello')

    def test_unicode_binary(self):
        self._check(_bytes('привет'), u'привет')

    def test_unicode_other_encoding(self):
        data = u'mañana'.encode('latin-1')
        result = misc.binary_decode(data, 'latin-1')
        self.assertIsInstance(result, six.text_type)
        self.assertEqual(result, u'mañana')

class DecodeJsonTest(test.TestCase):

    def test_it_works(self):
        self.assertEqual(misc.decode_json(_bytes('{"foo": 1}')),
                         {"foo": 1})

    def test_it_works_with_unicode(self):
        data = _bytes('{"foo": "фуу"}')
        self.assertEqual(misc.decode_json(data), {"foo": u'фуу'})

    def test_handles_invalid_unicode(self):
        self.assertRaises(ValueError, misc.decode_json,
                          six.b('{"\xf1": 1}'))

    def test_handles_bad_json(self):
        self.assertRaises(ValueError, misc.decode_json,
                          _bytes('{"foo":'))

    def test_handles_wrong_types(self):
        self.assertRaises(ValueError, misc.decode_json,
                          _bytes('42'))


text:
import { ContentChildren, Component, ElementRef, EventEmitter, forwardRef, Input, Output, QueryList, NgZone,
  Renderer, OnDestroy, AfterViewInit, ViewEncapsulation
} from '@angular/core';
import { Ion } from '../ion';
import { isTrueProperty, assert } from '../util/util';
import { Config } from '../config/config';
import { Platform } from '../platform/platform';

// Breakpoints should have the same pixel values
// as in other places (FlexLayout, SASS variables)
const QUERY: { [key: string]: string }  = {
  xs: '(min-width: 0px)',
  sm: '(min-width: 600px)',
  md: '(min-width: 960px)',
  lg: '(min-width: 1280px)',
  xl: '(min-width: 1920px)',
  never: '',
};

/**
 * @hidden
 */
export abstract class RootNode {
  abstract getElementRef(): ElementRef;
  abstract initPane(): boolean;
  abstract paneChanged?(visible: boolean): void;
}

/**
 * @name SplitPaneComponent
 *
 * @description
 * SplitPane is a component that makes it possible to create multi-view layout.
 * Similar to iPad apps, SplitPane allows UI elements, like Menus, to be
 * displayed as the viewport increases.
 *
 * If the devices screen size is below a certain size, the SplitPane will
 * collapse and the menu will become hidden again. This is especially useful when
 * creating an app that will be served over a browser or deployed through the app
 * store to phones and tablets.
 *
 * @usage
 * To use SplitPane, simply add the component around your root component.
 * In this example, we'll be using a sidemenu layout, similar to what is
 * provided from the sidemenu starter template.
 *
 *  ```html
 *  <ion-split-pane>
 *    <!--  our side menu  -->
 *    <ion-menu [content]="content">
 *      <ion-header>
 *        <ion-toolbar>
 *          <ion-title>Menu</ion-title>
 *        </ion-toolbar>
 *      </ion-header>
 *    </ion-menu>
 *
 *    <!-- the main content -->
 *    <ion-nav [root]="root" main #content></ion-nav>
 *  </ion-split-pane>
 *  ```
 *
 *  Here, SplitPane will look for the element with the `main` attribute and make
 *  that the central component on larger screens. The `main` component can be any
 *  Ionic component (`ion-nav` or `ion-tabs`) except `ion-menu`.
 *
 *  ### Setting breakpoints
 *
 *  By default, SplitPane will expand when the screen is larger than 960px.
 *  If you want to customize this, use the `when` input. The `when` input can
 *  accept any valid media query, as it uses `matchMedia()` underneath.
 *
 *  ```
 *  <ion-split-pane when="(min-width: 475px)">
 *
 *    <!--  our side menu  -->
 *    <ion-menu [content]="content">
 *    ....
 *    </ion-menu>
 *
 *    <!-- the main content -->
 *    <ion-nav [root]="root" main #content></ion-nav>
 *  </ion-split-pane>
 *  ```
 *
 *  SplitPane also provides some predefined media queries that can be used.
 *
 *  ```html
 *  <!-- could be "xs", "sm", "md", "lg", or "xl" -->
 *  <ion-split-pane when="lg">
 *  ...
 *  </ion-split-pane>
 *  ```
 *
 *
 *  | Size | Value                 | Description                                                           |
 *  |------|-----------------------|-----------------------------------------------------------------------|
 *  | `xs` | `(min-width: 0px)`    | Show the split-pane when the min-width is 0px (meaning, always)       |
 *  | `sm` | `(min-width: 600px)`  | Show the split-pane when the min-width is 600px                       |
 *  | `md` | `(min-width: 960px)`  | Show the split-pane when the min-width is 960px (default break point) |
 *  | `lg` | `(min-width: 1280px)`  | Show the split-pane when the min-width is 1280px                       |
 *  | `xl` | `(min-width: 1920px)` | Show the split-pane when the min-width is 1920px                      |
 *
 *  You can also pass in boolean values that will trigger SplitPane when the value
 *  or expression evaluates to true.
 *
 *
 *  ```html
 *  <ion-split-pane [when]="isLarge">
 *  ...
 *  </ion-split-pane>
 *  ```
 *
 *  ```ts
 *  class MyClass {
 *    public isLarge = false;
 *    constructor(){}
 *  }
 *  ```
 *
 *  Or
 *
 *  ```html
 *  <ion-split-pane [when]="shouldShow()">
 *  ...
 *  </ion-split-pane>
 *  ```
 *
 *  ```ts
 *  class MyClass {
 *    constructor(){}
 *    shouldShow(){
 *      if(conditionA){
 *        return true
 *      } else {
 *        return false
 *      }
 *    }
 *  }
 *  ```
 *
 */
@Component({
  moduleId: module.id,
  selector: 'ion-split-pane',
  template: '<ng-content></ng-content>',
  styleUrls: ['./split-pane.component.css'],
  providers: [
    { provide: RootNode, useExisting: forwardRef(() => SplitPaneComponent) },
  ],
  encapsulation: ViewEncapsulation.None,
})
export class SplitPaneComponent extends Ion implements RootNode, OnDestroy, AfterViewInit {

  _init = false;
  _visible = false;
  _isEnabled = true;
  _rmListener: any;
  _mediaQuery: string | boolean = QUERY['md'];
  _children: RootNode[];

  /**
   * @hidden
   */
  sideContent: RootNode = null;
  /**
   * @hidden
   */
  mainContent: RootNode = null;

  /**
   * @hidden
   */
  @ContentChildren(RootNode, { descendants: false })
  set _setchildren(query: QueryList<RootNode>) {
    const children = this._children = query.filter((child => child !== this));
    children.forEach(child => {
      const isMain = child.initPane();
      this._setPaneCSSClass(child.getElementRef(), isMain);
    });
  }

  /**
   * @input {string | boolean} When the split-pane should be shown.
   * Can be a CSS media query expression, or a shortcut expression.
   * Can also be a boolean expression.
   */
  @Input()
  set when(query: string | boolean) {
    if (typeof query === 'boolean') {
      this._mediaQuery = query;
    } else {
      const defaultQuery = QUERY[query];
      this._mediaQuery = (defaultQuery)
        ? defaultQuery
        : query;
    }
    this._update();
  }
  get when(): string | boolean {
    return this._mediaQuery;
  }

  /**
   * @input {boolean} If `false`, the split-pane is disabled, ie. the side pane will
   * never be displayed. Default `true`.
   */
  @Input()
  set enabled(val: boolean) {
    this._isEnabled = isTrueProperty(val);
    this._update();
  }
  get enabled(): boolean {
    return this._isEnabled;
  }

  /**
   * @output {any} Expression to be called when the split-pane visibility has changed
   */
  @Output() ionChange: EventEmitter<SplitPaneComponent> = new EventEmitter<SplitPaneComponent>();

  constructor(
    private _zone: NgZone,
    private _plt: Platform,
    elementRef: ElementRef,
    config: Config,
    renderer: Renderer,
  ) {
    super(config, elementRef, renderer, 'split-pane');
  }

  /**
   * @hidden
   */
  _register(node: RootNode, isMain: boolean, callback: Function): boolean {
    if (this.getElementRef().nativeElement !== node.getElementRef().nativeElement.parentNode) {
      return false;
    }
    this._setPaneCSSClass(node.getElementRef(), isMain);
    if (callback) {
      this.ionChange.subscribe(callback);
    }
    if (isMain) {
      if (this.mainContent) {
        console.error('split pane: main content was already set');
      }
      this.mainContent = node;
    }
    return true;
  }

  /**
   * @hidden
   */
  ngAfterViewInit() {
    this._init = true;
    this._update();
  }

  /**
   * @hidden
   */
  _update() {
    if (!this._init) {
      return;
    }
    // Unlisten
    if (this._rmListener) {
      this._rmListener();
    }
    this._rmListener = null;

    // Check if the split-pane is disabled
    if (!this._isEnabled) {
      this._setVisible(false);
      return;
    }

    const query = this._mediaQuery;
    if (typeof query === 'boolean') {
      this._setVisible(query);
      return;
    }
    if (query && query.length > 0) {
      // Listen
      const callback = (q: MediaQueryList) => this._setVisible(q.matches);
      const mediaList = this._plt.win().matchMedia(query);
      mediaList.addListener(callback);
      this._setVisible(mediaList.matches);
      this._rmListener = function () {
        mediaList.removeListener(callback);
      };
    } else {
      this._setVisible(false);
    }
  }

  /**
   * @hidden
   */
  _updateChildren() {
    this.mainContent = null;
    this.sideContent = null;
    const visible = this._visible;
    this._children.forEach(child => child.paneChanged && child.paneChanged(visible));
  }

  /**
   * @hidden
   */
  _setVisible(visible: boolean) {
    if (this._visible === visible) {
      return;
    }
    this._visible = visible;
    this.setElementClass('split-pane-visible', visible);
    this._updateChildren();
    this._zone.run(() => {
      this.ionChange.emit(this);
    });
  }

  /**
   * @hidden
   */
  isVisible(): boolean {
    return this._visible;
  }

  /**
   * @hidden
   */
  setElementClass(className: string, add: boolean) {
    this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
  }

  /**
   * @hidden
   */
  _setPaneCSSClass(elementRef: ElementRef, isMain: boolean) {
    const ele = elementRef.nativeElement;
    this._renderer.setElementClass(ele, 'split-pane-main', isMain);
    this._renderer.setElementClass(ele, 'split-pane-side', !isMain);
  }

  /**
   * @hidden
   */
  ngOnDestroy() {
    assert(this._rmListener, 'at this point _rmListerner should be valid');

    if (this._rmListener) {
      this._rmListener();
    }
    this._rmListener = null;
  }

  /**
   * @hidden
   */
  initPane(): boolean {
    return true;
  }

}


text:
/*
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

using System;
using java = biz.ritter.javapi;

namespace biz.ritter.javapi.lang
{

    /**
     * Thrown when a program attempts to cast a an object to a type with which it is
     * not compatible.
     */
    [Serializable]
    public class ClassCastException : RuntimeException {
        private static readonly long serialVersionUID = -9223365651070458532L;

        /**
         * Constructs a new {@code ClassCastException} that includes the current
         * stack trace.
         */
        public ClassCastException() : base () {
        }

        /**
         * Constructs a new {@code ClassCastException} with the current stack trace
         * and the specified detail message.
         *
         * @param detailMessage
         *            the detail message for this exception.
         */
        public ClassCastException(String detailMessage) : base (detailMessage) {
        }

        /**
         * Constructs a new {@code ClassCastException} with the current stack trace
         * and a detail message based on the source and target class.
         *
         * @param instanceClass
         *            the class being cast from.
         * @param castClass
         *            the class being cast to.
         */
        protected internal ClassCastException(Type instanceClass, Type castClass) : base ("Class "+instanceClass.FullName+" cannot cast to "+castClass.FullName) {
        }
    }
}


text:
"""LIT wrappers for T5, supporting both HuggingFace and SavedModel formats."""
import re
from typing import List

import attr
from lit_nlp.api import model as lit_model
from lit_nlp.api import types as lit_types
from lit_nlp.examples.models import model_utils
from lit_nlp.lib import utils

import tensorflow as tf
# tensorflow_text is required for T5 SavedModel
import tensorflow_text  # pylint: disable=unused-import
import transformers

from rouge_score import rouge_scorer

JsonDict = lit_types.JsonDict

def masked_token_mean(vectors, masks):
  """Mean over tokens.

  Args:
    vectors: <tf.float32>[batch_size, num_tokens, emb_dim]
    masks: <tf.int32>[batch_size, num_tokens]

  Returns:
    <tf.float32>[batch_size, emb_dim]
  """
  masks = tf.cast(masks, tf.float32)
  weights = masks / tf.reduce_sum(masks, axis=1, keepdims=True)
  return tf.reduce_sum(vectors * tf.expand_dims(weights, axis=-1), axis=1)

@attr.s(auto_attribs=True, kw_only=True)
class T5ModelConfig(object):
  """Config options for a T5 generation model."""
  # Input options
  inference_batch_size: int = 4
  # Generation options
  beam_size: int = 4
  max_gen_length: int = 50
  num_to_generate: int = 1
  # Decoding options
  token_top_k: int = 10
  output_attention: bool = False

def validate_t5_model(model: lit_model.Model) -> lit_model.Model:
  """Validate that a given model looks like a T5 model.

  This checks the model spec at runtime; it is intended to be used before server
  start, such as in the __init__() method of a wrapper class.

  Args:
    model: a LIT model

  Returns:
    model: the same model

  Raises:
    AssertionError: if the model's spec does not match that expected for a T5
    model.
  """
  # Check inputs
  ispec = model.input_spec()
  assert "input_text" in ispec
  assert isinstance(ispec["input_text"], lit_types.TextSegment)
  if "target_text" in ispec:
    assert isinstance(ispec["target_text"], lit_types.TextSegment)

  # Check outputs
  ospec = model.output_spec()
  assert "output_text" in ospec
  assert isinstance(
      ospec["output_text"],
      (lit_types.GeneratedText, lit_types.GeneratedTextCandidates))
  assert ospec["output_text"].parent == "target_text"

  return model

class T5SavedModel(lit_model.Model):
  """T5 from a TensorFlow SavedModel, for black-box access.

  To create a SavedModel from a regular T5 checkpoint, see
  https://github.com/google-research/text-to-text-transfer-transformer#export
  """

  def __init__(self, saved_model_path: str, model=None, **config_kw):
    super().__init__()
    # By default, SavedModels from the original T5 codebase have batch_size=1
    # hardcoded. Use setdefault here so that the user can still override if
    # they've fixed this upstream.
    config_kw.setdefault("inference_batch_size", 1)
    self.config = T5ModelConfig(**config_kw)
    self.model = model or tf.saved_model.load(saved_model_path)

  ##
  # LIT API implementations
  def max_minibatch_size(self) -> int:
    # The lit.Model base class handles batching automatically in the
    # implementation of predict(), and uses this value as the batch size.
    return self.config.inference_batch_size

  def predict_minibatch(self, inputs):
    """Predict on a single minibatch of examples."""
    model_inputs = tf.constant([ex["input_text"] for ex in inputs])
    model_outputs = self.model.signatures["serving_default"](model_inputs)
    return [{
        "output_text": m.decode("utf-8")
    } for m in model_outputs["outputs"].numpy()]

  def input_spec(self):
    return {
        "input_text": lit_types.TextSegment(),
        "target_text": lit_types.TextSegment(required=False),
    }

  def output_spec(self):
    return {"output_text": lit_types.GeneratedText(parent="target_text")}

class T5HFModel(lit_model.Model):
  """T5 using HuggingFace Transformers and Keras.

  This version supports embeddings, attention, and force-decoding of the target
  text, as well as more options to control decoding (such as beam search).
  """

  @property
  def num_layers(self):
    return self.model.config.num_layers

  def __init__(self,
               model_name="t5-small",
               model=None,
               tokenizer=None,
               **config_kw):
    super().__init__()
    self.config = T5ModelConfig(**config_kw)
    assert self.config.num_to_generate <= self.config.beam_size
    self.tokenizer = tokenizer or transformers.T5Tokenizer.from_pretrained(
        model_name)
    self.model = model or model_utils.load_pretrained(
        transformers.TFT5ForConditionalGeneration,
        model_name,
        output_hidden_states=True,
        output_attentions=self.config.output_attention)

  def _encode_texts(self, texts: List[str]):
    return self.tokenizer.batch_encode_plus(
        texts,
        return_tensors="tf",
        padding="longest",
        truncation="longest_first")

  def _force_decode(self, encoded_inputs, encoded_targets):
    """Get predictions for a batch of tokenized examples.

    Each forward pass produces the following:
      logits: batch_size x dec_len x vocab_size
      decoder_past_key_value_states: tuple with cached outputs.
      dec_states: tuple[len:dec_layers]:
                  batch_size x dec_len x hid_size
      dec_attn: [optional] tuple[len:dec_layers+1]
                batch_size x num_heads x dec_len x dec_len
      enc_final_state: batch_size x enc_len x hid_size
      enc_states: tuple[len:enc_layers]:
                  batch_size x enc_len x hid_size
      enc_attn: [optional] tuple[len:enc_layers+1]
                batch_size x num_heads x enc_len x enc_len

    The two optional attention fields are only returned if
    config.output_attention is set.

    Args:
      encoded_inputs: Dict as returned from Tokenizer for inputs.
      encoded_targets: Dict as returned from Tokenizer for outputs

    Returns:
      batched_outputs: Dict[str, tf.Tensor]
    """
    results = self.model(
        input_ids=encoded_inputs["input_ids"],
        decoder_input_ids=encoded_targets["input_ids"],
        attention_mask=encoded_inputs["attention_mask"],
        decoder_attention_mask=encoded_targets["attention_mask"])

    model_probs = tf.nn.softmax(results.logits, axis=-1)
    top_k = tf.math.top_k(
        model_probs, k=self.config.token_top_k, sorted=True, name=None)
    batched_outputs = {
        "input_ids": encoded_inputs["input_ids"],
        "input_ntok": tf.reduce_sum(encoded_inputs["attention_mask"], axis=1),
        "target_ids": encoded_targets["input_ids"],
        "target_ntok": tf.reduce_sum(encoded_targets["attention_mask"], axis=1),
        "top_k_indices": top_k.indices,
        "top_k_probs": top_k.values,
    }
    # encoder_last_hidden_state is <float>[batch_size, num_tokens, emb_dim]
    # take the mean over real tokens to get <float>[batch_size, emb_dim]
    batched_outputs["encoder_final_embedding"] = masked_token_mean(
        results.encoder_last_hidden_state, encoded_inputs["attention_mask"])

    if self.config.output_attention:
      for i in range(len(results.decoder_attentions)):
        batched_outputs[
            f"decoder_layer_{i+1:d}_attention"] = results.decoder_attentions[i]
      for i in range(len(results.encoder_attentions)):
        batched_outputs[
            f"encoder_layer_{i+1:d}_attention"] = results.encoder_attentions[i]

    return batched_outputs

  def _postprocess(self, preds):
    """Post-process single-example preds. Operates on numpy arrays."""
    # Return tokenization for input text.
    input_ntok = preds.pop("input_ntok")
    input_ids = preds.pop("input_ids")[:input_ntok]
    preds["input_tokens"] = self.tokenizer.convert_ids_to_tokens(input_ids)
    # Return tokenization for target text.
    target_ntok = preds.pop("target_ntok")
    target_ids = preds.pop("target_ids")[:target_ntok]
    preds["target_tokens"] = self.tokenizer.convert_ids_to_tokens(target_ids)

    # Decode predicted top-k tokens.
    # token_topk_preds will be a List[List[(word, prob)]]
    # Initialize prediction for 0th token as N/A.
    token_topk_preds = [[("N/A", 1.)]]
    pred_ids = preds.pop("top_k_indices")[:target_ntok]  # <int>[num_tokens, k]
    pred_probs = preds.pop(
        "top_k_probs")[:target_ntok]  # <float32>[num_tokens, k]
    for token_pred_ids, token_pred_probs in zip(pred_ids, pred_probs):
      token_pred_words = self.tokenizer.convert_ids_to_tokens(token_pred_ids)
      token_topk_preds.append(list(zip(token_pred_words, token_pred_probs)))
    preds["pred_tokens"] = token_topk_preds

    # Decode generated ids
    candidates = [
        self.tokenizer.decode(ids, skip_special_tokens=True)
        for ids in preds.pop("generated_ids")
    ]
    if self.config.num_to_generate > 1:
      preds["output_text"] = [(s, None) for s in candidates]
    else:
      preds["output_text"] = candidates[0]

    # Process attention fields, if present.
    for key in preds:
      if not re.match(r"\w+_layer_(\d+)/attention", key):
        continue
      if key.startswith("encoder_"):
        ntok = input_ntok
      elif key.startswith("decoder_"):
        ntok = target_ntok
      else:
        raise ValueError(f"Invalid attention key: '{key}'")
      # Select only real tokens, since most of this matrix is padding.
      # <float32>[num_heads, max_seq_length, max_seq_length]
      # -> <float32>[num_heads, num_tokens, num_tokens]
      preds[key] = preds[key][:, :ntok, :ntok].transpose((0, 2, 1))
      # Make a copy of this array to avoid memory leaks, since NumPy otherwise
      # keeps a pointer around that prevents the source array from being GCed.
      preds[key] = preds[key].copy()

    return preds

  ##
  # LIT API implementations
  def max_minibatch_size(self) -> int:
    # The lit.Model base class handles batching automatically in the
    # implementation of predict(), and uses this value as the batch size.
    return self.config.inference_batch_size

  def predict_minibatch(self, inputs):
    """Run model on a single batch.

    Args:
      inputs: List[Dict] with fields as described by input_spec()

    Returns:
      outputs: List[Dict] with fields as described by output_spec()
    """
    # Text as sequence of sentencepiece ID"s.
    encoded_inputs = self._encode_texts([ex["input_text"] for ex in inputs])
    encoded_targets = self._encode_texts(
        [ex.get("target_text", "") for ex in inputs])

    ##
    # Force-decode on target text, and also get encoder embs and attention.
    batched_outputs = self._force_decode(encoded_inputs, encoded_targets)
    # Get the conditional generation from the model.
    # Workaround for output_hidden not being compatible with generate.
    # See https://github.com/huggingface/transformers/issues/8361
    self.model.config.output_hidden_states = False
    generated_ids = self.model.generate(
        encoded_inputs.input_ids,
        num_beams=self.config.beam_size,
        attention_mask=encoded_inputs.attention_mask,
        max_length=self.config.max_gen_length,
        num_return_sequences=self.config.num_to_generate)
    # [batch_size*num_return_sequences, num_steps]
    # -> [batch_size, num_return_sequences, num_steps]
    batched_outputs["generated_ids"] = tf.reshape(
        generated_ids,
        [-1, self.config.num_to_generate, generated_ids.shape[-1]])
    self.model.config.output_hidden_states = True

    # Convert to numpy for post-processing.
    detached_outputs = {k: v.numpy() for k, v in batched_outputs.items()}
    # Split up batched outputs, then post-process each example.
    unbatched_outputs = utils.unbatch_preds(detached_outputs)
    return list(map(self._postprocess, unbatched_outputs))

  def input_spec(self):
    return {
        "input_text": lit_types.TextSegment(),
        "target_text": lit_types.TextSegment(required=False),
    }

  def output_spec(self):
    spec = {
        "output_text": lit_types.GeneratedText(parent="target_text"),
        "input_tokens": lit_types.Tokens(parent="input_text"),
        "encoder_final_embedding": lit_types.Embeddings(),
        # If target text is given, the following will also be populated.
        "target_tokens": lit_types.Tokens(parent="target_text"),
        "pred_tokens": lit_types.TokenTopKPreds(align="target_tokens"),
    }
    if self.config.num_to_generate > 1:
      spec["output_text"] = lit_types.GeneratedTextCandidates(
          parent="target_text")

    if self.config.output_attention:
      # Add attention for each layer.
      for i in range(self.num_layers):
        spec[f"encoder_layer_{i+1:d}_attention"] = lit_types.AttentionHeads(
            align_in="input_tokens", align_out="input_tokens")
        spec[f"decoder_layer_{i+1:d}_attention"] = lit_types.AttentionHeads(
            align_in="target_tokens", align_out="target_tokens")
    return spec

##
# Task-specific wrapper classes.

class TranslationWrapper(lit_model.ModelWrapper):
  """Wrapper class for machine translation."""

  # Mapping from generic T5 fields to this task
  FIELD_RENAMES = {
      "input_text": "source",
      "target_text": "target",
      "output_text": "translation",
  }

  # From Appendix D of https://arxiv.org/pdf/1910.10683.pdf.
  # Add more of these if your model supports them.
  LANGCODE_TO_NAME = {
      "en": "English",
      "de": "German",
      "fr": "French",
      "ro": "Romanian",
  }

  INPUT_TEMPLATE = "translate {source_language} to {target_language}: {source}"

  def __init__(self, model: lit_model.Model):
    model = validate_t5_model(model)
    super().__init__(model)

  def preprocess(self, ex: JsonDict) -> JsonDict:
    input_kw = {
        "source_language": self.LANGCODE_TO_NAME[ex["source_language"]],
        "target_language": self.LANGCODE_TO_NAME[ex["target_language"]],
        "source": ex["source"]
    }
    ret = {"input_text": self.INPUT_TEMPLATE.format(**input_kw)}
    if "target" in ex:
      ret["target_text"] = ex["target"]
    return ret

  ##
  # LIT API implementation
  def description(self) -> str:
    return "T5 for machine translation\n" + self.wrapped.description()

  # TODO(b/170662608): remove these after batching API is cleaned up.
  def max_minibatch_size(self) -> int:
    raise NotImplementedError("Use predict() instead.")

  def predict_minibatch(self, inputs):
    raise NotImplementedError("Use predict() instead.")

  def predict(self, inputs):
    """Predict on a single minibatch of examples."""
    model_inputs = (self.preprocess(ex) for ex in inputs)
    outputs = self.wrapped.predict(model_inputs)
    return (utils.remap_dict(mo, self.FIELD_RENAMES) for mo in outputs)

  def predict_with_metadata(self, indexed_inputs):
    """As predict(), but inputs are IndexedInput."""
    return self.predict((ex["data"] for ex in indexed_inputs))

  def input_spec(self):
    spec = lit_types.remap_spec(self.wrapped.input_spec(), self.FIELD_RENAMES)
    spec["source_language"] = lit_types.CategoryLabel()
    spec["target_language"] = lit_types.CategoryLabel()
    return spec

  def output_spec(self):
    return lit_types.remap_spec(self.wrapped.output_spec(), self.FIELD_RENAMES)

class SummarizationWrapper(lit_model.ModelWrapper):
  """Wrapper class to perform a summarization task."""

  # Mapping from generic T5 fields to this task
  FIELD_RENAMES = {
      "input_text": "document",
      "target_text": "reference",
  }

  def __init__(self, model: lit_model.Model):
    model = validate_t5_model(model)
    super().__init__(model)

    # TODO(gehrmann): temp solution for ROUGE.
    self._scorer = rouge_scorer.RougeScorer(["rougeL"], use_stemmer=True)
    # If output is List[(str, score)] instead of just str
    self._multi_output = isinstance(self.output_spec()["output_text"],
                                    lit_types.GeneratedTextCandidates)
    self._get_pred_string = (
        lit_types.GeneratedTextCandidates.top_text if self._multi_output else
        (lambda x: x))

  def preprocess(self, ex: JsonDict) -> JsonDict:
    ret = {"input_text": "summarize: " + ex["document"]}
    if "reference" in ex:
      ret["target_text"] = ex["reference"]
    return ret

  ##
  # LIT API implementation
  def description(self) -> str:
    return "T5 for summarization\n" + self.wrapped.description()

  # TODO(b/170662608): remove these after batching API is cleaned up.
  def max_minibatch_size(self) -> int:
    raise NotImplementedError("Use predict() instead.")

  def predict_minibatch(self, inputs):
    raise NotImplementedError("Use predict() instead.")

  def predict(self, inputs):
    """Predict on a single minibatch of examples."""
    inputs = list(inputs)  # needs to be referenced below, so keep full list
    model_inputs = (self.preprocess(ex) for ex in inputs)
    outputs = self.wrapped.predict(model_inputs)
    outputs = (utils.remap_dict(mo, self.FIELD_RENAMES) for mo in outputs)

    # TODO(gehrmann): temp solution to get ROUGE scores in data table.
    for ex, mo in zip(inputs, outputs):
      score = self._scorer.score(
          target=ex["reference"],
          prediction=self._get_pred_string(mo["output_text"]))
      mo["rougeL"] = float(score["rougeL"].fmeasure)
      yield mo

  def predict_with_metadata(self, indexed_inputs):
    """As predict(), but inputs are IndexedInput."""
    return self.predict((ex["data"] for ex in indexed_inputs))

  def input_spec(self):
    return lit_types.remap_spec(self.wrapped.input_spec(), self.FIELD_RENAMES)

  def output_spec(self):
    spec = lit_types.remap_spec(self.wrapped.output_spec(), self.FIELD_RENAMES)
    spec["rougeL"] = lit_types.Scalar()
    return spec


text:
require 'progressbar'
raise LoadError, "require mechanize before mechanize/progressbar" unless defined?(Mechanize)

require 'mechanize/progressbar/api'
require 'mechanize/progressbar/mechanize_progressbar'
if Mechanize::VERSION == '1.0.0'
  require 'mechanize/progressbar/mechanize_1_0'
else
  require 'mechanize/progressbar/mechanize_2_0'
end


text:
<?xml version="1.0"?>

<document url="./ssl.xml">

<properties>

<author>Steve Ditlinger</author>

<title>Secure Socket Layer and Web Applications - Apache Struts</title>

</properties>

Many web applications, especially those deployed for e-commerce, necessitate the
transmission of sensitive data between the web server and the client browser.  This data
may include passwords, credit card numbers, bank account numbers or any other
information that users would not want to divulge to the general public. To protect
sensitive data during transmission, application developers typically use the Secure
Sockets Layer (SSL) and its companion protocol, HTTP over Secure Sockets Layer
(HTTPS). HTTPS employs SSL to protect data by encrypting it at the source, be it the
server or the client, and decrypting it at the destination. This prevents anyone monitoring
Internet data transmissions from easily capturing this data. The client and server
exchange public keys to enable encryption and decryption to occur.

The encryption/decryption process comes at a performance price, however. The
throughput of data for a web server transmitting via HTTPS is often as little as one-tenth
that of data transmission via HTTP. For this reason, it is undesirable to deploy an entire
web application under SSL. For fastest performance, it is best to deploy a web
application under HTTP and employ HTTPS only for those pages and processes that
transmit sensitive data.

Switching back and forth between the two protocols can require hard-coding the protocol
and full URL in every link to each resource in the web application. This creates an
ongoing maintenance headache for developers each time a server name changes or secure
protocol requirements change for resources in the web app.

Another significant hazard is that there is nothing to prevent a user from specifying the
wrong protocol by manually entering a URL into the browser. The penalty for manually
specifying HTTPS for a page or servlet that does not require HTTPS is reduced
performance. Far worse is the penalty for manually specifying HTTP for non-secure
access of a page that does require HTTPS: public exposure of sensitive data.

To help overcome the problem of non-secure access of sensitive data, the Java Servlet
Specification (versions 2.2 and 2.3) defines the transport-guarantee element of the
web.xml deployment descriptor file. The transport-guarantee element must specify one
of three types of protection for communication between client and server: NONE,
INTEGRAL, or CONFIDENTIAL. For most containers a specification of INTEGRAL
or CONFIDENTIAL is treated as a requirement for SSL usage. Web application
containers will prevent users from accessing web resources over HTTP if they have been
so specified.

The implementation for blocking HTTP access to web resources specified as INTEGRAL
or CONFIDENTIAL varies from container to container. If a user attempts to access such
a resource over HTTP, some containers will present that user with an error message
instructing them to use the HTTPS protocol for accessing the requested resource. Other
containers will actually redirect the request using the HTTPS protocol, but then continue
using the HTTPS protocol for all subsequent requests, even those for resources with a
transport-guarantee specification of NONE.

An extension to Struts 1.1, named sslext, helps solve many of these issues for Struts
developers. It extends the ActionConfig class, RequestProcessor, and Plugin classes to
define a framework where developers may specify the transmission protocol behavior for
Struts applications. Within the Struts configuration file, developers specify which action
requests require HTTPS transmission and which should use HTTP. Developers can also
specify whether to redirect "improperly-protocoled" requests to the correct protocol.

In addition to these extensions, the <html:link> and the <html:form> tags have been
extended. In these extensions, the Struts actions specified in either of these tags are
analyzed to determine the protocol that should be used in requesting that action. The
HTML generated by these tags will specify the proper protocol. An additional custom
tag is defined for allowing users to specify the transmission protocol for an individual
JSP. This is most often used for form-based authentication pages.

The sslext library may be obtained from
http://sslext.sourceforge.net

One additional complication faced by developers of web applications is that some
browsers (e.g. pre-6.0 versions of Netscape Navigator) will treat requests to different
protocols and ports on the same server as requests to different domains. This causes
these browsers to initiate a new session each time a different protocol or port is specified
in a request. This problem can only be solved at the container level. Some containers
have a "session domain" or "cookie domain" configuration parameter to allow the session
to be shared across different servers in the same domain. As an example, the Weblogic
Server has a "CookieDomain" property configured in its weblogic.xml deployment
descriptor. Thankfully, the effects of this problem are diminishing as people upgrade
their browsers to the current versions.

The procedure for configuring SSL for a container will be specific to that container.  The
procedure for enabling SSL for Tomcat can be found
here.

</document>