{
        if (this == objectToCompare) {
            return true;
        }
        if (!(objectToCompare instanceof SearchClassifications)) {
            return false;
        }
        SearchClassifications that = (SearchClassifications) objectToCompare;
        return getMatchCriteria() == that.getMatchCriteria() && Objects.equals(getConditions(), that.getConditions());
    }

/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.frameworks.governanceaction.search;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
 * The SearchClassifications class provides support for searching against one or more classifications using a variety of
 * comparison mechanisms.
 */
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchClassifications implements Serializable {

    private static final long serialVersionUID = 1L;

    private List<ClassificationCondition> conditions;

    private MatchCriteria matchCriteria;

    public SearchClassifications() {
        super();
        // Setup defaults
        matchCriteria = MatchCriteria.ALL;
    }

    /**
     * Copy/clone constructor.
     *
     * @param templateProperties template object to copy.
     */
    public SearchClassifications(SearchClassifications templateProperties) {
        /*
         * An empty properties object is created in the private variable declaration so nothing to do.
         */
        if (templateProperties != null) {
            this.matchCriteria = templateProperties.getMatchCriteria();
            this.conditions = new ArrayList<>();
            this.conditions.addAll(templateProperties.getConditions());
        }
    }

    /**
     * Retrieve the classification conditions against which to match.
     *
     * @return {@code List<ClassificationCondition>}
     */
    public List<ClassificationCondition> getConditions() {
        return conditions;
    }

    /**
     * Set the classification conditions against which to match.
     *
     * @param conditions against which to match
     */
    public void setConditions(List<ClassificationCondition> conditions) {
        this.conditions = conditions;
    }

    /**
     * Retrieve the criteria against which to match the classifications.
     *
     * @return MatchCriteria
     */
    public MatchCriteria getMatchCriteria() {
        return matchCriteria;
    }

    /**
     * Set the criteria against which to match the classifications.
     *
     * @param matchCriteria against which to match the classifications
     */
    public void setMatchCriteria(MatchCriteria matchCriteria) {
        this.matchCriteria = matchCriteria;
    }

    /**
     * Standard toString method.
     *
     * @return JSON style description of variables.
     */
    @Override
    public String toString() {
        return "SearchClassifications{" + "matchCriteria=" + matchCriteria + ", conditions=" + conditions + '}';
    }

    /**
     * Validate that an object is equal depending on their stored values.
     *
     * @param objectToCompare object
     * @return boolean result
     */
    @Override
    public boolean equals(Object objectToCompare)

    /**
     * Return a hash code based on the property values
     *
     * @return int hash code
     */
    @Override
    public int hashCode() {
        return Objects.hash(getMatchCriteria(), getConditions());
    }
}


/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.frameworks.governanceaction.search;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
 * The SearchClassifications class provides support for searching against one or more classifications using a variety of
 * comparison mechanisms.
 */
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchClassifications implements Serializable {

    private static final long serialVersionUID = 1L;

    private List<ClassificationCondition> conditions;

    private MatchCriteria matchCriteria;

    public SearchClassifications() {
        super();
        // Setup defaults
        matchCriteria = MatchCriteria.ALL;
    }

    /**
     * Copy/clone constructor.
     *
     * @param templateProperties template object to copy.
     */
    public SearchClassifications(SearchClassifications templateProperties) {
        /*
         * An empty properties object is created in the private variable declaration so nothing to do.
         */
        if (templateProperties != null) {
            this.matchCriteria = templateProperties.getMatchCriteria();
            this.conditions = new ArrayList<>();
            this.conditions.addAll(templateProperties.getConditions());
        }
    }

    /**
     * Retrieve the classification conditions against which to match.
     *
     * @return {@code List<ClassificationCondition>}
     */
    public List<ClassificationCondition> getConditions() {
        return conditions;
    }

    /**
     * Set the classification conditions against which to match.
     *
     * @param conditions against which to match
     */
    public void setConditions(List<ClassificationCondition> conditions) {
        this.conditions = conditions;
    }

    /**
     * Retrieve the criteria against which to match the classifications.
     *
     * @return MatchCriteria
     */
    public MatchCriteria getMatchCriteria() {
        return matchCriteria;
    }

    /**
     * Set the criteria against which to match the classifications.
     *
     * @param matchCriteria against which to match the classifications
     */
    public void setMatchCriteria(MatchCriteria matchCriteria) {
        this.matchCriteria = matchCriteria;
    }

    /**
     * Standard toString method.
     *
     * @return JSON style description of variables.
     */
    @Override
    public String toString() {
        return "SearchClassifications{" + "matchCriteria=" + matchCriteria + ", conditions=" + conditions + '}';
    }

    /**
     * Validate that an object is equal depending on their stored values.
     *
     * @param objectToCompare object
     * @return boolean result
     */
    @Override
    public boolean equals(Object objectToCompare) {
        if (this == objectToCompare) {
            return true;
        }
        if (!(objectToCompare instanceof SearchClassifications)) {
            return false;
        }
        SearchClassifications that = (SearchClassifications) objectToCompare;
        return getMatchCriteria() == that.getMatchCriteria() && Objects.equals(getConditions(), that.getConditions());
    }

    /**
     * Return a hash code based on the property values
     *
     * @return int hash code
     */
    @Override
    public int hashCode() {
        return Objects.hash(getMatchCriteria()


public void setConditions(List<ClassificationCondition> conditions) {
        this.conditions = conditions;
    }

/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.frameworks.governanceaction.search;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
 * The SearchClassifications class provides support for searching against one or more classifications using a variety of
 * comparison mechanisms.
 */
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchClassifications implements Serializable {

    private static final long serialVersionUID = 1L;

    private List<ClassificationCondition> conditions;

    private MatchCriteria matchCriteria;

    public SearchClassifications() {
        super();
        // Setup defaults
        matchCriteria = MatchCriteria.ALL;
    }

    /**
     * Copy/clone constructor.
     *
     * @param templateProperties template object to copy.
     */
    public SearchClassifications(SearchClassifications templateProperties) {
        /*
         * An empty properties object is created in the private variable declaration so nothing to do.
         */
        if (templateProperties != null) {
            this.matchCriteria = templateProperties.getMatchCriteria();
            this.conditions = new ArrayList<>();
            this.conditions.addAll(templateProperties.getConditions());
        }
    }

    /**
     * Retrieve the classification conditions against which to match.
     *
     * @return {@code List<ClassificationCondition>}
     */
    public List<ClassificationCondition> getConditions() {
        return conditions;
    }

    /**
     * Set the classification conditions against which to match.
     *
     * @param conditions against which to match
     */

    /**
     * Retrieve the criteria against which to match the classifications.
     *
     * @return MatchCriteria
     */
    public MatchCriteria getMatchCriteria() {
        return matchCriteria;
    }

    /**
     * Set the criteria against which to match the classifications.
     *
     * @param matchCriteria against which to match the classifications
     */
    public void setMatchCriteria(MatchCriteria matchCriteria) {
        this.matchCriteria = matchCriteria;
    }

    /**
     * Standard toString method.
     *
     * @return JSON style description of variables.
     */
    @Override
    public String toString() {
        return "SearchClassifications{" + "matchCriteria=" + matchCriteria + ", conditions=" + conditions + '}';
    }

    /**
     * Validate that an object is equal depending on their stored values.
     *
     * @param objectToCompare object
     * @return boolean result
     */
    @Override
    public boolean equals(Object objectToCompare) {
        if (this == objectToCompare) {
            return true;
        }
        if (!(objectToCompare instanceof SearchClassifications)) {
            return false;
        }
        SearchClassifications that = (SearchClassifications) objectToCompare;
        return getMatchCriteria() == that.getMatchCriteria() && Objects.equals(getConditions(), that.getConditions());
    }

    /**
     * Return a hash code based on the property values
     *
     * @return int hash code
     */
    @Override
    public int hashCode() {
        return Objects.hash(getMatchCriteria(), getConditions());
    }
}


@Deprecated
    public static long getNrOpenFiles()

/*
 *
 *
 * Additionally licensed with:
 *
 */
package org.spf4j.perf.io;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import org.spf4j.base.AbstractRunnable;
import org.spf4j.concurrent.DefaultScheduler;
import org.spf4j.perf.impl.RecorderFactory;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.spf4j.os.OperatingSystem;
import org.spf4j.base.Runtime;
import org.spf4j.base.SysExits;
import org.spf4j.jmx.JmxExport;
import org.spf4j.jmx.Registry;
import org.spf4j.perf.MeasurementRecorder;
import org.spf4j.tsdb2.avro.MeasurementType;
import org.spf4j.unix.Lsof;

/**
 * This class allows you to poll and recordAt to a file the heap commitxted and heap used for your java process. start
 * data recording by calling the startMemoryUsageSampling method, stop the data recording by calling the method:
 * startMemoryUsageSampling.
 *
 * @author zoly
 */
public final class OpenFilesSampler {

    private static ScheduledFuture<?> samplingFuture;

    private static AccumulatorRunnable accumulator;

    private static volatile CharSequence lastWarnLsof = "";

    private static volatile Instant lastWarnLsofTime;

    static {
        Runtime.queueHook(2, new AbstractRunnable(true) {

            @Override
            public void doRun() {
                stop();
            }
        });
        Registry.export(OpenFilesSampler.class);
    }

    private OpenFilesSampler() {
    }

    public static void start(final long sampleTimeMillis) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescriptorCount();
        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, true);
    }

    @JmxExport
    public static void start(@JmxExport("sampleTimeMillis") final long sampleTimeMillis, @JmxExport("shutdownOnError") final boolean shutdownOnError) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescriptorCount();
        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, shutdownOnError);
    }

    @JmxExport
    public static String getWarnLsofDetail() {
        return lastWarnLsof.toString();
    }

    @JmxExport
    @Nullable
    public static synchronized String getWarnLsofTime() {
        Instant lwt = lastWarnLsofTime;
        if (lwt == null) {
            return null;
        } else {
            return lwt.toString();
        }
    }

    public static synchronized void start(final long sampleTimeMillis, final long warnThreshold, final long errorThreshold, final boolean shutdownOnError) {
        if (samplingFuture == null) {
            accumulator = new AccumulatorRunnable(errorThreshold, shutdownOnError, warnThreshold, (int) sampleTimeMillis);
            samplingFuture = DefaultScheduler.INSTANCE.scheduleWithFixedDelay(accumulator, sampleTimeMillis, sampleTimeMillis, TimeUnit.MILLISECONDS);
        } else {
            throw new IllegalStateException("Open file usage sampling already started " + samplingFuture);
        }
    }

    @JmxExport
    public static synchronized void stop() {
        if (samplingFuture != null) {
            samplingFuture.cancel(false);
            samplingFuture = null;
            accumulator = null;
        }
    }

    @JmxExport
    public static synchronized boolean isStarted() {
        return samplingFuture != null;
    }

    @JmxExport
    public static String getLsof() {
        CharSequence lsofOutput = Lsof.getLsofOutput();
        return lsofOutput == null ? "unable to obtain lsof" : lsofOutput.toString();
    }

    @Deprecated
    public static long getMaxNrOpenFiles() {
        return OperatingSystem.getMaxFileDescriptorCount();
    }

{
        return OperatingSystem.getOpenFileDescriptorCount();
    }

    @JmxExport
    public static long getWarnThreshold() {
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getWarnThreshold();
    }

    @JmxExport
    public static long getErrorThreshold() {
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getErrorThreshold();
    }

    private static class AccumulatorRunnable extends AbstractRunnable {

        private final long errorThreshold;

        private final boolean shutdownOnError;

        private final long warnThreshold;

        private final MeasurementRecorder nrOpenFiles;

        AccumulatorRunnable(final long errorThreshold, final boolean shutdownOnError, final long warnThreshold, final int sampleMillis) {
            this.errorThreshold = errorThreshold;
            this.shutdownOnError = shutdownOnError;
            this.warnThreshold = warnThreshold;
            this.nrOpenFiles = RecorderFactory.createDirectRecorder("process.nr_open_files", "count", sampleMillis, MeasurementType.GAUGE);
        }

        @Override
        @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
        public void doRun() {
            long time = System.currentTimeMillis();
            long nrOf = OperatingSystem.getOpenFileDescriptorCount();
            if (nrOf > errorThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.SEVERE, "Nr open files is {0} and exceeds error threshold {1}, detail:\n{2}", new Object[] { nrOf, errorThreshold, lastWarnLsof });
                if (shutdownOnError) {
                    Runtime.goDownWithError(null, SysExits.EX_IOERR);
                }
            } else if (nrOf > warnThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.WARNING, "Nr open files is {0} and exceeds warn threshold {1}, detail:\n{2} ", new Object[] { nrOf, warnThreshold, lastWarnLsof });
                if (!Runtime.gc(60000)) {
                    log.warning("Unable to trigger GC although running low on file resources");
                } else {
                    log.log(Level.WARNING, "gc executed nr open files reduced by {0} files", nrOf - OperatingSystem.getOpenFileDescriptorCount());
                }
            }
            this.nrOpenFiles.recordAt(time, nrOf);
        }

        public long getErrorThreshold() {
            return errorThreshold;
        }

        public boolean isShutdownOnError() {
            return shutdownOnError;
        }

        public long getWarnThreshold() {
            return warnThreshold;
        }
    }
}


{
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getWarnThreshold();
    }

/*
 *
 *
 * Additionally licensed with:
 *
 */
package org.spf4j.perf.io;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import org.spf4j.base.AbstractRunnable;
import org.spf4j.concurrent.DefaultScheduler;
import org.spf4j.perf.impl.RecorderFactory;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.spf4j.os.OperatingSystem;
import org.spf4j.base.Runtime;
import org.spf4j.base.SysExits;
import org.spf4j.jmx.JmxExport;
import org.spf4j.jmx.Registry;
import org.spf4j.perf.MeasurementRecorder;
import org.spf4j.tsdb2.avro.MeasurementType;
import org.spf4j.unix.Lsof;

/**
 * This class allows you to poll and recordAt to a file the heap commitxted and heap used for your java process. start
 * data recording by calling the startMemoryUsageSampling method, stop the data recording by calling the method:
 * startMemoryUsageSampling.
 *
 * @author zoly
 */
public final class OpenFilesSampler {

    private static ScheduledFuture<?> samplingFuture;

    private static AccumulatorRunnable accumulator;

    private static volatile CharSequence lastWarnLsof = "";

    private static volatile Instant lastWarnLsofTime;

    static {
        Runtime.queueHook(2, new AbstractRunnable(true) {

            @Override
            public void doRun() {
                stop();
            }
        });
        Registry.export(OpenFilesSampler.class);
    }

    private OpenFilesSampler() {
    }

    public static void start(final long sampleTimeMillis) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescriptorCount();
        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, true);
    }

    @JmxExport
    public static void start(@JmxExport("sampleTimeMillis") final long sampleTimeMillis, @JmxExport("shutdownOnError") final boolean shutdownOnError) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescriptorCount();
        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, shutdownOnError);
    }

    @JmxExport
    public static String getWarnLsofDetail() {
        return lastWarnLsof.toString();
    }

    @JmxExport
    @Nullable
    public static synchronized String getWarnLsofTime() {
        Instant lwt = lastWarnLsofTime;
        if (lwt == null) {
            return null;
        } else {
            return lwt.toString();
        }
    }

    public static synchronized void start(final long sampleTimeMillis, final long warnThreshold, final long errorThreshold, final boolean shutdownOnError) {
        if (samplingFuture == null) {
            accumulator = new AccumulatorRunnable(errorThreshold, shutdownOnError, warnThreshold, (int) sampleTimeMillis);
            samplingFuture = DefaultScheduler.INSTANCE.scheduleWithFixedDelay(accumulator, sampleTimeMillis, sampleTimeMillis, TimeUnit.MILLISECONDS);
        } else {
            throw new IllegalStateException("Open file usage sampling already started " + samplingFuture);
        }
    }

    @JmxExport
    public static synchronized void stop() {
        if (samplingFuture != null) {
            samplingFuture.cancel(false);
            samplingFuture = null;
            accumulator = null;
        }
    }

    @JmxExport
    public static synchronized boolean isStarted() {
        return samplingFuture != null;
    }

    @JmxExport
    public static String getLsof() {
        CharSequence lsofOutput = Lsof.getLsofOutput();
        return lsofOutput == null ? "unable to obtain lsof" : lsofOutput.toString();
    }

    @Deprecated
    public static long getMaxNrOpenFiles() {
        return OperatingSystem.getMaxFileDescriptorCount();
    }

    @Deprecated
    public static long getNrOpenFiles() {
        return OperatingSystem.getOpenFileDescriptorCount();
    }

    @JmxExport
    public static long getWarnThreshold()

    @JmxExport
    public static long getErrorThreshold() {
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getErrorThreshold();
    }

    private static class AccumulatorRunnable extends AbstractRunnable {

        private final long errorThreshold;

        private final boolean shutdownOnError;

        private final long warnThreshold;

        private final MeasurementRecorder nrOpenFiles;

        AccumulatorRunnable(final long errorThreshold, final boolean shutdownOnError, final long warnThreshold, final int sampleMillis) {
            this.errorThreshold = errorThreshold;
            this.shutdownOnError = shutdownOnError;
            this.warnThreshold = warnThreshold;
            this.nrOpenFiles = RecorderFactory.createDirectRecorder("process.nr_open_files", "count", sampleMillis, MeasurementType.GAUGE);
        }

        @Override
        @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
        public void doRun() {
            long time = System.currentTimeMillis();
            long nrOf = OperatingSystem.getOpenFileDescriptorCount();
            if (nrOf > errorThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.SEVERE, "Nr open files is {0} and exceeds error threshold {1}, detail:\n{2}", new Object[] { nrOf, errorThreshold, lastWarnLsof });
                if (shutdownOnError) {
                    Runtime.goDownWithError(null, SysExits.EX_IOERR);
                }
            } else if (nrOf > warnThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.WARNING, "Nr open files is {0} and exceeds warn threshold {1}, detail:\n{2} ", new Object[] { nrOf, warnThreshold, lastWarnLsof });
                if (!Runtime.gc(60000)) {
                    log.warning("Unable to trigger GC although running low on file resources");
                } else {
                    log.log(Level.WARNING, "gc executed nr open files reduced by {0} files", nrOf - OperatingSystem.getOpenFileDescriptorCount());
                }
            }
            this.nrOpenFiles.recordAt(time, nrOf);
        }

        public long getErrorThreshold() {
            return errorThreshold;
        }

        public boolean isShutdownOnError() {
            return shutdownOnError;
        }

        public long getWarnThreshold() {
            return warnThreshold;
        }
    }
}


/*
 *
 *
 * Additionally licensed with:
 *
 */
package org.spf4j.perf.io;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import org.spf4j.base.AbstractRunnable;
import org.spf4j.concurrent.DefaultScheduler;
import org.spf4j.perf.impl.RecorderFactory;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.spf4j.os.OperatingSystem;
import org.spf4j.base.Runtime;
import org.spf4j.base.SysExits;
import org.spf4j.jmx.JmxExport;
import org.spf4j.jmx.Registry;
import org.spf4j.perf.MeasurementRecorder;
import org.spf4j.tsdb2.avro.MeasurementType;
import org.spf4j.unix.Lsof;

/**
 * This class allows you to poll and recordAt to a file the heap commitxted and heap used for your java process. start
 * data recording by calling the startMemoryUsageSampling method, stop the data recording by calling the method:
 * startMemoryUsageSampling.
 *
 * @author zoly
 */
public final class OpenFilesSampler {

    private static ScheduledFuture<?> samplingFuture;

    private static AccumulatorRunnable accumulator;

    private static volatile CharSequence lastWarnLsof = "";

    private static volatile Instant lastWarnLsofTime;

    static {
        Runtime.queueHook(2, new AbstractRunnable(true) {

            @Override
            public void doRun() {
                stop();
            }
        });
        Registry.export(OpenFilesSampler.class);
    }

    private OpenFilesSampler() {
    }

    public static void start(final long sampleTimeMillis) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescrip

        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, true);
    }

    @JmxExport
    public static void start(@JmxExport("sampleTimeMillis") final long sampleTimeMillis, @JmxExport("shutdownOnError") final boolean shutdownOnError) {
        long maxFileDescriptorCount = OperatingSystem.getMaxFileDescriptorCount();
        start(sampleTimeMillis, maxFileDescriptorCount - maxFileDescriptorCount / 10, maxFileDescriptorCount, shutdownOnError);
    }

    @JmxExport
    public static String getWarnLsofDetail() {
        return lastWarnLsof.toString();
    }

    @JmxExport
    @Nullable
    public static synchronized String getWarnLsofTime() {
        Instant lwt = lastWarnLsofTime;
        if (lwt == null) {
            return null;
        } else {
            return lwt.toString();
        }
    }

    public static synchronized void start(final long sampleTimeMillis, final long warnThreshold, final long errorThreshold, final boolean shutdownOnError) {
        if (samplingFuture == null) {
            accumulator = new AccumulatorRunnable(errorThreshold, shutdownOnError, warnThreshold, (int) sampleTimeMillis);
            samplingFuture = DefaultScheduler.INSTANCE.scheduleWithFixedDelay(accumulator, sampleTimeMillis, sampleTimeMillis, TimeUnit.MILLISECONDS);
        } else {
            throw new IllegalStateException("Open file usage sampling already started " + samplingFuture);
        }
    }

    @JmxExport
    public static synchronized void stop() {
        if (samplingFuture != null) {
            samplingFuture.cancel(false);
            samplingFuture = null;
            accumulator = null;
        }
    }

    @JmxExport
    public static synchronized boolean isStarted() {
        return samplingFuture != null;
    }

    @JmxExport
    public static String getLsof() {
        CharSequence lsofOutput = Lsof.getLsofOutput();
        return lsofOutput == null ? "unable to obtain lsof" : lsofOutput.toString();
    }

    @Deprecated
    public static long getMaxNrOpenFiles() {
        return OperatingSystem.getMaxFileDescriptorCount();
    }

    @Deprecated
    public static long getNrOpenFiles() {
        return OperatingSystem.getOpenFileDescriptorCount();
    }

    @JmxExport
    public static long getWarnThreshold() {
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getWarnThreshold();
    }

    @JmxExport
    public static long getErrorThreshold() {
        if (accumulator == null) {
            return -1;
        }
        return accumulator.getErrorThreshold();
    }

    private static class AccumulatorRunnable extends AbstractRunnable {

        private final long errorThreshold;

        private final boolean shutdownOnError;

        private final long warnThreshold;

        private final MeasurementRecorder nrOpenFiles;

        AccumulatorRunnable(final long errorThreshold, final boolean shutdownOnError, final long warnThreshold, final int sampleMillis) {
            this.errorThreshold = errorThreshold;
            this.shutdownOnError = shutdownOnError;
            this.warnThreshold = warnThreshold;
            this.nrOpenFiles = RecorderFactory.createDirectRecorder("process.nr_open_files", "count", sampleMillis, MeasurementType.GAUGE);
        }

        @Override
        @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
        public void doRun() {
            long time = System.currentTimeMillis();
            long nrOf = OperatingSystem.getOpenFileDescriptorCount();
            if (nrOf > errorThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.SEVERE, "Nr open files is {0} and exceeds error threshold {1}, detail:\n{2}", new Object[] { nrOf, errorThreshold, lastWarnLsof });
                if (shutdownOnError) {
                    Runtime.goDownWithError(null, SysExits.EX_IOERR);
                }
            } else if (nrOf > warnThreshold) {
                lastWarnLsof = Lsof.getLsofOutput();
                lastWarnLsofTime = Instant.now();
                Logger log = Logger.getLogger(OpenFilesSampler.class.getName());
                log.log(Level.WARNING, "Nr open files is {0} and exceeds warn threshold {1}, detail:\n{2} ", new Object[] { nrOf, warnThreshold, lastWarnLsof });
                if (!Runtime.gc(60000)) {
                    log.warning("Unable to trigger GC although running low on file resources");
                } else {
                    log.log(Level.WARNING, "gc executed nr open files reduced by {0} files", nrOf - OperatingSystem.getOpenFileDescriptorCount());
                }
            }
            this.nrOpenFiles.recordAt(time, nrOf);
        }

        public long getErrorThreshold() {
            return errorThreshold;
        }

        public boolean isShutdownOnError() {
            return shutdownOnError;
        }

        public long getWarnThreshold() {
            return warnThreshold;
        }
    }
}


public void setJsoninfo(String jsoninfo)

package com.byl.qrobot.bean;

import org.json.JSONObject;
import java.util.List;

/**
 * 机器人回答类
 * Created by baiyuliang on 2016-5-12.
 */
public class Answer {

    // 返回码
    private String code;

    // 内容
    private String text;

    // 链接
    private String url;

    // 新闻列表
    private List<News> listNews;

    // 菜谱列表
    private List<Cook> listCook;

    private String jsoninfo;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<News> getListNews() {
        return listNews;
    }

    public void setListNews(List<News> listNews) {
        this.listNews = listNews;
    }

    public List<Cook> getListCook() {
        return listCook;
    }

    public void setListCook(List<Cook> listCook) {
        this.listCook = listCook;
    }

    public String getJsoninfo() {
        return jsoninfo;
    }

{
        this.jsoninfo = jsoninfo;
    }
}


package com.byl.qrobot.bean;

import org.json.JSONObject;
import java.util.List;

/**
 * 机器人回答类
 * Created by baiyuliang on 2016-5-12.
 */
public class Answer {

    // 返回码
    private String code;

    // 内容
    private String text;

    // 链接
    private String url;

    // 新闻列表
    private List<News> listNews;

    // 菜谱列表
    private List<Cook> listCook;

    private String jsoninfo;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getText()

    public void setText(String text) {
        this.text = text;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<News> getListNews() {
        return listNews;
    }

    public void setListNews(List<News> listNews) {
        this.listNews = listNews;
    }

    public List<Cook> getListCook() {
        return listCook;
    }

    public void setListCook(List<Cook> listCook) {
        this.listCook = listCook;
    }

    public String getJsoninfo() {
        return jsoninfo;
    }

    public void setJsoninfo(String jsoninfo) {
        this.jsoninfo = jsoninfo;
    }
}


package com.byl.qrobot.bean;

import org.json.JSONObject;
import java.util.List;

/**
 * 机器人回答类
 * Created by baiyuliang on 2016-5-12.
 */
public class Answer {

    // 返回码
    private String code;

    // 内容
    private String text;

    // 链接
    private String url;

    // 新闻列表
    private List<News> listNews;

    // 菜谱列表
    private List<Cook> listCook;

    private String jsoninfo;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<News> getListNews() {
        return listNews;
    }

    public void setListNews(List<News> listNews) {
        this.listNews = listNews;
    }

    public List<Cook> getListCook() {
        ret

    }

    public void setListCook(List<Cook> listCook) {
        this.listCook = listCook;
    }

    public String getJsoninfo() {
        return jsoninfo;
    }

    public void setJsoninfo(String jsoninfo) {
        this.jsoninfo = jsoninfo;
    }
}


public void registerResourceReferenceProcessor(final EEResourceReferenceProcessor resourceReferenceProcessor)

/*
 * JBoss, Home of Professional Open Source.
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 */
package org.jboss.as.ee.component.deployers;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.as.ee.logging.EeLogger;

public class EEResourceReferenceProcessorRegistry {

    private final Map<String, EEResourceReferenceProcessor> resourceReferenceProcessors = new ConcurrentHashMap<String, EEResourceReferenceProcessor>();

{
        if (resourceReferenceProcessor == null) {
            throw EeLogger.ROOT_LOGGER.nullResourceReference();
        }
        final String resourceReferenceType = resourceReferenceProcessor.getResourceReferenceType();
        if (resourceReferenceType == null || resourceReferenceType.trim().isEmpty()) {
            throw EeLogger.ROOT_LOGGER.nullOrEmptyResourceReferenceType();
        }
        resourceReferenceProcessors.put(resourceReferenceType, resourceReferenceProcessor);
    }

    public EEResourceReferenceProcessor getResourceReferenceProcessor(final String resourceReferenceType) {
        return resourceReferenceProcessors.get(resourceReferenceType);
    }
}


{
        return resourceReferenceProcessors.get(resourceReferenceType);
    }

/*
 * JBoss, Home of Professional Open Source.
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 */
package org.jboss.as.ee.component.deployers;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.as.ee.logging.EeLogger;

public class EEResourceReferenceProcessorRegistry {

    private final Map<String, EEResourceReferenceProcessor> resourceReferenceProcessors = new ConcurrentHashMap<String, EEResourceReferenceProcessor>();

    public void registerResourceReferenceProcessor(final EEResourceReferenceProcessor resourceReferenceProcessor) {
        if (resourceReferenceProcessor == null) {
            throw EeLogger.ROOT_LOGGER.nullResourceReference();
        }
        final String resourceReferenceType = resourceReferenceProcessor.getResourceReferenceType();
        if (resourceReferenceType == null || resourceReferenceType.trim().isEmpty()) {
            throw EeLogger.ROOT_LOGGER.nullOrEmptyResourceReferenceType();
        }
        resourceReferenceProcessors.put(resourceReferenceType, resourceReferenceProcessor);
    }

    public EEResourceReferenceProcessor getResourceReferenceProcessor(final String resourceReferenceType)


/*
 * JBoss, Home of Professional Open Source.
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 */
package org.jboss.as.ee.component.deployers;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.as.ee.logging.EeLogger;

public class EEResourceReferenceProcessorRegistry {

    private final Map<String, EEResourceReferenceProcessor> resourceReferenceProcessors = new ConcurrentHashMap<String, EEResourceReferenceProcessor>();

    public void registerResourceReferenceProcessor(final EEResourceReferenceProcessor resourceReferenceProcessor) {
        if (resourceReferenceProcessor == null) {
            throw EeLogger.ROOT_LOGGER.nullResourceReference();
        }
        final String resourceReferenceType = resourceReferenceProcessor.getResourceReferenceType();
        if (resourceReferenceType == null || resourceReferenceType.trim().isEmpty()) {
            throw EeLogger.ROOT_LOGGER.nullOrEmptyResourceReferenceType();
        }
        resourceReferenceProcessors.put(resourceReferenceType, resourceReferenceProcessor);
    }

    public EEResourceReferenceProcessor getResourceReferenceProcessor(final String resourceReferenceType) {
        return resou


public static DTO created(final String location)

package org.openhab.core.io.rest.sitemap.internal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openhab.core.io.rest.sitemap.internal.JerseyResponseBuilderUtils.JerseyResponseBuilderDTO.ContextDTO;
import org.openhab.core.io.rest.sitemap.internal.JerseyResponseBuilderUtils.JerseyResponseBuilderDTO.ContextDTO.StreamInfoDTO;
import org.osgi.dto.DTO;

/**
 * Data transfer object until UIs are fixed.
 *
 * <p>
 * {@link http://example.com}
 *
 * @author Markus Rathgeb - Initial contribution
 */
public class JerseyResponseBuilderUtils extends DTO {

    public static class JerseyResponseBuilderDTO extends DTO {

        public static class ContextDTO extends DTO {

            public static class StreamInfoDTO extends DTO {

                int bufferSize;

                boolean directWrite;

                boolean isCommitted;

                boolean isClosed;
            }

            public Map<String, List<Object>> headers;

            public StreamInfoDTO committingOutputStream;

            public List<String> entityAnnotations;

            public StreamInfoDTO entityStream;
        }

        public String status;

        public ContextDTO context;
    }

{
        JerseyResponseBuilderDTO jrbDTO = new JerseyResponseBuilderDTO();
        jrbDTO.status = "CREATED";
        jrbDTO.context = new ContextDTO();
        jrbDTO.context.headers = new HashMap<>();
        jrbDTO.context.headers.put("Location", List.of(location));
        jrbDTO.context.committingOutputStream = new StreamInfoDTO();
        jrbDTO.context.committingOutputStream.bufferSize = 0;
        jrbDTO.context.committingOutputStream.directWrite = true;
        jrbDTO.context.committingOutputStream.isCommitted = false;
        jrbDTO.context.committingOutputStream.isClosed = false;
        jrbDTO.context.entityAnnotations = new ArrayList<>(0);
        jrbDTO.context.entityStream = new StreamInfoDTO();
        jrbDTO.context.entityStream.bufferSize = 0;
        jrbDTO.context.entityStream.directWrite = true;
        jrbDTO.context.entityStream.isCommitted = false;
        jrbDTO.context.entityStream.isClosed = false;
        return jrbDTO;
    }
}


package org.openhab.core.io.rest.sitemap.internal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openhab.core.io.rest.sitemap.internal.JerseyResponseBuilderUtils.JerseyResponseBuilderDTO.ContextDTO;
import org.openhab.core.io.rest.sitemap.internal.JerseyResponseBuilderUtils.JerseyResponseBuilderDTO.ContextDTO.StreamInfoDTO;
import org.osgi.dto.DTO;

/**
 * Data transfer object until UIs are fixed.
 *
 * <p>
 * {@link http://example.com}
 *
 * @author Markus Rathgeb - Initial contribution
 */
public class JerseyResponseBuilderUtils extends DTO {

    public static class JerseyResponseBuilderDTO extends DTO {

        public static class ContextDTO extends DTO {

            public static class StreamInfoDTO extends DTO {

                int bufferSize;

                boolean directWrite;

                boolean isCommitted;

                boolean isClosed;
            }

            public Map<String, List<Object>> headers;

            public StreamInfoDTO committingOutputStream;

            public List<String> entityAnnotations;

            public StreamInfoDTO entityStream;
        }

        public String status;

        public ContextDTO context;
    }

    public static DTO created(final String location) {
        JerseyResponseBuilderDTO jrbDTO = new JerseyResponseBuilderDTO();
        jrbDTO.status = "CREATE

        jrbDTO.context = new ContextDTO();
        jrbDTO.context.headers = new HashMap<>();
        jrbDTO.context.headers.put("Location", List.of(location));
        jrbDTO.context.committingOutputStream = new StreamInfoDTO();
        jrbDTO.context.committingOutputStream.bufferSize = 0;
        jrbDTO.context.committingOutputStream.directWrite = true;
        jrbDTO.context.committingOutputStream.isCommitted = false;
        jrbDTO.context.committingOutputStream.isClosed = false;
        jrbDTO.context.entityAnnotations = new ArrayList<>(0);
        jrbDTO.context.entityStream = new StreamInfoDTO();
        jrbDTO.context.entityStream.bufferSize = 0;
        jrbDTO.context.entityStream.directWrite = true;
        jrbDTO.context.entityStream.isCommitted = false;
        jrbDTO.context.entityStream.isClosed = false;
        return jrbDTO;
    }
}


@Override
    public String getSharingProfileName()

package org.apache.guacamole.auth.jdbc.connection;

import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecord;
import org.apache.guacamole.net.auth.ConnectionRecord;

/**
 * A ConnectionRecord which is backed by a database model.
 */
public class ModeledConnectionRecord extends ModeledActivityRecord implements ConnectionRecord {

    /**
     * The model object backing this connection record.
     */
    private final ConnectionRecordModel model;

    /**
     * Creates a new ModeledConnectionRecord backed by the given model object.
     * Changes to this record will affect the backing model object, and changes
     * to the backing model object will affect this record.
     *
     * @param model
     *     The model object to use to back this connection record.
     */
    public ModeledConnectionRecord(ConnectionRecordModel model) {
        super(model);
        this.model = model;
    }

    @Override
    public String getConnectionIdentifier() {
        return model.getConnectionIdentifier();
    }

    @Override
    public String getConnectionName() {
        return model.getConnectionName();
    }

    @Override
    public String getSharingProfileIdentifier() {
        return model.getSharingProfileIdentifier();
    }

{
        return model.getSharingProfileName();
    }
}


{
        return model.getSharingProfileName();
    }

package org.apache.guacamole.auth.jdbc.connection;

import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecord;
import org.apache.guacamole.net.auth.ConnectionRecord;

/**
 * A ConnectionRecord which is backed by a database model.
 */
public class ModeledConnectionRecord extends ModeledActivityRecord implements ConnectionRecord {

    /**
     * The model object backing this connection record.
     */
    private final ConnectionRecordModel model;

    /**
     * Creates a new ModeledConnectionRecord backed by the given model object.
     * Changes to this record will affect the backing model object, and changes
     * to the backing model object will affect this record.
     *
     * @param model
     *     The model object to use to back this connection record.
     */
    public ModeledConnectionRecord(ConnectionRecordModel model) {
        super(model);
        this.model = model;
    }

    @Override
    public String getConnectionIdentifier() {
        return model.getConnectionIdentifier();
    }

    @Override
    public String getConnectionName() {
        return model.getConnectionName();
    }

    @Override
    public String getSharingProfileIdentifier() {
        return model.getSharingProfileIdentifier();
    }

    @Override
    public String getSharingProfileName()


package org.apache.guacamole.auth.jdbc.connection;

import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecord;
import org.apache.guacamole.net.auth.ConnectionRecord;

/**
 * A ConnectionRecord which is backed by a database model.
 */
public class ModeledConnectionRecord extends ModeledActivityRecord implements ConnectionRecord {

    /**
     * The model object backing this connection record.
     */
    private final ConnectionRecordModel model;

    /**
     * Creates a new ModeledConnectionRecord backed by the given model object.
     * Changes to this record will affect the backing model object, and changes
     * to the backing model object will affect this record.
     *
     * @param model
     *     The model object to use to back this connection record.
     */
    public ModeledConnectionRecord(ConnectionRecordModel model) {
        super(model);
        this.model = model;
    }

    @Override
    public String getConnectionIdentifier() {
        ret

    }

    @Override
    public String getConnectionName() {
        return model.getConnectionName();
    }

    @Override
    public String getSharingProfileIdentifier() {
        return model.getSharingProfileIdentifier();
    }

    @Override
    public String getSharingProfileName() {
        return model.getSharingProfileName();
    }
}


@Override
        public Response apply(ContainerRequestContext containerRequestContext)

package org.glassfish.jersey.server.wadl.processor;

import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.annotation.Priority;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.xml.bind.Marshaller;
import org.glassfish.jersey.internal.util.PropertiesHelper;
import org.glassfish.jersey.message.internal.MediaTypes;
import org.glassfish.jersey.process.Inflector;
import org.glassfish.jersey.server.ExtendedUriInfo;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.model.ModelProcessor;
import org.glassfish.jersey.server.model.Resource;
import org.glassfish.jersey.server.model.ResourceModel;
import org.glassfish.jersey.server.model.RuntimeResource;
import org.glassfish.jersey.server.model.internal.ModelProcessorUtil;
import org.glassfish.jersey.server.wadl.WadlApplicationContext;
import org.glassfish.jersey.server.wadl.internal.WadlResource;
import org.glassfish.jersey.server.wadl.internal.WadlUtils;
import com.sun.research.ws.wadl.Application;

/**
 * WADL {@link ModelProcessor model processor} which enhance resource model by WADL related resources (like "/application.wadl").
 * The provider should be registered using
 * {@link org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable} or by
 * {@link org.glassfish.jersey.server.wadl.WadlFeature} if auto-discovery is disabled.
 *
 * @author Miroslav Fuksa
 */
@Priority(10000)
public class WadlModelProcessor implements ModelProcessor {

    private final List<ModelProcessorUtil.Method> methodList;

    /**
     * Create new WADL model processor instance.
     */
    public WadlModelProcessor() {
        methodList = new ArrayList<>();
        methodList.add(new ModelProcessorUtil.Method(HttpMethod.OPTIONS, MediaType.WILDCARD_TYPE, MediaTypes.WADL_TYPE, OptionsHandler.class));
    }

    @Override
    public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) {
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true);
        // Do not add WadlResource if already present in the classes (i.e. added during scanning).
        if (!configuration.getClasses().contains(WadlResource.class)) {
            final Resource wadlResource = Resource.builder(WadlResource.class).build();
            builder.addResource(wadlResource);
        }
        return builder.build();
    }

    /**
     * OPTIONS resource method handler that serves resource WADL.
     */
    public static class OptionsHandler implements Inflector<ContainerRequestContext, Response> {

        private final String lastModified = new SimpleDateFormat(WadlResource.HTTPDATEFORMAT).format(new Date());

        @Inject
        private Provider<ExtendedUriInfo> extendedUriInfo;

        @Context
        private WadlApplicationContext wadlApplicationContext;

{
            final RuntimeResource resource = extendedUriInfo.get().getMatchedRuntimeResources().get(0);
            // TODO: support multiple resources, see ignored tests in WadlResourceTest.Wadl8Test
            final UriInfo uriInfo = containerRequestContext.getUriInfo();
            final Application wadlApplication = wadlApplicationContext.getApplication(uriInfo, resource.getResources().get(0), WadlUtils.isDetailedWadlRequested(uriInfo));
            if (wadlApplication == null) {
                // wadlApplication can be null if limited WADL is requested and all content
                // of wadlApplication is invisible in limited WADL
                return Response.status(Response.Status.NOT_FOUND).build();
            }
            byte[] bytes;
            try {
                final Marshaller marshaller = wadlApplicationContext.getJAXBContext().createMarshaller();
                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                final ByteArrayOutputStream os = new ByteArrayOutputStream();
                marshaller.marshal(wadlApplication, os);
                bytes = os.toByteArray();
                os.close();
            } catch (Exception e) {
                throw new ProcessingException("Could not marshal the wadl Application.", e);
            }
            return Response.ok().type(MediaTypes.WADL_TYPE).allow(ModelProcessorUtil.getAllowedMethods(resource)).header("Last-modified", lastModified).entity(bytes).build();
        }
    }

    @Override
    public ResourceModel processSubResource(ResourceModel resourceModel, Configuration configuration) {
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        return ModelProcessorUtil.enhanceResourceModel(resourceModel, true, methodList, true).build();
    }
}


{
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        return ModelProcessorUtil.enhanceResourceModel(resourceModel, true, methodList, true).build();
    }

package org.glassfish.jersey.server.wadl.processor;

import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.annotation.Priority;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.xml.bind.Marshaller;
import org.glassfish.jersey.internal.util.PropertiesHelper;
import org.glassfish.jersey.message.internal.MediaTypes;
import org.glassfish.jersey.process.Inflector;
import org.glassfish.jersey.server.ExtendedUriInfo;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.model.ModelProcessor;
import org.glassfish.jersey.server.model.Resource;
import org.glassfish.jersey.server.model.ResourceModel;
import org.glassfish.jersey.server.model.RuntimeResource;
import org.glassfish.jersey.server.model.internal.ModelProcessorUtil;
import org.glassfish.jersey.server.wadl.WadlApplicationContext;
import org.glassfish.jersey.server.wadl.internal.WadlResource;
import org.glassfish.jersey.server.wadl.internal.WadlUtils;
import com.sun.research.ws.wadl.Application;

/**
 * WADL {@link ModelProcessor model processor} which enhance resource model by WADL related resources (like "/application.wadl").
 * The provider should be registered using
 * {@link org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable} or by
 * {@link org.glassfish.jersey.server.wadl.WadlFeature} if auto-discovery is disabled.
 *
 * @author Miroslav Fuksa
 */
@Priority(10000)
public class WadlModelProcessor implements ModelProcessor {

    private final List<ModelProcessorUtil.Method> methodList;

    /**
     * Create new WADL model processor instance.
     */
    public WadlModelProcessor() {
        methodList = new ArrayList<>();
        methodList.add(new ModelProcessorUtil.Method(HttpMethod.OPTIONS, MediaType.WILDCARD_TYPE, MediaTypes.WADL_TYPE, OptionsHandler.class));
    }

    @Override
    public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) {
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true);
        // Do not add WadlResource if already present in the classes (i.e. added during scanning).
        if (!configuration.getClasses().contains(WadlResource.class)) {
            final Resource wadlResource = Resource.builder(WadlResource.class).build();
            builder.addResource(wadlResource);
        }
        return builder.build();
    }

    /**
     * OPTIONS resource method handler that serves resource WADL.
     */
    public static class OptionsHandler implements Inflector<ContainerRequestContext, Response> {

        private final String lastModified = new SimpleDateFormat(WadlResource.HTTPDATEFORMAT).format(new Date());

        @Inject
        private Provider<ExtendedUriInfo> extendedUriInfo;

        @Context
        private WadlApplicationContext wadlApplicationContext;

        @Override
        public Response apply(ContainerRequestContext containerRequestContext) {
            final RuntimeResource resource = extendedUriInfo.get().getMatchedRuntimeResources().get(0);
            // TODO: support multiple resources, see ignored tests in WadlResourceTest.Wadl8Test
            final UriInfo uriInfo = containerRequestContext.getUriInfo();
            final Application wadlApplication = wadlApplicationContext.getApplication(uriInfo, resource.getResources().get(0), WadlUtils.isDetailedWadlRequested(uriInfo));
            if (wadlApplication == null) {
                // wadlApplication can be null if limited WADL is requested and all content
                // of wadlApplication is invisible in limited WADL
                return Response.status(Response.Status.NOT_FOUND).build();
            }
            byte[] bytes;
            try {
                final Marshaller marshaller = wadlApplicationContext.getJAXBContext().createMarshaller();
                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                final ByteArrayOutputStream os = new ByteArrayOutputStream();
                marshaller.marshal(wadlApplication, os);
                bytes = os.toByteArray();
                os.close();
            } catch (Exception e) {
                throw new ProcessingException("Could not marshal the wadl Application.", e);
            }
            return Response.ok().type(MediaTypes.WADL_TYPE).allow(ModelProcessorUtil.getAllowedMethods(resource)).header("Last-modified", lastModified).entity(bytes).build();
        }
    }

    @Override
    public ResourceModel processSubResource(ResourceModel resourceModel, Configuration configuration)


package org.glassfish.jersey.server.wadl.processor;

import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.annotation.Priority;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.xml.bind.Marshaller;
import org.glassfish.jersey.internal.util.PropertiesHelper;
import org.glassfish.jersey.message.internal.MediaTypes;
import org.glassfish.jersey.process.Inflector;
import org.glassfish.jersey.server.ExtendedUriInfo;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.model.ModelProcessor;
import org.glassfish.jersey.server.model.Resource;
import org.glassfish.jersey.server.model.ResourceModel;
import org.glassfish.jersey.server.model.RuntimeResource;
import org.glassfish.jersey.server.model.internal.ModelProcessorUtil;
import org.glassfish.jersey.server.wadl.WadlApplicationContext;
import org.glassfish.jersey.server.wadl.internal.WadlResource;
import org.glassfish.jersey.server.wadl.internal.WadlUtils;
import com.sun.research.ws.wadl.Application;

/**
 * WADL {@link ModelProcessor model processor} which enhance resource model by WADL related resources (like "/application.wadl").
 * The provider should be registered using
 * {@link org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable} or by
 * {@link org.glassfish.jersey.server.wadl.WadlFeature} if auto-discovery is disabled.
 *
 * @author Miroslav Fuksa
 */
@Priority(10000)
public class WadlModelProcessor implements ModelProcessor {

    private final List<ModelProcessorUtil.Method> methodList;

    /**
     * Create new WADL model processor instance.
     */
    public WadlModelProcessor() {
        methodList = new ArrayList<>();
        methodList.add(new ModelProcessorUtil.Method(HttpMethod.OPTIONS, MediaType.WILDCARD_TYPE, MediaTypes.WADL_TYPE, OptionsHandler.class));
    }

    @Override
    public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) {
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true);
        // Do not add WadlResource if already present in the classes (i.e. added during scanning).
        if (!configuration.getClasses().contains(WadlResource.class)) {
            final Resource wadlResource = Resource.builder(WadlResource.class).build();
            builder.addResource(wadlResource);
        }
        return builder.build();
    }

    /**
     * OPTIONS resource method handler that serves resource WADL.
     */
    public static class OptionsHandler implements Inflector<ContainerRequestContext, Response> {

        private final String lastModified = new SimpleDateFormat(WadlResource.HTTPDATEFORMAT).format(new Date());

        @Inject
        private Provider<ExtendedUriInfo> extendedUriInfo;

        @Context
        private WadlApplicationContext wadlApplicationContext;

        @Override
        public Response apply(ContainerRequestContext containerRequestContext) {
            final RuntimeResource resource = extendedUriInfo.get().getMatchedRuntimeResources().get(0);
            // TODO: support multiple resources, see ignored tests in WadlResourceTest.Wadl8Test
            final UriInfo uriInfo = containerRequestContext.getUriInfo();
            final Application wadlApplication = wadlApplicationContext.getApplication(uriInfo, resource.getResources().get(0), WadlUtils.isDetailedWadlRequested(uriInfo));
            if (wadlApplication == null) {
                // wadlApplication can be null if limited WADL is requested and all content
                // of wadlApplication is invisible in limited WADL
                return Response.status(Response.Status.NOT_FOUND).build();
            }
            byte[] by

            try {
                final Marshaller marshaller = wadlApplicationContext.getJAXBContext().createMarshaller();
                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                final ByteArrayOutputStream os = new ByteArrayOutputStream();
                marshaller.marshal(wadlApplication, os);
                bytes = os.toByteArray();
                os.close();
            } catch (Exception e) {
                throw new ProcessingException("Could not marshal the wadl Application.", e);
            }
            return Response.ok().type(MediaTypes.WADL_TYPE).allow(ModelProcessorUtil.getAllowedMethods(resource)).header("Last-modified", lastModified).entity(bytes).build();
        }
    }

    @Override
    public ResourceModel processSubResource(ResourceModel resourceModel, Configuration configuration) {
        final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE));
        if (disabled) {
            return resourceModel;
        }
        return ModelProcessorUtil.enhanceResourceModel(resourceModel, true, methodList, true).build();
    }
}


package com.bytezone.dm3270.extended;

import com.bytezone.dm3270.utilities.Dm3270Utility;

public class ResponseCommand extends AbstractExtendedCommand {

    public ResponseCommand(CommandHeader commandHeader, byte[] buffer, int offset, int length) {
        super(commandHeader, buffer, offset, length);
        if (length != 1)
            System.out.println(Dm3270Utility.toHex(buffer, offset, length));
    }

{
        return "Response";
    }

    @Override
    public String toString() {
        return String.format("Rsp: %02X", data[0]);
    }
}


package com.bytezone.dm3270.extended;

import com.bytezone.dm3270.utilities.Dm3270Utility;

public class ResponseCommand extends AbstractExtendedCommand {

    public ResponseCommand(CommandHeader commandHeader, byte[] buffer, int offset, int length) {
        super(commandHeader, buffer, offset, length);
        if (length != 1)
            System.out.println(Dm3270Utility.toHex(buffer, offset, length));
    }

    @Override
    public String getName()

    @Override
    public String toString() {
        return String.format("Rsp: %02X", data[0]);
    }
}


package com.bytezone.dm3270.extended;

import com.bytezone.dm3270.utilities.Dm3270Utility;

public class ResponseCommand extends AbstractExtendedCommand {

    public ResponseCommand(CommandHeader commandHeader, byte[] buffer, int offset, int length) {
        super(commandHeader, buffer, offset, length);
        if (length != 1)
            System.out.println(Dm3270Utility.toHex(buffer, offset, length));
    }

    @Override
    public String getName() {
        return "Response";
    }

    @Override
    public String toString() {
        return String.format("Rsp: %02X", data


private boolean hasNoColumnEntries(IMenuManager manager)

package sernet.verinice.rcp.search.tables;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import sernet.verinice.model.search.VeriniceSearchResultTable;
import sernet.verinice.rcp.search.Messages;
import sernet.verinice.rcp.search.SearchView;
import sernet.verinice.rcp.search.column.ColumnStoreFactory;
import sernet.verinice.rcp.search.column.IColumn;
import sernet.verinice.rcp.search.column.IColumnStore;

public class TableMenuListener implements IMenuListener {

    private final SearchView searchView;

    private IColumnStore columnStore;

    private VeriniceSearchResultTable vSearchResultObject;

    public TableMenuListener(SearchView searchView, VeriniceSearchResultTable vSearchResultObject) {
        this.searchView = searchView;
        columnStore = ColumnStoreFactory.getColumnStore(vSearchResultObject.getEntityTypeId());
        this.vSearchResultObject = vSearchResultObject;
    }

    @Override
    public void menuAboutToShow(IMenuManager manager) {
        if (hasNoColumnEntries(manager)) {
            for (IColumn col : columnStore.getAllColumns()) {
                manager.add(new ColumnContribution(this.searchView, col, vSearchResultObject));
            }
            manager.add(new Separator());
            manager.add(new RestoreDefaultAction());
        }
    }

{
        return manager.getItems() != null && manager.getItems().length == 0;
    }

    private class RestoreDefaultAction extends Action {

        public RestoreDefaultAction() {
            setText(Messages.SearchView_6);
            setToolTipText(Messages.SearchView_6);
        }

        @Override
        public void run() {
            columnStore.restoreDefault();
            searchView.setTableViewer(vSearchResultObject);
        }
    }
}


{
        return manager.getItems() != null && manager.getItems().length == 0;
    }

package sernet.verinice.rcp.search.tables;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import sernet.verinice.model.search.VeriniceSearchResultTable;
import sernet.verinice.rcp.search.Messages;
import sernet.verinice.rcp.search.SearchView;
import sernet.verinice.rcp.search.column.ColumnStoreFactory;
import sernet.verinice.rcp.search.column.IColumn;
import sernet.verinice.rcp.search.column.IColumnStore;

public class TableMenuListener implements IMenuListener {

    private final SearchView searchView;

    private IColumnStore columnStore;

    private VeriniceSearchResultTable vSearchResultObject;

    public TableMenuListener(SearchView searchView, VeriniceSearchResultTable vSearchResultObject) {
        this.searchView = searchView;
        columnStore = ColumnStoreFactory.getColumnStore(vSearchResultObject.getEntityTypeId());
        this.vSearchResultObject = vSearchResultObject;
    }

    @Override
    public void menuAboutToShow(IMenuManager manager) {
        if (hasNoColumnEntries(manager)) {
            for (IColumn col : columnStore.getAllColumns()) {
                manager.add(new ColumnContribution(this.searchView, col, vSearchResultObject));
            }
            manager.add(new Separator());
            manager.add(new RestoreDefaultAction());
        }
    }

    private boolean hasNoColumnEntries(IMenuManager manager)

    private class RestoreDefaultAction extends Action {

        public RestoreDefaultAction() {
            setText(Messages.SearchView_6);
            setToolTipText(Messages.SearchView_6);
        }

        @Override
        public void run() {
            columnStore.restoreDefault();
            searchView.setTableViewer(vSearchResultObject);
        }
    }
}


package sernet.verinice.rcp.search.tables;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import sernet.verinice.model.search.VeriniceSearchResultTable;
import sernet.verinice.rcp.search.Messages;
import sernet.verinice.rcp.search.SearchView;
import sernet.verinice.rcp.search.column.ColumnStoreFactory;
import sernet.verinice.rcp.search.column.IColumn;
import sernet.verinice.rcp.search.column.IColumnStore;

public class TableMenuListener implements IMenuListener {

    private final SearchView searchView;

    private IColumnStore columnStore;

    private VeriniceSearchResultTable vSearchResultObject;

    public TableMenuListener(SearchView searchView, VeriniceSearchResultTable vSearchResultObject) {
        this.searchView = searchView;
        columnStore = ColumnStoreFactory.getColumnStore(vSearchResultObject.getEntityTypeId());
        this.vSearchResultObject = vSearchResultObject;
    }

    @Override
    public void menuAboutToShow(IMenuManager manager) {
        if (hasNoColumnEntries(manager)) {
            for (IColumn col : columnStore.getAllColumns()) {
                manager.add(new ColumnContribution(this.searchView, col, vSearchResultObject));
            }
            manager.add(new Separator());
            manager.add(new RestoreDefaultAction());
        }
    }

    private boolean hasNoColumnEntries(IMenuManager manager) {
        return manager.getItems() != null && manager.getItems().length == 0;
    }

    private class RestoreDefaultAction extends Action {

        public RestoreDefaultAction() {
            setText(Messages.SearchView_6);
            setToolTipText(Messages.SearchView_6);
        }

        @Override
        public void run() {
            columnStore.restoreDefault(

            searchView.setTableViewer(vSearchResultObject);
        }
    }
}


public POSSample read() throws IOException

package opennlp.tools.postag;

import java.io.IOException;
import opennlp.tools.util.FilterObjectStream;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.ObjectStream;

/**
 * A stream filter which reads a sentence per line which contains
 * words and tags in word_tag format and outputs a {@link POSSample} objects.
 */
public class WordTagSampleStream extends FilterObjectStream<String, POSSample> {

    /**
     * Initializes the current instance.
     *
     * @param sentences the sentences
     */
    public WordTagSampleStream(ObjectStream<String> sentences) {
        super(sentences);
    }

    /**
     * Parses the next sentence and return the next
     * {@link POSSample} object.
     *
     * If an error occurs an empty {@link POSSample} object is returned
     * and an warning message is logged. Usually it does not matter if one
     * of many sentences is ignored.
     *
     * TODO: An exception in error case should be thrown.
     */

{
        String sentence = samples.read();
        if (sentence != null) {
            POSSample sample;
            try {
                sample = POSSample.parse(sentence);
            } catch (InvalidFormatException e) {
                System.out.println("Error during parsing, ignoring sentence: " + sentence);
                sample = new POSSample(new String[] {}, new String[] {});
            }
            return sample;
        } else {
            // sentences stream is exhausted
            return null;
        }
    }
}


package opennlp.tools.postag;

import java.io.IOException;
import opennlp.tools.util.FilterObjectStream;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.ObjectStream;

/**
 * A stream filter which reads a sentence per line which contains
 * words and tags in word_tag format and outputs a {@link POSSample} objects.
 */
public class WordTagSampleStream extends FilterObjectStream<String, POSSample> {

    /**
     * Initializes the current instance.
     *
     * @param sentences the sentences
     */
    public WordTagSampleStream(ObjectStream<String> sentences) {
        super(sentences);
    }

    /**
     * Parses the next sentence and return the next
     * {@link POSSample} object.
     *
     * If an error occurs an empty {@link POSSample} object is returned
     * and an warning message is logged. Usually it does not matter if one
     * of many sentences is ignored.
     *
     * TODO: An exception in error case should be thrown.
     */
    public POSSample read() throws IOException {
        String sente

        if (sentence != null) {
            POSSample sample;
            try {
                sample = POSSample.parse(sentence);
            } catch (InvalidFormatException e) {
                System.out.println("Error during parsing, ignoring sentence: " + sentence);
                sample = new POSSample(new String[] {}, new String[] {});
            }
            return sample;
        } else {
            // sentences stream is exhausted
            return null;
        }
    }
}


try {
                sample = POSSample.parse(sentence);
            } catch (InvalidFormatException e) {
                System.out.println("Error during parsing, ignoring sentence: " + sentence);
                sample = new POSSample(new String[] {}, new String[] {});
            }

package opennlp.tools.postag;

import java.io.IOException;
import opennlp.tools.util.FilterObjectStream;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.ObjectStream;

/**
 * A stream filter which reads a sentence per line which contains
 * words and tags in word_tag format and outputs a {@link POSSample} objects.
 */
public class WordTagSampleStream extends FilterObjectStream<String, POSSample> {

    /**
     * Initializes the current instance.
     *
     * @param sentences the sentences
     */
    public WordTagSampleStream(ObjectStream<String> sentences) {
        super(sentences);
    }

    /**
     * Parses the next sentence and return the next
     * {@link POSSample} object.
     *
     * If an error occurs an empty {@link POSSample} object is returned
     * and an warning message is logged. Usually it does not matter if one
     * of many sentences is ignored.
     *
     * TODO: An exception in error case should be thrown.
     */
    public POSSample read() throws IOException {
        String sentence = samples.read();
        if (sentence != null) {
            POSSample sample;

            return sample;
        } else {
            // sentences stream is exhausted
            return null;
        }
    }
}


public void initialise(Properties userProps) throws ManipulationException

package org.commonjava.maven.ext.core.state;

import org.commonjava.maven.ext.annotation.ConfigValue;
import org.commonjava.maven.ext.common.ManipulationException;
import java.util.Properties;

/**
 * Captures configuration relating to groovy script execution.
 */
public class GroovyState implements State {

    /**
     * The name of the property which contains a comma separated list of remote groovy scripts to load.
     *

     * -DgroovyScripts=org.foo:bar-script,....
     *

     */
    @ConfigValue(docIndex = "groovy.html")
    private static final String GROOVY_SCRIPT = "groovyScripts";

    private String groovyScripts;

    public GroovyState(final Properties userProps) throws ManipulationException {
        initialise(userProps);
    }

{
        groovyScripts = userProps.getProperty(GROOVY_SCRIPT);
        // Catch old style groovy configuration. Not doc'ed as config value.
        if (userProps.getProperty("groovyManipulatorPrecedence") != null) {
            throw new ManipulationException("groovyManipulatorPrecedence is no longer valid");
        }
    }

    /**
     * Enabled ONLY if groovyScripts is provided in the user properties / CLI -D options.
     *
     * @see State#isEnabled()
     */
    @Override
    public boolean isEnabled() {
        return groovyScripts != null && !groovyScripts.isEmpty();
    }

    public String getGroovyScripts() {
        return groovyScripts;
    }
}


package org.commonjava.maven.ext.core.state;

import org.commonjava.maven.ext.annotation.ConfigValue;
import org.commonjava.maven.ext.common.ManipulationException;
import java.util.Properties;

/**
 * Captures configuration relating to groovy script execution.
 */
public class GroovyState implements State {

    /**
     * The name of the property which contains a comma separated list of remote groovy scripts to load.
     *

     * -DgroovyScripts=org.foo:bar-script,....
     *

     */
    @ConfigValue(docIndex = "groovy.html")
    private static final String GROOVY_SCRIPT = "groovyScripts";

    private String groovyScripts;

    public GroovyState(final Properties userProps) throws ManipulationException {
        initialise(userProps);
    }

    public void initialise(Properties userProps) throws ManipulationException {
        groovyScripts = userProps.getProperty(GROOVY_SCRIPT);
        // Catch old style groovy configuration. Not doc'ed as config value.
        if (userProps.getProperty("groovyManipulatorPrecedence") != null) {
            throw new ManipulationException("groovyManipulatorPrecedence is no longer valid");
        }
    }

    /**
     * Enabled ONLY if groovyScripts is provided in the user properties / CLI -D options.
     *
     * @see State#isEnabled()
     */
    @Override
    public boolean isEnabled() {
        return groovyScripts != null && !groovyScripts.isEmpty();
    }

    public String getGroovyScripts()


package org.commonjava.maven.ext.core.state;

import org.commonjava.maven.ext.annotation.ConfigValue;
import org.commonjava.maven.ext.common.ManipulationException;
import java.util.Properties;

/**
 * Captures configuration relating to groovy script execution.
 */
public class GroovyState implements State {

    /**
     * The name of the property which contains a comma separated list of remote groovy scripts to load.
     *

     * -DgroovyScripts=org.foo:bar-script,....
     *

     */
    @ConfigValue(docIndex = "groovy.html")
    private static final String GROOVY_SCRIPT = "groovyScripts";

    private String groovyScripts;

    public GroovyState(final Properties userProps) throws ManipulationException {
        initialise(userProps);
    }

    public void initialise(Properties userProps) throws ManipulationException {
        groovyScripts = userProps.getProperty(GROOVY_SCRIPT);
        // Catch old style groovy configuration. Not doc'ed as config value.
        if (userProps.getProperty("groovyManipulatorPrecedence") != null) {
            throw new ManipulationException("groovyManipulatorPrecedence is no longer valid");
        }
    }

    /**
     * Enabled ONLY if groovyScripts is provided in the user properties / CLI -D options.
     *
     * @see State#isEnabled()
     */
    @Override
    public boolean isEnabled() {
        return groovyScripts != null && !groov

    }

    public String getGroovyScripts() {
        return groovyScripts;
    }
}


@Override
    public boolean isEnabled() {
        return groovyScripts != null && !groovyScripts.isEmpty();
    }

package org.commonjava.maven.ext.core.state;

import org.commonjava.maven.ext.annotation.ConfigValue;
import org.commonjava.maven.ext.common.ManipulationException;
import java.util.Properties;

/**
 * Captures configuration relating to groovy script execution.
 */
public class GroovyState implements State {

    /**
     * The name of the property which contains a comma separated list of remote groovy scripts to load.
     *

     * -DgroovyScripts=org.foo:bar-script,....
     *

     */
    @ConfigValue(docIndex = "groovy.html")
    private static final String GROOVY_SCRIPT = "groovyScripts";

    private String groovyScripts;

    public GroovyState(final Properties userProps) throws ManipulationException {
        initialise(userProps);
    }

    public void initialise(Properties userProps) throws ManipulationException {
        groovyScripts = userProps.getProperty(GROOVY_SCRIPT);
        // Catch old style groovy configuration. Not doc'ed as config value.
        if (userProps.getProperty("groovyManipulatorPrecedence") != null) {
            throw new ManipulationException("groovyManipulatorPrecedence is no longer valid");
        }
    }

    /**
     * Enabled ONLY if groovyScripts is provided in the user properties / CLI -D options.
     *
     * @see State#isEnabled()
     */

    public String getGroovyScripts() {
        return groovyScripts;
    }
}


public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders)

package com.sun.xml.bind.v2.runtime.property;

import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.DomHandler;
import javax.xml.stream.XMLStreamException;
import com.sun.xml.bind.v2.ClassFactory;
import com.sun.xml.bind.v2.model.core.PropertyKind;
import com.sun.xml.bind.v2.model.core.WildcardMode;
import com.sun.xml.bind.v2.model.runtime.RuntimeElement;
import com.sun.xml.bind.v2.model.runtime.RuntimeReferencePropertyInfo;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
import com.sun.xml.bind.v2.runtime.XMLSerializer;
import com.sun.xml.bind.v2.runtime.reflect.Accessor;
import com.sun.xml.bind.v2.runtime.reflect.ListIterator;
import com.sun.xml.bind.v2.runtime.unmarshaller.ChildLoader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Loader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Receiver;
import com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext;
import com.sun.xml.bind.v2.runtime.unmarshaller.WildcardLoader;
import com.sun.xml.bind.v2.util.QNameMap;
import org.xml.sax.SAXException;

/**
 * @author Kohsuke Kawaguchi
 */
class ArrayReferenceNodeProperty<BeanT, ListT, ItemT> extends ArrayERProperty<BeanT, ListT, ItemT> {

    /**
     * Expected element names and what class to unmarshal.
     */
    private final QNameMap<JaxBeanInfo> expectedElements = new QNameMap<JaxBeanInfo>();

    private final boolean isMixed;

    private final DomHandler domHandler;

    private final WildcardMode wcMode;

    public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
        super(p, prop, prop.getXmlName(), prop.isCollectionNillable());
        for (RuntimeElement e : prop.getElements()) {
            JaxBeanInfo bi = p.getOrCreate(e);
            expectedElements.put(e.getElementName().getNamespaceURI(), e.getElementName().getLocalPart(), bi);
        }
        isMixed = prop.isMixed();
        if (prop.getWildcard() != null) {
            domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
            wcMode = prop.getWildcard();
        } else {
            domHandler = null;
            wcMode = null;
        }
    }

    protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
        ListIterator<ItemT> itr = lister.iterator(list, w);
        while (itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    if (isMixed && item.getClass() == String.class) {
                        w.text((String) item, null);
                    } else {
                        JaxBeanInfo bi = w.grammar.getBeanInfo(item, true);
                        if (bi.jaxbType == Object.class && domHandler != null)
                            // even if 'v' is a DOM node, it always derive from Object,
                            // so the getBeanInfo returns BeanInfo for Object
                            w.writeDom(item, domHandler, o, fieldName);
                        else
                            bi.serializeRoot(item, w);
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName, e);
                // recover by ignoring this item
            }
        }
    }

{
        final int offset = chain.allocateOffset();
        Receiver recv = new ReceiverImpl(offset);
        for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) {
            final JaxBeanInfo beanInfo = n.getValue();
            loaders.put(n.nsUri, n.localName, new ChildLoader(beanInfo.getLoader(chain.context, true), recv));
        }
        if (isMixed) {
            // handler for processing mixed contents.
            loaders.put(TEXT_HANDLER, new ChildLoader(new MixedTextLoader(recv), null));
        }
        if (domHandler != null) {
            loaders.put(CATCH_ALL, new ChildLoader(new WildcardLoader(domHandler, wcMode), recv));
        }
    }

    private static final class MixedTextLoader extends Loader {

        private final Receiver recv;

        public MixedTextLoader(Receiver recv) {
            super(true);
            this.recv = recv;
        }

        public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException {
            if (// length 0 text is pointless
            text.length() != 0)
                recv.receive(state, text.toString());
        }
    }

    public PropertyKind getKind() {
        return PropertyKind.REFERENCE;
    }

    @Override
    public Accessor getElementPropertyAccessor(String nsUri, String localName) {
        // TODO: unwrap JAXBElement
        if (wrapperTagName != null) {
            if (wrapperTagName.equals(nsUri, localName))
                return acc;
        } else {
            if (expectedElements.containsKey(nsUri, localName))
                return acc;
        }
        return null;
    }
}


{
            if (// length 0 text is pointless
            text.length() != 0)
                recv.receive(state, text.toString());
        }

package com.sun.xml.bind.v2.runtime.property;

import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.DomHandler;
import javax.xml.stream.XMLStreamException;
import com.sun.xml.bind.v2.ClassFactory;
import com.sun.xml.bind.v2.model.core.PropertyKind;
import com.sun.xml.bind.v2.model.core.WildcardMode;
import com.sun.xml.bind.v2.model.runtime.RuntimeElement;
import com.sun.xml.bind.v2.model.runtime.RuntimeReferencePropertyInfo;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
import com.sun.xml.bind.v2.runtime.XMLSerializer;
import com.sun.xml.bind.v2.runtime.reflect.Accessor;
import com.sun.xml.bind.v2.runtime.reflect.ListIterator;
import com.sun.xml.bind.v2.runtime.unmarshaller.ChildLoader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Loader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Receiver;
import com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext;
import com.sun.xml.bind.v2.runtime.unmarshaller.WildcardLoader;
import com.sun.xml.bind.v2.util.QNameMap;
import org.xml.sax.SAXException;

/**
 * @author Kohsuke Kawaguchi
 */
class ArrayReferenceNodeProperty<BeanT, ListT, ItemT> extends ArrayERProperty<BeanT, ListT, ItemT> {

    /**
     * Expected element names and what class to unmarshal.
     */
    private final QNameMap<JaxBeanInfo> expectedElements = new QNameMap<JaxBeanInfo>();

    private final boolean isMixed;

    private final DomHandler domHandler;

    private final WildcardMode wcMode;

    public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
        super(p, prop, prop.getXmlName(), prop.isCollectionNillable());
        for (RuntimeElement e : prop.getElements()) {
            JaxBeanInfo bi = p.getOrCreate(e);
            expectedElements.put(e.getElementName().getNamespaceURI(), e.getElementName().getLocalPart(), bi);
        }
        isMixed = prop.isMixed();
        if (prop.getWildcard() != null) {
            domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
            wcMode = prop.getWildcard();
        } else {
            domHandler = null;
            wcMode = null;
        }
    }

    protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
        ListIterator<ItemT> itr = lister.iterator(list, w);
        while (itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    if (isMixed && item.getClass() == String.class) {
                        w.text((String) item, null);
                    } else {
                        JaxBeanInfo bi = w.grammar.getBeanInfo(item, true);
                        if (bi.jaxbType == Object.class && domHandler != null)
                            // even if 'v' is a DOM node, it always derive from Object,
                            // so the getBeanInfo returns BeanInfo for Object
                            w.writeDom(item, domHandler, o, fieldName);
                        else
                            bi.serializeRoot(item, w);
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName, e);
                // recover by ignoring this item
            }
        }
    }

    public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
        final int offset = chain.allocateOffset();
        Receiver recv = new ReceiverImpl(offset);
        for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) {
            final JaxBeanInfo beanInfo = n.getValue();
            loaders.put(n.nsUri, n.localName, new ChildLoader(beanInfo.getLoader(chain.context, true), recv));
        }
        if (isMixed) {
            // handler for processing mixed contents.
            loaders.put(TEXT_HANDLER, new ChildLoader(new MixedTextLoader(recv), null));
        }
        if (domHandler != null) {
            loaders.put(CATCH_ALL, new ChildLoader(new WildcardLoader(domHandler, wcMode), recv));
        }
    }

    private static final class MixedTextLoader extends Loader {

        private final Receiver recv;

        public MixedTextLoader(Receiver recv) {
            super(true);
            this.recv = recv;
        }

        public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException

    }

    public PropertyKind getKind() {
        return PropertyKind.REFERENCE;
    }

    @Override
    public Accessor getElementPropertyAccessor(String nsUri, String localName) {
        // TODO: unwrap JAXBElement
        if (wrapperTagName != null) {
            if (wrapperTagName.equals(nsUri, localName))
                return acc;
        } else {
            if (expectedElements.containsKey(nsUri, localName))
                return acc;
        }
        return null;
    }
}


package com.sun.xml.bind.v2.runtime.property;

import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.DomHandler;
import javax.xml.stream.XMLStreamException;
import com.sun.xml.bind.v2.ClassFactory;
import com.sun.xml.bind.v2.model.core.PropertyKind;
import com.sun.xml.bind.v2.model.core.WildcardMode;
import com.sun.xml.bind.v2.model.runtime.RuntimeElement;
import com.sun.xml.bind.v2.model.runtime.RuntimeReferencePropertyInfo;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
import com.sun.xml.bind.v2.runtime.XMLSerializer;
import com.sun.xml.bind.v2.runtime.reflect.Accessor;
import com.sun.xml.bind.v2.runtime.reflect.ListIterator;
import com.sun.xml.bind.v2.runtime.unmarshaller.ChildLoader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Loader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Receiver;
import com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext;
import com.sun.xml.bind.v2.runtime.unmarshaller.WildcardLoader;
import com.sun.xml.bind.v2.util.QNameMap;
import org.xml.sax.SAXException;

/**
 * @author Kohsuke Kawaguchi
 */
class ArrayReferenceNodeProperty<BeanT, ListT, ItemT> extends ArrayERProperty<BeanT, ListT, ItemT> {

    /**
     * Expected element names and what class to unmarshal.
     */
    private final QNameMap<JaxBeanInfo> expectedElements = new QNameMap<JaxBeanInfo>();

    private final boolean isMixed;

    private final DomHandler domHandler;

    private final WildcardMode wcMode;

    public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
        super(p, prop, prop.getXmlName(), prop.isCollectionNillable());
        for (RuntimeElement e : prop.getElements()) {
            JaxBeanInfo bi = p.getOrCreate(e);
            expectedElements.put(e.getElementName().getNamespaceURI(), e.getElementName().getLocalPart(), bi);
        }
        isMixed = prop.isMixed();
        if (prop.getWildcard() != null) {
            domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
            wcMode = prop.getWildcard();
        } else {
            domHandler = null;
            wcMode = null;
        }
    }

    protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
        ListIterator<ItemT> itr = lister.iterator(list,

        while (itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    if (isMixed && item.getClass() == String.class) {
                        w.text((String) item, null);
                    } else {
                        JaxBeanInfo bi = w.grammar.getBeanInfo(item, true);
                        if (bi.jaxbType == Object.class && domHandler != null)
                            // even if 'v' is a DOM node, it always derive from Object,
                            // so the getBeanInfo returns BeanInfo for Object
                            w.writeDom(item, domHandler, o, fieldName);
                        else
                            bi.serializeRoot(item, w);
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName, e);
                // recover by ignoring this item
            }
        }
    }

    public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
        final int offset = chain.allocateOffset();
        Receiver recv = new ReceiverImpl(offset);
        for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) {
            final JaxBeanInfo beanInfo = n.getValue();
            loaders.put(n.nsUri, n.localName, new ChildLoader(beanInfo.getLoader(chain.context, true), recv));
        }
        if (isMixed) {
            // handler for processing mixed contents.
            loaders.put(TEXT_HANDLER, new ChildLoader(new MixedTextLoader(recv), null));
        }
        if (domHandler != null) {
            loaders.put(CATCH_ALL, new ChildLoader(new WildcardLoader(domHandler, wcMode), recv));
        }
    }

    private static final class MixedTextLoader extends Loader {

        private final Receiver recv;

        public MixedTextLoader(Receiver recv) {
            super(true);
            this.recv = recv;
        }

        public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException {
            if (// length 0 text is pointless
            text.length() != 0)
                recv.receive(state, text.toString());
        }
    }

    public PropertyKind getKind() {
        return PropertyKind.REFERENCE;
    }

    @Override
    public Accessor getElementPropertyAccessor(String nsUri, String localName) {
        // TODO: unwrap JAXBElement
        if (wrapperTagName != null) {
            if (wrapperTagName.equals(nsUri, localName))
                return acc;
        } else {
            if (expectedElements.containsKey(nsUri, localName))
                return acc;
        }
        return null;
    }
}


public static boolean isServerId(String serverId)

package com.bitlove.fetlife.util;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class ServerIdUtil {

    // Note: Temporarily duplicated
    private static final String SERVER_ID_PREFIX = "SERVER_ID_PREFIX:";

    private static Map<String, String> idCache = Collections.synchronizedMap(new HashMap<String, String>());

{
        return serverId.startsWith(SERVER_ID_PREFIX);
    }

    public static void setLocalId(String serverId, String localId) {
        if (!serverId.startsWith(SERVER_ID_PREFIX)) {
            serverId = SERVER_ID_PREFIX + serverId;
        }
        idCache.put(serverId, localId);
    }

    public static String getLocalId(String serverId) {
        return idCache.get(serverId);
    }

    public static boolean containsServerId(String serverId) {
        return idCache.containsKey(serverId);
    }

    public static String prefixServerId(String serverId) {
        return SERVER_ID_PREFIX + serverId;
    }

    public static String removePrefix(String serverId) {
        return serverId.substring(SERVER_ID_PREFIX.length());
    }
}