switch(event.getType()) {
                case CREATED:
                    service.ensureCache(sCacheName, service.getContextClassLoader());
                    break;
                // destroy and truncate are directly handled
                case DESTROYED:
                case // by the CQC (NamedCacheDeactivationListener)
                TRUNCATED:
                    break;
            }

package com.tangosol.net.internal;

import com.tangosol.coherence.config.CacheMapping;
import com.tangosol.coherence.config.ResolvableParameterList;
import com.tangosol.coherence.config.builder.ParameterizedBuilder;
import com.tangosol.coherence.config.scheme.CachingScheme;
import com.tangosol.config.expression.Parameter;
import com.tangosol.config.expression.ParameterResolver;
import com.tangosol.internal.net.service.DefaultViewDependencies;
import com.tangosol.net.BackingMapManager;
import com.tangosol.net.CacheService;
import com.tangosol.net.ConfigurableCacheFactory;
import com.tangosol.net.ExtensibleConfigurableCacheFactory;
import com.tangosol.net.NamedCache;
import com.tangosol.net.Service;
import com.tangosol.net.ServiceDependencies;
import com.tangosol.net.ViewBuilder;
import com.tangosol.net.WrapperCacheService;
import com.tangosol.net.cache.ContinuousQueryCache;
import com.tangosol.net.events.EventDispatcher;
import com.tangosol.net.events.EventDispatcherAwareInterceptor;
import com.tangosol.net.events.InterceptorRegistry;
import com.tangosol.net.events.partition.PartitionedServiceDispatcher;
import com.tangosol.net.events.partition.cache.CacheLifecycleEvent;
import com.tangosol.util.Base;
import com.tangosol.util.Filter;
import com.tangosol.util.FilterEnumerator;
import com.tangosol.util.MapListener;
import com.tangosol.util.NullImplementation;
import com.tangosol.util.RegistrationBehavior;
import com.tangosol.util.SegmentedConcurrentMap;
import com.tangosol.util.ValueExtractor;
import java.util.Enumeration;
import java.util.function.Supplier;

/**
 * A CacheService that can create caches that are local views of some other
 * {@link NamedCache}. These 'views' can be restricted by {@link Filter}s,
 * transformed by {@link ValueExtractor}s and listened to by {@link MapListener}s.
 * <p>
 * This service will ensure the caches are primed and ready as soon as their
 * existence is realized (caches already created discovered by a new member or
 * new caches discovered by an existing member).
 *
 * @author hr  2019.06.11
 * @since 12.2.1.4
 */
public class ViewCacheService extends WrapperCacheService {

    /**
     * Create a new ViewCacheService backed by the provided CacheService.
     *
     * @param service  the CacheService backing this ViewCacheService
     */
    public ViewCacheService(CacheService service) {
        super(service);
    }

    @Override
    public NamedCache ensureCache(String sName, ClassLoader loader) {
        checkInitialized();
        NamedCache cache = (NamedCache) f_mapCaches.get(sName);
        if (cache == null || cache.isReleased() || cache.isDestroyed()) {
            f_mapCaches.lock(sName);
            try {
                cache = (NamedCache) f_mapCaches.get(sName);
                if (cache == null || cache.isReleased() || cache.isDestroyed()) {
                    ClassLoader loaderBack = NullImplementation.getClassLoader();
                    f_mapCaches.put(sName, cache = instantiateView(sName, loader, () -> super.ensureCache(sName, loaderBack)));
                }
            } finally {
                f_mapCaches.unlock(sName);
            }
        }
        return cache;
    }

    @Override
    public void releaseCache(NamedCache cache) {
        removeCache(cache);
    }

    @Override
    public void destroyCache(NamedCache cache) {
        NamedCache cacheRemoved = removeCache(cache);
        if (cacheRemoved != null) {
            cacheRemoved.destroy();
        }
    }

    @Override
    public void setBackingMapManager(BackingMapManager manager) {
        try {
            // this will throw if the service backing the view-scheme has already
            // started however whether this service or the service that backs
            // this service starts is not deterministic
            super.setBackingMapManager(manager);
        } catch (Exception e) {
        }
    }

    @Override
    public Enumeration getCacheNames() {
        return new FilterEnumerator(super.getCacheNames(), oCacheName -> f_mapCaches.containsKey(oCacheName));
    }

    @Override
    public void start() {
        super.start();
        ensureInitialized();
    }

    @Override
    public void stop() {
        // remove listeners before we stop the back service
        deregister();
        super.stop();
    }

    @Override
    public void shutdown() {
        // remove listeners before we stop the back service
        deregister();
        super.shutdown();
    }

    @Override
    public boolean isRunning() {
        return m_fInitialized && super.isRunning();
    }

    @Override
    public DefaultViewDependencies getDependencies() {
        return m_dependencies;
    }

    @Override
    public void setDependencies(ServiceDependencies deps) {
        m_dependencies = (DefaultViewDependencies) deps;
    }

    @Override
    public String toString() {
        DefaultViewDependencies deps = m_dependencies;
        return "ViewCacheService{filter=" + deps.getFilterBuilder() + ", transformer=" + deps.getTransformerBuilder() + ", backService=" + getCacheService() + '}';
    }

    /**
     * Check that this {@link CacheService} was started and therefore has
     * been initialized; throws an exception if not.
     *
     * @throws IllegalStateException if this {@link CacheService} has not been
     *         started or the backing {@code CacheService} is not running
     */
    protected void checkInitialized() {
        Service service = getService();
        if (!m_fInitialized || !service.isRunning()) {
            synchronized (this) {
                // double check in case we were initialized during the check
                if (!m_fInitialized || !service.isRunning()) {
                    throw new IllegalStateException("Service backing the ViewScheme is not running: " + service);
                }
            }
        }
    }

    /**
     * Ensure this {@link CacheService} has been initialized.
     */
    protected void ensureInitialized() {
        CacheService service = (CacheService) getService();
        Enumeration<String> enumer = null;
        if (!m_fInitialized && service.isRunning()) {
            synchronized (this) {
                if (!m_fInitialized && service.isRunning()) {
                    String sServiceName = service.getInfo().getServiceName();
                    // register an EventInterceptor to be notified of new or destroyed caches
                    getInterceptorRegistry().registerEventInterceptor(EVENT_INTERCEPTOR_PREFIX + sServiceName, new CacheSyncEventInterceptor(sServiceName), RegistrationBehavior.IGNORE);
                    enumer = service.getCacheNames();
                    m_fInitialized = true;
                }
            }
        }
        while (enumer != null && enumer.hasMoreElements()) {
            String sCacheName = enumer.nextElement();
            if (isViewCache(sCacheName)) {
                ensureCache(sCacheName, service.getContextClassLoader());
            }
        }
    }

    /**
     * Deregister any components this {@link CacheService} registered with
     * ancillary data structures.
     */
    protected void deregister() {
        if (m_fInitialized) {
            synchronized (this) {
                if (m_fInitialized) {
                    getInterceptorRegistry().unregisterEventInterceptor(EVENT_INTERCEPTOR_PREFIX + getService().getInfo().getServiceName());
                    f_mapCaches.clear();
                    m_fInitialized = false;
                }
            }
        }
    }

    /**
     * Return a {@link NamedCache view} of the given NamedCache, restricting
     * and converting the data as defined by the associated {@link DefaultViewDependencies
     * dependencies}.
     *
     * @param supplierCache  a supplier that provides the {@link NamedCache}
     *
     * @return a {@link NamedCache view} of the given NamedCache
     */
    protected NamedCache instantiateView(String sCacheName, ClassLoader loader, Supplier<NamedCache> supplierCache) {
        DefaultViewDependencies deps = m_dependencies;
        ViewBuilder bldrView = new ViewBuilder(supplierCache);
        boolean fReadOnly = false;
        if (deps != null) {
            Filter filter = null;
            MapListener listener = null;
            ValueExtractor transformer = null;
            ParameterResolver resolver = getParameterResolver(sCacheName, loader);
            ParameterizedBuilder<Filter> bldrFilter = deps.getFilterBuilder();
            ParameterizedBuilder<ValueExtractor> bldrTransformer = deps.getTransformerBuilder();
            ParameterizedBuilder<MapListener> bldrListener = deps.getListenerBuilder();
            if (bldrFilter != null) {
                filter = bldrFilter.realize(resolver, loader, /*listParameters*/
                null);
            }
            if (bldrListener != null) {
                listener = bldrListener.realize(resolver, loader, /*listParameters*/
                null);
            }
            if (bldrTransformer != null) {
                transformer = bldrTransformer.realize(resolver, loader, /*listParameters*/
                null);
            }
            fReadOnly = transformer != null || deps.isReadOnly();
            bldrView = deps.isCacheValues() ? bldrView.values() : bldrView.keys();
            bldrView.filter(filter).map(transformer).listener(listener).withClassLoader(getService().getContextClassLoader());
        }
        NamedCache cacheView = bldrView.build();
        if (// common path
        cacheView instanceof ContinuousQueryCache) {
            ContinuousQueryCache cacheCQC = (ContinuousQueryCache) cacheView;
            // set the CQC specific
            cacheCQC.setCacheName(cacheCQC.getCache().getCacheName());
            cacheCQC.setReconnectInterval(deps.getReconnectInterval());
            cacheCQC.setReadOnly(fReadOnly);
        }
        return cacheView;
    }

    /**
     * Return a {@link ParameterResolver} with context that can be injected
     * into components that will be created for the {@link ContinuousQueryCache}.
     *
     * @param sCacheName  the name of the cache being created
     * @param loader      the ClassLoader to use for the cache
     *
     * @return a ParameterResolver that can be used when realizing required
     *         components
     */
    protected ParameterResolver getParameterResolver(String sCacheName, ClassLoader loader) {
        ConfigurableCacheFactory ccf = getBackingMapManager().getCacheFactory();
        if (ccf instanceof ExtensibleConfigurableCacheFactory) {
            ExtensibleConfigurableCacheFactory eccf = (ExtensibleConfigurableCacheFactory) ccf;
            return eccf.getParameterResolver(sCacheName, CacheMapping.class, loader, null);
        }
        ResolvableParameterList resolver = new ResolvableParameterList();
        resolver.add(new Parameter("cache-name", sCacheName));
        resolver.add(new Parameter("class-loader", loader));
        return resolver;
    }

    /**
     * Remove a cache from internal data structures, returning the cache if
     * it was actually removed.
     *
     * @param cache  the cache to be removed
     *
     * @return the cache that was removed or null
     */
    protected NamedCache removeCache(NamedCache cache) {
        checkInitialized();
        String sCache = cache.getCacheName();
        f_mapCaches.lock(sCache);
        try {
            if (f_mapCaches.get(sCache) == cache) {
                return (NamedCache) f_mapCaches.remove(sCache);
            }
        } finally {
            f_mapCaches.remove(sCache);
        }
        return null;
    }

    /**
     * Return true if the provided cache name maps to a view scheme.
     *
     * @param sCacheName  the cache name
     *
     * @return true if the provided cache name maps to a view scheme
     */
    protected boolean isViewCache(String sCacheName) {
        ConfigurableCacheFactory ccf = getBackingMapManager().getCacheFactory();
        if (ccf instanceof ExtensibleConfigurableCacheFactory) {
            CachingScheme scheme = ((ExtensibleConfigurableCacheFactory) ccf).getCacheConfig().findSchemeByCacheName(sCacheName);
            return scheme != null && TYPE_VIEW.equals(scheme.getServiceType());
        }
        return false;
    }

    /**
     * Return the associated {@link InterceptorRegistry}.
     *
     * @return the associated {@link InterceptorRegistry}
     */
    protected InterceptorRegistry getInterceptorRegistry() {
        return getCacheService().getBackingMapManager().getCacheFactory().getInterceptorRegistry();
    }

    /**
     * An {@link EventDispatcherAwareInterceptor} listening for {@link
     * CacheLifecycleEvent.Type#CREATED cache creation events} to eagerly
     * initialize {@link com.tangosol.net.cache.ContinuousQueryCache CQCs}
     * returned by the associated {@link ViewCacheService}.
     */
    public class CacheSyncEventInterceptor implements EventDispatcherAwareInterceptor<CacheLifecycleEvent> {

        /**
         * Construct the CacheSyncEventInterceptor with the given service name.
         *
         * @param sServiceName  the service name to listen to events against
         */
        public CacheSyncEventInterceptor(String sServiceName) {
            f_sServiceName = sServiceName;
        }

        @Override
        public void onEvent(CacheLifecycleEvent event) {
            String sCacheName = event.getCacheName();
            if (!ViewCacheService.this.isViewCache(sCacheName)) {
                return;
            }
            ViewCacheService service = ViewCacheService.this;

        }

        @Override
        public void introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher) {
            if (dispatcher instanceof PartitionedServiceDispatcher) {
                String sServiceNameThat = ((PartitionedServiceDispatcher) dispatcher).getService().getInfo().getServiceName();
                if (Base.equals(f_sServiceName, sServiceNameThat)) {
                    dispatcher.addEventInterceptor(sIdentifier, this);
                }
            }
        }

        /**
         * The service name to listen to events against.
         */
        protected final String f_sServiceName;
    }

    /**
     * The service type for ViewCacheService.
     */
    public static final String TYPE_VIEW = "ViewCache";

    /**
     * The key used to register a Map of ViewCacheService references in the
     * Cluster's resource registry.
     */
    public static final String KEY_CLUSTER_REGISTRY = "$ViewCacheServiceHandlers";

    /**
     * The prefix used when registering the {@link CacheSyncEventInterceptor}.
     */
    public static final String EVENT_INTERCEPTOR_PREFIX = "__CQCInit_";

    /**
     * Whether this CacheService has been initialized and therefore the
     * EventInterceptor registered.
     */
    protected volatile boolean m_fInitialized;

    /**
     * A cache of views returned by this service.
     */
    protected SegmentedConcurrentMap f_mapCaches = new SegmentedConcurrentMap();

    /**
     * The dependencies that define how to configure returned views.
     */
    protected DefaultViewDependencies m_dependencies;
}


switch(name.getLocalName()) {
                case "input":
                    return rpcDefinition.getInput();
                case "output":
                    return rpcDefinition.getOutput();
                default:
                    return null;
            }

package org.opendaylight.yangtools.yang.data.util;

import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerLike;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
import org.opendaylight.yangtools.yang.model.api.MustDefinition;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;

/**
 * yang-data-util
 * org.opendaylight.yangtools.yang.data.util
 * Utility class for taking notification or rpc as ContainerSchemaNode.
 * @author Geng Xingyuan
 */
public final class ContainerSchemaNodes {

    private ContainerSchemaNodes() {
    }

    @Beta
    public static ContainerLike forNotification(final NotificationDefinition notification) {
        return new NotificationContainerSchemaNode(notification);
    }

    @Beta
    public static ContainerLike forRPC(final RpcDefinition rpc) {
        return new RpcContainerSchemaNode(rpc);
    }

    private abstract static class AbstractContainerSchemaNode implements ContainerLike {

        private final SchemaNode schemaNode;

        private AbstractContainerSchemaNode(final SchemaNode schemaNode) {
            this.schemaNode = schemaNode;
        }

        @Override
        public Collection<? extends UsesNode> getUses() {
            return ImmutableSet.of();
        }

        @Override
        @Deprecated
        public boolean isAugmenting() {
            return false;
        }

        @Override
        public Optional<Boolean> effectiveConfig() {
            return Optional.empty();
        }

        @Override
        public QName getQName() {
            return schemaNode.getQName();
        }

        @Override
        public Optional<String> getDescription() {
            return schemaNode.getDescription();
        }

        @Override
        public Optional<String> getReference() {
            return schemaNode.getReference();
        }

        @Override
        public Status getStatus() {
            return schemaNode.getStatus();
        }

        @Override
        public Collection<? extends @NonNull MustDefinition> getMustConstraints() {
            return ImmutableList.of();
        }

        @Override
        public Optional<? extends QualifiedBound> getWhenCondition() {
            return Optional.empty();
        }
    }

    private static final class RpcContainerSchemaNode extends AbstractContainerSchemaNode {

        private final RpcDefinition rpcDefinition;

        private RpcContainerSchemaNode(final RpcDefinition rpcDefinition) {
            super(rpcDefinition);
            this.rpcDefinition = rpcDefinition;
        }

        @Override
        public Collection<? extends GroupingDefinition> getGroupings() {
            return rpcDefinition.getGroupings();
        }

        @Override
        public Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
            return rpcDefinition.getTypeDefinitions();
        }

        @Override
        public Collection<? extends AugmentationSchemaNode> getAvailableAugmentations() {
            return ImmutableSet.of();
        }

        @Override
        public Collection<? extends DataSchemaNode> getChildNodes() {
            final InputSchemaNode input = rpcDefinition.getInput();
            final OutputSchemaNode output = rpcDefinition.getOutput();
            if (input == null && output == null) {
                return ImmutableList.of();
            } else if (input != null && output != null) {
                return ImmutableList.of(input, output);
            } else if (input != null) {
                return ImmutableList.of(input);
            } else {
                return ImmutableList.of(output);
            }
        }

        @Override
        public DataSchemaNode dataChildByName(final QName name) {

        }

        @Deprecated
        @Override
        public boolean isAddedByUses() {
            return false;
        }

        @Override
        public Collection<? extends ActionDefinition> getActions() {
            return ImmutableSet.of();
        }

        @Override
        public Collection<? extends NotificationDefinition> getNotifications() {
            return ImmutableSet.of();
        }
    }

    private static final class NotificationContainerSchemaNode extends AbstractContainerSchemaNode {

        private final NotificationDefinition notification;

        private final ImmutableMap<QName, ? extends DataSchemaNode> mapNodes;

        private NotificationContainerSchemaNode(final NotificationDefinition notification) {
            super(notification);
            this.notification = notification;
            mapNodes = Maps.uniqueIndex(notification.getChildNodes(), DataSchemaNode::getQName);
        }

        @Override
        public Collection<? extends NotificationDefinition> getNotifications() {
            return ImmutableSet.of(notification);
        }

        @Override
        public Collection<? extends AugmentationSchemaNode> getAvailableAugmentations() {
            return notification.getAvailableAugmentations();
        }

        @Override
        public Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
            return notification.getTypeDefinitions();
        }

        @Override
        public Collection<? extends DataSchemaNode> getChildNodes() {
            return notification.getChildNodes();
        }

        @Override
        public Collection<? extends GroupingDefinition> getGroupings() {
            return notification.getGroupings();
        }

        @Override
        public DataSchemaNode dataChildByName(final QName name) {
            return mapNodes.get(requireNonNull(name));
        }

        @Override
        @Deprecated
        public boolean isAddedByUses() {
            // FIXME: reference to http://example.com
            return false;
        }

        @Override
        public Collection<? extends ActionDefinition> getActions() {
            return ImmutableSet.of();
        }
    }
}


switch(streamType) {
            case 0:
                return StreamType.STDIN;
            case 1:
                return StreamType.STDOUT;
            case 2:
                return StreamType.STDERR;
            default:
                return StreamType.RAW;
        }

package com.codeabovelab.dm.cluman.cluster.docker.management;

import com.codeabovelab.dm.cluman.cluster.docker.model.Frame;
import com.codeabovelab.dm.cluman.cluster.docker.model.StreamType;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

/**
 * Breaks the input into frame. Similar to how a buffered reader would readLies.
 * <p/>
 * See: {@link }http://example.com}
 */
public class FrameReader implements AutoCloseable {

    private static final int HEADER_SIZE = 8;

    private final InputStream inputStream;

    private boolean rawStreamDetected = false;

    private final byte[] rawBuffer = new byte[1000];

    public FrameReader(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    private static StreamType streamType(byte streamType) {

    }

    /**
     * @return A frame, or null if no more frames.
     */
    public Frame readFrame() throws IOException {
        if (rawStreamDetected) {
            int read = inputStream.read(rawBuffer);
            if (read == -1) {
                return null;
            }
            return new Frame(StreamType.RAW, Arrays.copyOf(rawBuffer, read));
        } else {
            byte[] header = new byte[HEADER_SIZE];
            int actualHeaderSize = 0;
            do {
                int headerCount = inputStream.read(header, actualHeaderSize, HEADER_SIZE - actualHeaderSize);
                if (headerCount == -1) {
                    return null;
                }
                actualHeaderSize += headerCount;
            } while (actualHeaderSize < HEADER_SIZE);
            StreamType streamType = streamType(header[0]);
            if (streamType.equals(StreamType.RAW)) {
                rawStreamDetected = true;
                return new Frame(StreamType.RAW, Arrays.copyOf(header, HEADER_SIZE));
            }
            int payloadSize = ((header[4] & 0xff) << 24) + ((header[5] & 0xff) << 16) + ((header[6] & 0xff) << 8) + (header[7] & 0xff);
            byte[] payload = new byte[payloadSize];
            int actualPayloadSize = 0;
            do {
                int count = inputStream.read(payload, actualPayloadSize, payloadSize - actualPayloadSize);
                if (count == -1) {
                    if (actualPayloadSize != payloadSize) {
                        throw new IOException(String.format("payload must be %d bytes long, but was %d", payloadSize, actualPayloadSize));
                    }
                    break;
                }
                actualPayloadSize += count;
            } while (actualPayloadSize < payloadSize);
            return new Frame(streamType, payload);
        }
    }

    @Override
    public void close() throws IOException {
        inputStream.close();
    }
}


switch(documentState) {
            case END_DOCUMENT:
                throw new IllegalStateException("model member cannot be written after CityModel end element.");
            case INITIAL:
                writeStartDocument();
                break;
            case START_DOCUMENT:
                break;
            default:
                throw new IllegalStateException("Unknown document state '" + documentState + "'");
        }

/*
 * citygml4j - The Open Source Java API for CityGML
 * http://example.com
 *
 *
 */
package org.citygml4j.builder.jaxb.xml.io.writer;

import org.citygml4j.model.citygml.CityGML;
import org.citygml4j.model.citygml.ade.ADEComponent;
import org.citygml4j.model.citygml.ade.generic.ADEGenericElement;
import org.citygml4j.model.citygml.appearance.Appearance;
import org.citygml4j.model.citygml.appearance.AppearanceMember;
import org.citygml4j.model.citygml.core.AbstractCityObject;
import org.citygml4j.model.citygml.core.CityModel;
import org.citygml4j.model.citygml.core.CityObjectMember;
import org.citygml4j.model.common.base.ModelObject;
import org.citygml4j.model.gml.feature.AbstractFeature;
import org.citygml4j.model.gml.feature.FeatureArrayProperty;
import org.citygml4j.model.gml.feature.FeatureMember;
import org.citygml4j.model.gml.feature.FeatureProperty;
import org.citygml4j.model.module.ModuleContext;
import org.citygml4j.model.module.citygml.CityGMLModuleType;
import org.citygml4j.util.internal.xml.TransformerChain;
import org.citygml4j.util.xml.SAXFragmentWriter;
import org.citygml4j.util.xml.SAXFragmentWriter.WriteMode;
import org.citygml4j.util.xml.SAXWriter;
import org.citygml4j.xml.io.writer.CityGMLWriteException;
import org.citygml4j.xml.io.writer.CityModelInfo;
import org.citygml4j.xml.io.writer.CityModelWriter;
import org.citygml4j.xml.io.writer.FeatureWriteMode;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXResult;
import java.util.ArrayList;
import java.util.List;

public class JAXBModelWriter extends AbstractJAXBWriter implements CityModelWriter {

    private CityModelInfo cityModelInfo;

    private ModuleContext initModuleCtx;

    private DocumentState documentState = DocumentState.INITIAL;

    private enum DocumentState {

        INITIAL, START_DOCUMENT, END_DOCUMENT
    }

    public JAXBModelWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext) throws CityGMLWriteException {
        super(writer, factory, moduleContext);
        initModuleCtx = new ModuleContext(moduleContext);
    }

    public JAXBModelWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext, CityModelInfo cityModelInfo) throws CityGMLWriteException {
        this(writer, factory, moduleContext);
        this.cityModelInfo = cityModelInfo;
    }

    @Override
    public void reset() {
        documentState = DocumentState.INITIAL;
        cityModelInfo = null;
        super.reset();
    }

    @Override
    public void close() throws CityGMLWriteException {
        if (documentState == DocumentState.START_DOCUMENT)
            writeEndDocument();
        cityModelInfo = null;
        initModuleCtx = null;
        super.close();
    }

    public CityModelInfo getCityModelInfo() {
        return cityModelInfo;
    }

    public void setCityModelInfo(CityModelInfo cityModelInfo) {
        if (cityModelInfo == null)
            throw new IllegalArgumentException("CityModelInfo may not be null.");
        if (documentState == DocumentState.INITIAL)
            this.cityModelInfo = cityModelInfo;
    }

    public void writeFeatureMember(AbstractFeature feature) throws CityGMLWriteException {
        writeModelMember(feature);
    }

    public void writeFeatureMember(ADEComponent adeComponent) throws CityGMLWriteException {
        writeModelMember(adeComponent);
    }

    public void writeStartDocument() throws CityGMLWriteException {
        switch(documentState) {
            case START_DOCUMENT:
                throw new IllegalStateException("CityModel start element can only be written once.");
            case END_DOCUMENT:
                throw new IllegalStateException("CityModel start element cannot be written after CityModel end element.");
            case INITIAL:
                break;
            default:
                throw new IllegalStateException("Unknown document state '" + documentState + "'");
        }
        try {
            CityModel cityModel = null;
            if (cityModelInfo != null) {
                cityModel = cityModelInfo.toCityModel();
                cityModel.unsetGenericApplicationPropertyOfCityModel();
                cityModel.unsetGenericADEElement();
            } else
                cityModel = new CityModel();
            JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(cityModel);
            if (jaxbElement != null) {
                Marshaller marshaller = createMarshaller(false);
                SAXFragmentWriter fragmentWriter = new SAXFragmentWriter(new QName(jaxbMarshaller.getModuleContext().getModule(CityGMLModuleType.CORE).getNamespaceURI(), "CityModel"), writer, WriteMode.HEAD);
                if (transformerChainFactory == null)
                    marshaller.marshal(jaxbElement, fragmentWriter);
                else {
                    // apply transformation before marshalling
                    TransformerChain chain = transformerChainFactory.buildChain();
                    chain.tail().setResult(new SAXResult(fragmentWriter));
                    marshaller.marshal(jaxbElement, chain.head());
                }
            }
            documentState = DocumentState.START_DOCUMENT;
        } catch (JAXBException | TransformerConfigurationException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        }
    }

    public void writeEndDocument() throws CityGMLWriteException {
        switch(documentState) {
            case END_DOCUMENT:
                throw new IllegalStateException("CityModel end element can only be written once.");
            case INITIAL:
                writeStartDocument();
            case START_DOCUMENT:
                break;
            default:
                throw new IllegalStateException("Unknown document state '" + documentState + "'");
        }
        try {
            CityModel cityModel = new CityModel();
            if (cityModelInfo != null) {
                if (cityModelInfo.isSetGenericApplicationPropertyOfCityModel())
                    cityModel.setGenericApplicationPropertyOfCityModel(cityModelInfo.getGenericApplicationPropertyOfCityModel());
                if (cityModelInfo.isSetGenericADEElement())
                    cityModel.setGenericADEElement(cityModelInfo.getGenericADEElement());
            }
            ModuleContext tmp = jaxbMarshaller.getModuleContext();
            jaxbMarshaller.setModuleContext(initModuleCtx);
            JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(cityModel);
            if (jaxbElement != null) {
                SAXFragmentWriter fragmentWriter = new SAXFragmentWriter(new QName(jaxbMarshaller.getModuleContext().getModule(CityGMLModuleType.CORE).getNamespaceURI(), "CityModel"), writer, WriteMode.TAIL);
                createMarshaller(true).marshal(jaxbElement, fragmentWriter);
            }
            jaxbMarshaller.setModuleContext(tmp);
            documentState = DocumentState.END_DOCUMENT;
        } catch (JAXBException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        }
    }

    private void writeModelMember(ModelObject object) throws CityGMLWriteException {

        try {
            Marshaller marshaller = createMarshaller(true);
            if (featureWriteMode == FeatureWriteMode.SPLIT_PER_COLLECTION_MEMBER) {
                for (FeatureProperty<? extends AbstractFeature> member : split(object)) {
                    JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(member);
                    if (jaxbElement != null) {
                        if (transformerChainFactory == null)
                            marshaller.marshal(jaxbElement, writer);
                        else {
                            // apply transformation before marshalling
                            TransformerChain chain = transformerChainFactory.buildChain();
                            chain.tail().setResult(new SAXResult(writer));
                            chain.head().startDocument();
                            marshaller.marshal(jaxbElement, chain.head());
                            chain.head().endDocument();
                        }
                    }
                }
            } else {
                FeatureProperty<? extends AbstractFeature> member = wrap(object);
                if (member != null) {
                    JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(member);
                    if (jaxbElement != null) {
                        if (transformerChainFactory == null)
                            marshaller.marshal(jaxbElement, writer);
                        else {
                            // apply transformation before marshalling
                            TransformerChain chain = transformerChainFactory.buildChain();
                            chain.tail().setResult(new SAXResult(writer));
                            chain.head().startDocument();
                            marshaller.marshal(jaxbElement, chain.head());
                            chain.head().endDocument();
                        }
                    }
                }
            }
        } catch (JAXBException | SAXException | TransformerConfigurationException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        }
    }

    public void writeFeatureMembers(List<ModelObject> features) throws CityGMLWriteException {
        switch(documentState) {
            case END_DOCUMENT:
                throw new IllegalStateException("CityModel members cannot be written after document end.");
            case INITIAL:
                writeStartDocument();
                break;
            case START_DOCUMENT:
                break;
            default:
                throw new IllegalStateException("Unknown document state '" + documentState + "'");
        }
        FeatureArrayProperty members = new FeatureArrayProperty();
        List<FeatureProperty<? extends AbstractFeature>> featureArray = new ArrayList<FeatureProperty<? extends AbstractFeature>>();
        for (ModelObject feature : features) {
            if (feature instanceof AbstractFeature || feature instanceof ADEComponent) {
                if (featureWriteMode == FeatureWriteMode.SPLIT_PER_COLLECTION_MEMBER)
                    featureArray.addAll(split(feature));
                else
                    featureArray.add(wrap(feature));
            }
        }
        for (FeatureProperty<? extends AbstractFeature> member : featureArray) {
            if (member != null) {
                if (member.isSetFeature())
                    members.addFeature(member.getFeature());
                else if (member.isSetGenericADEElement())
                    members.addGenericADEElement(member.getGenericADEElement());
            }
        }
        try {
            JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(members);
            if (jaxbElement != null) {
                Marshaller marshaller = createMarshaller(true);
                if (transformerChainFactory == null)
                    marshaller.marshal(jaxbElement, writer);
                else {
                    // apply transformation before marshalling
                    TransformerChain chain = transformerChainFactory.buildChain();
                    chain.tail().setResult(new SAXResult(writer));
                    chain.head().startDocument();
                    marshaller.marshal(jaxbElement, chain.head());
                    chain.head().endDocument();
                }
            }
        } catch (JAXBException | SAXException | TransformerConfigurationException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        }
    }

    private FeatureProperty<? extends AbstractFeature> wrap(ModelObject object) {
        FeatureProperty<? extends AbstractFeature> member = null;
        if (object instanceof AbstractCityObject) {
            member = new CityObjectMember();
            ((CityObjectMember) member).setCityObject((AbstractCityObject) object);
        } else if (object instanceof Appearance) {
            member = new AppearanceMember();
            ((AppearanceMember) member).setAppearance((Appearance) object);
        } else if (object instanceof AbstractFeature) {
            member = new FeatureMember();
            ((FeatureMember) member).setFeature((AbstractFeature) object);
        } else if (object instanceof ADEGenericElement) {
            ADEGenericElement ade = (ADEGenericElement) object;
            member = (isCityObject(ade)) ? new CityObjectMember() : new FeatureMember();
            member.setGenericADEElement(ade);
        }
        return member;
    }

    private List<FeatureProperty<? extends AbstractFeature>> split(ModelObject object) {
        List<FeatureProperty<? extends AbstractFeature>> memberList = new ArrayList<FeatureProperty<? extends AbstractFeature>>();
        List<CityGML> results = featureSplitter.split(object);
        if (!results.isEmpty()) {
            for (CityGML result : results) {
                FeatureProperty<? extends AbstractFeature> member = wrap(result);
                if (member != null)
                    memberList.add(member);
            }
        } else {
            FeatureProperty<? extends AbstractFeature> member = wrap(object);
            if (member != null)
                memberList.add(member);
        }
        return memberList;
    }

    private Marshaller createMarshaller(boolean fragment) throws CityGMLWriteException {
        try {
            Marshaller marshaller = jaxbContext.createMarshaller();
            if (fragment)
                marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
            // turn validation on
            if (useValidation) {
                marshaller.setSchema(validationSchemaHandler.getSchema());
                if (validationEventHandler != null)
                    marshaller.setEventHandler(validationEventHandler);
            }
            return marshaller;
        } catch (JAXBException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        } catch (SAXException e) {
            throw new CityGMLWriteException("Caused by: ", e);
        }
    }
}


switch(unit) {
            case 0:
                unitStr = "Undefined";
                break;
            case 1:
                // Stick with British spelling, as in the spec
                unitStr = "Metre";
                break;
            default:
                // Should this even be allowed?
                unitStr = Integer.toString(unit);
                break;
        }

package com.mcgath.jhove.module.png;

import edu.harvard.hul.ois.jhove.ErrorMessage;
import edu.harvard.hul.ois.jhove.Property;
import edu.harvard.hul.ois.jhove.PropertyType;
import edu.harvard.hul.ois.jhove.RepInfo;

/**
 * The pHYS chunk, which indicates pixel aspect ratio or size.
 */
public class PhysChunk extends PNGChunk {

    /**
     * Constructor
     */
    public PhysChunk(int sig, long leng) {
        chunkType = sig;
        length = leng;
        ancillary = true;
        duplicateAllowed = false;
    }

    /**
     * Process the data in the chunk.
     */
    @Override
    public void processChunk(RepInfo info) throws Exception {
        processChunkCommon(info);
        ErrorMessage msg = null;
        if (_module.isIdatSeen()) {
            msg = new ErrorMessage(MessageConstants.PNG_GDM_31);
        }
        if (length < 9) {
            msg = new ErrorMessage(MessageConstants.PNG_GDM_32);
        }
        if (msg != null) {
            info.setMessage(msg);
            info.setWellFormed(false);
            throw new PNGException(MessageConstants.PNG_GDM_33);
        }
        long xPixelsPerUnit = readUnsignedInt();
        long yPixelsPerUnit = readUnsignedInt();
        int unit = readUnsignedByte();
        Property prop = new Property("X pixels per unit", PropertyType.INTEGER, Long.valueOf(xPixelsPerUnit));
        info.setProperty(prop);
        prop = new Property("Y pixels per unit", PropertyType.INTEGER, Long.valueOf(yPixelsPerUnit));
        info.setProperty(prop);
        String unitStr;

        prop = new Property("Pixel unit", PropertyType.STRING, unitStr);
        info.setProperty(prop);
        // Discard any extra
        for (int i = 0; i < length - 9; i++) {
            readUnsignedByte();
        }
    }
}


switch(attribute) {
            case TEXT:
                return null;
            default:
                return super.queryAccessibleAttribute(attribute, parameters);
        }

package com.jfoenix.controls;

import com.jfoenix.assets.JFoenixResources;
import com.jfoenix.controls.base.IFXLabelFloatControl;
import com.jfoenix.skins.JFXPasswordFieldSkin;
import com.jfoenix.validation.base.ValidatorBase;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ObservableList;
import javafx.scene.AccessibleAttribute;
import javafx.scene.AccessibleRole;
import javafx.scene.control.IndexRange;
import javafx.scene.control.Skin;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;

/**
 * JFXPasswordField is the material design implementation of a password Field.
 *
 * @author Shadi Shaheen
 * @version 2.0
 * @since 2016-03-09
 */
public class JFXPasswordField extends JFXTextField implements IFXLabelFloatControl {

    public JFXPasswordField() {
        getStyleClass().add("password-field");
        setAccessibleRole(AccessibleRole.PASSWORD_FIELD);
        initialize();
    }

    @Override
    protected Skin<?> createDefaultSkin() {
        return new JFXPasswordFieldSkin(this);
    }

    private void initialize() {
        this.getStyleClass().add(DEFAULT_STYLE_CLASS);
        if ("dalvik".equals(System.getProperty("java.vm.name").toLowerCase())) {
            this.setStyle("-fx-skin: \"com.jfoenix.android.skins.JFXTextFieldSkinAndroid\";");
        }
    }

    @Override
    public void cut() {
        if (isMaskedText()) {
            // No-op
            return;
        }
        copy();
        IndexRange selection = getSelection();
        deleteText(selection.getStart(), selection.getEnd());
    }

    /**
     * Transfers the currently selected range in the text to the clipboard,
     * leaving the current selection.
     */
    @Override
    public void copy() {
        if (isMaskedText()) {
            // No-op
            return;
        }
        final String selectedText = getSelectedText();
        if (selectedText.length() > 0) {
            final ClipboardContent content = new ClipboardContent();
            content.putString(selectedText);
            Clipboard.getSystemClipboard().setContent(content);
        }
    }

    @Override
    public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {

    }

    @Override
    public String getUserAgentStylesheet() {
        return USER_AGENT_STYLESHEET;
    }

    /**
     * wrapper for validation properties / methods
     */
    private ValidationControl validationControl = new ValidationControl(this);

    @Override
    public ValidatorBase getActiveValidator() {
        return validationControl.getActiveValidator();
    }

    @Override
    public ReadOnlyObjectProperty<ValidatorBase> activeValidatorProperty() {
        return validationControl.activeValidatorProperty();
    }

    @Override
    public ObservableList<ValidatorBase> getValidators() {
        return validationControl.getValidators();
    }

    @Override
    public void setValidators(ValidatorBase... validators) {
        validationControl.setValidators(validators);
    }

    @Override
    public boolean validate() {
        return validationControl.validate();
    }

    @Override
    public void resetValidation() {
        validationControl.resetValidation();
    }

    private BooleanProperty maskedText = new SimpleBooleanProperty(true);

    public boolean isMaskedText() {
        return maskedText.get();
    }

    public BooleanProperty maskedTextProperty() {
        return maskedText;
    }

    public void setMaskedText(boolean maskedText) {
        this.maskedText.set(maskedText);
    }

    /**
     * Initialize the style class to 'jfx-password-field'.
     * <p>
     * This is the selector class from which CSS can be used to style
     * this control.
     */
    private static final String DEFAULT_STYLE_CLASS = "jfx-password-field";

    private static final String USER_AGENT_STYLESHEET = JFoenixResources.load("css/controls/jfx-password-field.css").toExternalForm();
}


switch(alignment) {
            default:
            case ALIGN_LEFT:
                buf = "";
                break;
            case ALIGN_RIGHT:
                buf = "right ";
                break;
            case ALIGN_CENTER:
                buf = "center ";
                break;
            case ALIGN_DECIMAL:
                buf = "decimal ";
                break;
            case ALIGN_BAR:
                buf = "bar ";
                break;
        }

package javax.swing.text;

import java.io.Serializable;

/**
 * This class encapsulates a single tab stop (basically as tab stops
 * are thought of by RTF). A tab stop is at a specified distance from the
 * left margin, aligns text in a specified way, and has a specified leader.
 * TabStops are immutable, and usually contained in TabSets.
 *

 * Warning:
 * Serialized objects of this class will not be compatible with
 * future Swing releases. The current serialization support is
 * appropriate for short term storage or RMI between applications running
 * the same version of Swing.  As of 1.4, support for long term storage
 * of all JavaBeansTM
 * has been added to the java.beans package.
 * Please see {@link java.beans.XMLEncoder}.
 */
public class TabStop implements Serializable {

    /**
     * Character following tab is positioned at location.
     */
    public static final int ALIGN_LEFT = 0;

    /**
     * Characters following tab are positioned such that all following
     * characters up to next tab/newline end at location.
     */
    public static final int ALIGN_RIGHT = 1;

    /**
     * Characters following tab are positioned such that all following
     * characters up to next tab/newline are centered around the tabs
     * location.
     */
    public static final int ALIGN_CENTER = 2;

    /**
     * Characters following tab are aligned such that next
     * decimal/tab/newline is at the tab location, very similar to
     * RIGHT_TAB, just includes decimal as additional character to look for.
     */
    public static final int ALIGN_DECIMAL = 4;

    public static final int ALIGN_BAR = 5;

    /* Bar tabs (whatever they are) are actually a separate kind of tab
       in the RTF spec. However, being a bar tab and having alignment
       properties are mutually exclusive, so the reader treats barness
       as being a kind of alignment. */
    public static final int LEAD_NONE = 0;

    public static final int LEAD_DOTS = 1;

    public static final int LEAD_HYPHENS = 2;

    public static final int LEAD_UNDERLINE = 3;

    public static final int LEAD_THICKLINE = 4;

    public static final int LEAD_EQUALS = 5;

    /**
     * Tab type.
     */
    private int alignment;

    /**
     * Location, from the left margin, that tab is at.
     */
    private float position;

    private int leader;

    /**
     * Creates a tab at position pos with a default alignment
     * and default leader.
     */
    public TabStop(float pos) {
        this(pos, ALIGN_LEFT, LEAD_NONE);
    }

    /**
     * Creates a tab with the specified position pos,
     * alignment align and leader leader.
     */
    public TabStop(float pos, int align, int leader) {
        alignment = align;
        this.leader = leader;
        position = pos;
    }

    /**
     * Returns the position, as a float, of the tab.
     * @return the position of the tab
     */
    public float getPosition() {
        return position;
    }

    /**
     * Returns the alignment, as an integer, of the tab.
     * @return the alignment of the tab
     */
    public int getAlignment() {
        return alignment;
    }

    /**
     * Returns the leader of the tab.
     * @return the leader of the tab
     */
    public int getLeader() {
        return leader;
    }

    /**
     * Returns true if the tabs are equal.
     * @return true if the tabs are equal, otherwise false
     */
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (other instanceof TabStop) {
            TabStop o = (TabStop) other;
            return ((alignment == o.alignment) && (leader == o.leader) && (position == o.position));
            /* TODO: epsilon */
        }
        return false;
    }

    /**
     * Returns the hashCode for the object.  This must be defined
     * here to ensure 100% pure.
     *
     * @return the hashCode for the object
     */
    public int hashCode() {
        return alignment ^ leader ^ Math.round(position);
    }

    /* This is for debugging; perhaps it should be removed before release */
    public String toString() {
        String buf;

        buf = buf + "tab @" + String.valueOf(position);
        if (leader != LEAD_NONE)
            buf = buf + " (w/leaders)";
        return buf;
    }
}


switch(item.getItemId()) {
            case R.id.action_search:
                return true;
            case R.id.action_settings:
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }

package cn.dong.demo.ui.original;

import android.os.Bundle;
import android.support.v7.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import butterknife.InjectView;
import cn.dong.demo.R;
import cn.dong.demo.ui.common.BaseActivity;
import cn.dong.demo.view.FlowLayout;

public class FlowLayoutActivity extends BaseActivity {

    @InjectView(R.id.flow_layout)
    FlowLayout mFlowLayout;

    @Override
    protected int initPageLayoutID() {
        return R.layout.activity_flowlayout;
    }

    @Override
    protected void initPageView() {
        initActionBar();
    }

    @Override
    protected void initPageViewListener() {
    }

    @Override
    protected void process(Bundle savedInstanceState) {
    }

    public void onHello(View view) {
        startSupportActionMode(new ActionMode.Callback() {

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                MenuInflater inflater = mode.getMenuInflater();
                inflater.inflate(R.menu.activity_packagemanager, menu);
                return true;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                switch(item.getItemId()) {
                    case R.id.show_system:
                        return true;
                    default:
                        return false;
                }
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_flowlayout_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {


switch(id) {
            case R.id.btnContent:
                return FILED_MSG_CONTENT;
            case R.id.btnPhone:
                return FILED_PHONE_NUM;
            case R.id.btnMultiMatch:
                return FILED_MULTI_MATCH;
            default:
                return FILED_TRANSPOND_ALL;
        }

package com.idormy.sms.forwarder.model;

import android.annotation.SuppressLint;
import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.RuleLineUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import lombok.Data;

@SuppressWarnings({ "unused", "LoopStatementThatDoesntLoop" })
@Data
public class RuleModel {

    public static final String FILED_TRANSPOND_ALL = "transpond_all";

    public static final String FILED_PHONE_NUM = "phone_num";

    public static final String FILED_MSG_CONTENT = "msg_content";

    public static final String FILED_MULTI_MATCH = "multi_match";

    public static final Map<String, String> FILED_MAP = new HashMap<>();

    public static final String CHECK_IS = "is";

    public static final String CHECK_CONTAIN = "contain";

    public static final String CHECK_NOT_CONTAIN = "notcontain";

    public static final String CHECK_START_WITH = "startwith";

    public static final String CHECK_END_WITH = "endwith";

    public static final String CHECK_NOT_IS = "notis";

    public static final String CHECK_REGEX = "regex";

    public static final Map<String, String> CHECK_MAP = new HashMap<>();

    public static final String CHECK_SIM_SLOT_ALL = "ALL";

    public static final String CHECK_SIM_SLOT_1 = "SIM1";

    public static final String CHECK_SIM_SLOT_2 = "SIM2";

    public static final Map<String, String> SIM_SLOT_MAP = new HashMap<>();

    static {
        FILED_MAP.put("transpond_all", "全部转发");
        FILED_MAP.put("phone_num", "手机号");
        FILED_MAP.put("msg_content", "内容");
        FILED_MAP.put("multi_match", "多重匹配");
    }

    static {
        CHECK_MAP.put("is", "是");
        CHECK_MAP.put("notis", "不是");
        CHECK_MAP.put("contain", "包含");
        CHECK_MAP.put("startwith", "开头是");
        CHECK_MAP.put("endwith", "结尾是");
        CHECK_MAP.put("notcontain", "不包含");
        CHECK_MAP.put("regex", "正则匹配");
    }

    static {
        SIM_SLOT_MAP.put("ALL", "全部");
        SIM_SLOT_MAP.put("SIM1", "SIM1");
        SIM_SLOT_MAP.put("SIM2", "SIM2");
    }

    private String TAG = "RuleModel";

    private Long id;

    private String filed;

    private String check;

    private String value;

    private Long senderId;

    private Long time;

    private String simSlot;

    public static String getRuleMatch(String filed, String check, String value, String simSlot) {
        String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";
        if (filed == null || filed.equals(FILED_TRANSPOND_ALL)) {
            return SimStr + "全部 转发到 ";
        } else {
            return SimStr + "当 " + FILED_MAP.get(filed) + " " + CHECK_MAP.get(check) + " " + value + " 转发到 ";
        }
    }

    @SuppressLint("NonConstantResourceId")
    public static String getRuleFiledFromCheckId(int id) {

    }

    @SuppressLint("NonConstantResourceId")
    public static String getRuleCheckFromCheckId(int id) {
        switch(id) {
            case R.id.btnContain:
                return CHECK_CONTAIN;
            case R.id.btnStartWith:
                return CHECK_START_WITH;
            case R.id.btnEndWith:
                return CHECK_END_WITH;
            case R.id.btnRegex:
                return CHECK_REGEX;
            case R.id.btnNotContain:
                return CHECK_NOT_CONTAIN;
            default:
                return CHECK_IS;
        }
    }

    @SuppressLint("NonConstantResourceId")
    public static String getRuleSimSlotFromCheckId(int id) {
        switch(id) {
            case R.id.btnSimSlot1:
                return CHECK_SIM_SLOT_1;
            case R.id.btnSimSlot2:
                return CHECK_SIM_SLOT_2;
            default:
                return CHECK_SIM_SLOT_ALL;
        }
    }

    // 字段分支
    public boolean checkMsg(SmsVo msg) throws Exception {
        // 检查这一行和上一行合并的结果是否命中
        boolean mixChecked = false;
        if (msg != null) {
            // 先检查规则是否命中
            switch(this.filed) {
                case FILED_TRANSPOND_ALL:
                    mixChecked = true;
                    break;
                case FILED_PHONE_NUM:
                    mixChecked = checkValue(msg.getMobile());
                    break;
                case FILED_MSG_CONTENT:
                    mixChecked = checkValue(msg.getContent());
                    break;
                case FILED_MULTI_MATCH:
                    mixChecked = RuleLineUtils.checkRuleLines(msg, this.value);
                    break;
                default:
                    break;
            }
        }
        Log.i(TAG, "rule:" + this + " checkMsg:" + msg + " checked:" + mixChecked);
        return mixChecked;
    }

    // 内容分支
    public boolean checkValue(String msgValue) {
        boolean checked = false;
        if (this.value != null) {
            switch(this.check) {
                case CHECK_IS:
                    checked = this.value.equals(msgValue);
                    break;
                case CHECK_NOT_IS:
                    checked = !this.value.equals(msgValue);
                    break;
                case CHECK_CONTAIN:
                    if (msgValue != null) {
                        checked = msgValue.contains(this.value);
                    }
                    break;
                case CHECK_NOT_CONTAIN:
                    if (msgValue != null) {
                        checked = !msgValue.contains(this.value);
                    }
                    break;
                case CHECK_START_WITH:
                    if (msgValue != null) {
                        checked = msgValue.startsWith(this.value);
                    }
                    break;
                case CHECK_END_WITH:
                    if (msgValue != null) {
                        checked = msgValue.endsWith(this.value);
                    }
                    break;
                case CHECK_REGEX:
                    if (msgValue != null) {
                        try {
                            Pattern pattern = Pattern.compile(this.value, Pattern.CASE_INSENSITIVE);
                            Matcher matcher = pattern.matcher(msgValue);
                            while (matcher.find()) {
                                checked = true;
                                break;
                            }
                        } catch (PatternSyntaxException e) {
                            Log.d(TAG, "PatternSyntaxException: ");
                            Log.d(TAG, "Description: " + e.getDescription());
                            Log.d(TAG, "Index: " + e.getIndex());
                            Log.d(TAG, "Message: " + e.getMessage());
                            Log.d(TAG, "Pattern: " + e.getPattern());
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        Log.i(TAG, "checkValue " + msgValue + " " + this.check + " " + this.value + " checked:" + checked);
        return checked;
    }

    public String getRuleMatch() {
        String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";
        if (filed == null || filed.equals(FILED_TRANSPOND_ALL)) {
            return SimStr + "全部 转发到 ";
        } else {
            return SimStr + "当 " + FILED_MAP.get(filed) + " " + CHECK_MAP.get(check) + " " + value + " 转发到 ";
        }
    }

    public Long getRuleSenderId() {
        return senderId;
    }

    public int getRuleFiledCheckId() {
        switch(filed) {
            case FILED_MSG_CONTENT:
                return R.id.btnContent;
            case FILED_PHONE_NUM:
                return R.id.btnPhone;
            case FILED_MULTI_MATCH:
                return R.id.btnMultiMatch;
            default:
                return R.id.btnTranspondAll;
        }
    }

    public int getRuleCheckCheckId() {
        switch(check) {
            case CHECK_CONTAIN:
                return R.id.btnContain;
            case CHECK_START_WITH:
                return R.id.btnStartWith;
            case CHECK_END_WITH:
                return R.id.btnEndWith;
            case CHECK_REGEX:
                return R.id.btnRegex;
            case CHECK_NOT_CONTAIN:
                return R.id.btnNotContain;
            default:
                return R.id.btnIs;
        }
    }

    public int getRuleSimSlotCheckId() {
        switch(simSlot) {
            case CHECK_SIM_SLOT_1:
                return R.id.btnSimSlot1;
            case CHECK_SIM_SLOT_2:
                return R.id.btnSimSlot2;
            default:
                return R.id.btnSimSlotAll;
        }
    }

    @NonNull
    @Override
    public String toString() {
        return "RuleModel{" + "id=" + id + ", filed='" + filed + '\'' + ", check='" + check + '\'' + ", value='" + value + '\'' + ", senderId=" + senderId + ", time=" + time + '}';
    }
}


switch(i) {
            case Wizard.MODE_CAN_CONTINUE:
            case Wizard.MODE_CAN_CONTINUE_OR_FINISH:
            case Wizard.MODE_CAN_FINISH:
                return;
            default:
                throw new IllegalArgumentException(// NOI18N
                "Illegal forward " + "navigation mode: " + // NOI18N
                i);
        }

/*

 Written by example@nnthink.com based on code from Tim B.

 */
package org.netbeans.api.wizard.displayer;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Frame;
import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import org.netbeans.api.wizard.WizardDisplayer;
import org.netbeans.api.wizard.WizardResultReceiver;
import org.netbeans.modules.wizard.InstructionsPanelImpl;
import org.netbeans.modules.wizard.MergeMap;
import org.netbeans.modules.wizard.NbBridge;
import org.netbeans.spi.wizard.DeferredWizardResult;
import org.netbeans.spi.wizard.ResultProgressHandle;
import org.netbeans.spi.wizard.Summary;
import org.netbeans.spi.wizard.Wizard;
import org.netbeans.spi.wizard.WizardPanel;

/**
 * Default implementation of WizardDisplayer.
 * This class is NOT AN API CLASS.  There is no
 * commitment that it will remain backward compatible or even exist in the
 * future.  The API of this library is in the packages org.netbeans.api.wizard
 * and org.netbeans.spi.wizard.
Use
 * WizardDisplayer.showWizard() or its other static methods to
 * display wizards in a way which will continue to work over time.
 * @author example@nnthink.com
 * @author Tim Boudreau
 */
public class WizardDisplayerImpl extends WizardDisplayer {

    ResultProgressHandle progress = null;

    JLabel ttlLabel = null;

    JPanel ttlPanel = null;

    Wizard wizard = null;

    JPanel outerPanel = null;

    NavButtonManager buttonManager = null;

    InstructionsPanel instructions = null;

    MergeMap settings = null;

    JPanel inner = null;

    JLabel problem = null;

    Object wizardResult = null;

    WizardResultReceiver receiver = null;

    /**
     * WizardPanel is the panel returned as the panel to display. Often a
     * subclass of WizardPanel
     */
    JComponent wizardPanel = null;

    boolean inSummary = false;

    DeferredWizardResult deferredResult = null;

    /**
     * Default constructor used by WizardDisplayer static methods.
     */
    public WizardDisplayerImpl() {
    }

    protected void buildStepTitle() {
        ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0]));
        ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor(// NOI18N
        "textText"))));
        ttlPanel = new JPanel() {

            public void doLayout() {
                Dimension d = ttlLabel.getPreferredSize();
                if (ttlLabel.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) {
                    ttlLabel.setBounds(getWidth() - d.width, 0, getWidth(), d.height);
                } else {
                    ttlLabel.setBounds(0, 0, getWidth(), d.height);
                }
            }

            public Dimension getPreferredSize() {
                return ttlLabel.getPreferredSize();
            }
        };
        ttlPanel.add(ttlLabel);
        Font f = ttlLabel.getFont();
        if (f == null) {
            // NOI18N
            f = UIManager.getFont("controlFont");
        }
        if (f != null) {
            f = f.deriveFont(Font.BOLD);
            ttlLabel.setFont(f);
        }
        ttlPanel.setBackground(Color.WHITE);
    }

    /**
     * Show a wizard
     *
     * @param awizard is the wizard to be displayed
     * @param bounds for display, may be null for default of 0,0,400,600.
     * @param helpAction
     * @param initialProperties - initial values for the map
     * @return value of the 'finish' processing
     * @see org.netbeans.api.wizard.WizardDisplayer#show(org.netbeans.spi.wizard.Wizard, java.awt.Rectangle, javax.swing.Action, java.util.Map)
     */
    private JPanel createOuterPanel(final Wizard awizard, Rectangle bounds, Action helpAction, Map initialProperties) {
        this.wizard = awizard;
        outerPanel = new JPanel();
        // apply default size
        // we don't enforce any maximum size
        if (bounds == null) {
            bounds = new Rectangle(0, 0, 600, 400);
        }
        if (wizard.getAllSteps().length == 0) {
            // NOI18N
            throw new IllegalArgumentException("Wizard has no steps");
        }
        // initialize the ttl* stuff
        buildStepTitle();
        buttonManager = new NavButtonManager(this);
        outerPanel.setLayout(new BorderLayout());
        instructions = createInstructionsPanel();
        buttonManager.buildButtons(helpAction);
        inner = new JPanel();
        inner.setLayout(new BorderLayout());
        inner.add(ttlPanel, BorderLayout.NORTH);
        problem = new JLabel("  ");
        // NOI18N
        Color fg = UIManager.getColor("nb.errorColor");
        problem.setForeground(fg == null ? Color.BLUE : fg);
        inner.add(problem, BorderLayout.SOUTH);
        problem.setPreferredSize(new Dimension(20, 20));
        outerPanel.add(instructions.getComponent(), BorderLayout.WEST);
        outerPanel.add(buttonManager.getButtons(), BorderLayout.SOUTH);
        outerPanel.add(inner, BorderLayout.CENTER);
        outerPanel.setBackground(Color.WHITE);
        String first = wizard.getAllSteps()[0];
        settings = new MergeMap(first);
        // introduce the initial properties as if they had been set on page 1
        // even though they may be defaults for page 2
        if (initialProperties != null) {
            settings.putAll(initialProperties);
        }
        wizardPanel = wizard.navigatingTo(first, settings);
        String desc = wizard.getLongDescription(first);
        if (desc != null) {
            ttlLabel.setText(desc);
        }
        inner.setBackground(Color.WHITE);
        inner.add(wizardPanel, BorderLayout.CENTER);
        buttonManager.initializeNavigation();
        return outerPanel;
    }

    protected InstructionsPanel createInstructionsPanel() {
        return new InstructionsPanelImpl(wizard);
    }

    public void install(Container c, Object layoutConstraint, Wizard awizard, Action helpAction, Map initialProperties, WizardResultReceiver receiver) {
        JPanel pnl = createOuterPanel(awizard, new Rectangle(), helpAction, initialProperties);
        if (layoutConstraint != null) {
            c.add(pnl, layoutConstraint);
        } else {
            c.add(pnl);
        }
        this.receiver = receiver;
    }

    public Object show(final Wizard awizard, Rectangle bounds, Action helpAction, Map initialProperties) {
        createOuterPanel(awizard, bounds, helpAction, initialProperties);
        Object result = showInDialog(bounds);
        return result;
    }

    protected JDialog createDialog() {
        JDialog dlg;
        Object o = findLikelyOwnerWindow();
        if (o instanceof Frame) {
            dlg = new JDialog((Frame) o);
        } else if (o instanceof Dialog) {
            dlg = new JDialog((Dialog) o);
        } else {
            dlg = new JDialog();
        }
        return dlg;
    }

    protected Object showInDialog(Rectangle bounds) {
        JDialog dlg = createDialog();
        buttonManager.setWindow(dlg);
        dlg.setTitle(wizard.getTitle());
        dlg.getContentPane().setLayout(new BorderLayout());
        dlg.getContentPane().add(outerPanel, BorderLayout.CENTER);
        if (bounds != null) {
            dlg.setBounds(bounds);
        } else {
            dlg.pack();
        }
        dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        dlg.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                if (!(e.getWindow() instanceof JDialog)) {
                    return;
                }
                JDialog dlg = (JDialog) e.getWindow();
                boolean dontClose = false;
                if (!wizard.isBusy()) {
                    try {
                        if (deferredResult != null && deferredResult.canAbort()) {
                            deferredResult.abort();
                        } else if (deferredResult != null && !deferredResult.canAbort()) {
                            dontClose = true;
                            return;
                        }
                    } finally {
                        if (!dontClose && wizard.cancel(settings)) {
                            dlg.setVisible(false);
                            dlg.dispose();
                        }
                    }
                }
            }
        });
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        // XXX get screen insets?
        int x = (d.width - dlg.getWidth()) / 2;
        int y = (d.height - dlg.getHeight()) / 2;
        dlg.setLocation(x, y);
        dlg.setModal(true);
        dlg.getRootPane().setDefaultButton(buttonManager.getNext());
        dlg.setVisible(true);
        return wizardResult;
    }

    private Window findLikelyOwnerWindow() {
        return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    }

    /**
     * Return the current wizard panel, or null if the currently displayed page
     * is not a WizardPanel.
     *
     * @return
     */
    public WizardPanel getCurrentWizardPanel() {
        JComponent comp = wizardPanel;
        if (comp instanceof WizardPanel) {
            return (WizardPanel) comp;
        }
        return null;
    }

    public String getCurrentStep() {
        return settings.currID();
    }

    // available in the package only
    static void checkLegalNavMode(int i) {

    }

    /**
     * Set the currently displayed panel.
     * @parm comp is can be anything - it is not required to be a WizardPage or WizardPanel
     */
    public void setCurrentWizardPanel(JComponent comp) {
        inner.add(comp, BorderLayout.CENTER);
        inner.remove(wizardPanel);
        wizardPanel = comp;
        inner.invalidate();
        inner.revalidate();
        inner.repaint();
        comp.requestFocus();
        if (!inSummary) {
            buttonManager.updateButtons();
        }
    }

    void handleSummary(Summary summary) {
        inSummary = true;
        // XXX
        JComponent summaryComp = (JComponent) summary.getSummaryComponent();
        if (summaryComp.getBorder() != null) {
            CompoundBorder b = new CompoundBorder(new EmptyBorder(5, 5, 5, 5), summaryComp.getBorder());
            summaryComp.setBorder(b);
        }
        // XXX
        setCurrentWizardPanel((JComponent) summaryComp);
        instructions.setInSummaryPage(true);
        ttlLabel.setText(// NOI18N
        NbBridge.// NOI18N
        getString(// NOI18N
        "org/netbeans/api/wizard/Bundle", WizardDisplayerImpl.class, // NOI18N
        "Summary"));
        getButtonManager().setSummaryShowingMode();
        ttlLabel.setBackground(Color.WHITE);
        summaryComp.requestFocus();
    }

    protected ResultProgressHandle createProgressDisplay(boolean isUseBusy) {
        return new NavProgress(this, isUseBusy);
    }

    void handleDeferredWizardResult(final DeferredWizardResult r) {
        deferredResult = r;
        wizardPanel.setEnabled(false);
        progress = createProgressDisplay(r.isUseBusy());
        Container inst = instructions.getComponent();
        progress.addProgressComponents(inst);
        inst.invalidate();
        if (inst instanceof JComponent) {
            ((JComponent) inst).revalidate();
        }
        inst.repaint();
        Runnable run = new Runnable() {

            public void run() {
                if (!EventQueue.isDispatchThread()) {
                    try {
                        instructions.setInSummaryPage(true);
                        buttonManager.getWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        r.start(settings, progress);
                        if (progress.isRunning()) {
                            progress.failed("Start method did not inidicate failure or finished in " + r, false);
                        }
                    } finally {
                        try {
                            EventQueue.invokeAndWait(this);
                        } catch (InvocationTargetException ex) {
                            ex.printStackTrace();
                        } catch (InterruptedException ex) {
                            ex.printStackTrace();
                        } finally {
                            buttonManager.getWindow().setCursor(Cursor.getDefaultCursor());
                        }
                    }
                } else {
                    deferredResult = null;
                    buttonManager.getCancel().setEnabled(true);
                    Container inst = instructions.getComponent();
                    inst.removeAll();
                    inst.invalidate();
                    if (inst instanceof JComponent) {
                        ((JComponent) instructions).revalidate();
                    }
                    inst.repaint();
                }
            }
        };
        // NOI18N
        Thread runner = new Thread(run, "Wizard Background Result Thread " + r);
        runner.start();
    }

    public void navigateTo(String id) {
        JComponent comp = wizard.navigatingTo(id, getSettings());
        String description = wizard.getLongDescription(id);
        if (description == null) {
            description = wizard.getStepDescription(id);
        }
        getTtlLabel().setText(description);
        setCurrentWizardPanel(comp);
    }

    public NavButtonManager getButtonManager() {
        return buttonManager;
    }

    public DeferredWizardResult getDeferredResult() {
        return deferredResult;
    }

    public InstructionsPanel getInstructions() {
        return instructions;
    }

    public boolean isInSummary() {
        return inSummary;
    }

    public void setInSummary(boolean state) {
        inSummary = state;
    }

    public JPanel getOuterPanel() {
        return outerPanel;
    }

    public MergeMap getSettings() {
        return settings;
    }

    public JLabel getTtlLabel() {
        return ttlLabel;
    }

    public JPanel getTtlPanel() {
        return ttlPanel;
    }

    public Wizard getWizard() {
        return wizard;
    }

    public JComponent getWizardPanel() {
        return wizardPanel;
    }

    public Object getWizardResult() {
        return wizardResult;
    }

    public void setWizardResult(Object wizardResult) {
        this.wizardResult = wizardResult;
        if (receiver != null) {
            receiver.finished(wizardResult);
        }
    }

    public void setDeferredResult(DeferredWizardResult deferredResult) {
        this.deferredResult = deferredResult;
    }

    /**
     * Will only be called if there is a WizardResultReceiver - i.e. if the
     * wizard is being displayed in some kind of custom container.  Return
     * true to indicate we should not try to close the parent window.
     */
    boolean cancel() {
        boolean result = receiver != null;
        if (result) {
            receiver.cancelled(settings);
        }
        return result;
    }

    void updateProblem() {
        String prob = wizard.getProblem();
        // NOI18N
        problem.setText(prob == null ? " " : prob);
        if (prob != null && prob.trim().length() == 0) {
            // Issue 3 - provide ability to disable next w/o
            // showing the error line
            prob = null;
        }
        Border b = prob == null ? BorderFactory.createEmptyBorder(1, 0, 0, 0) : BorderFactory.createMatteBorder(1, 0, 0, 0, problem.getForeground());
        Border b1 = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 12, 0, 12), b);
        problem.setBorder(b1);
    }
}


switch(size) {
                case 0:
                    return ImmutableEmptyIntList.INSTANCE;
                case 1:
                    return new ImmutableIntElement(i);
                default:
                    assert array != null;
                    if (array.length == size) {
                        return new ImmutableIntArray(array);
                    }
                    return new ImmutableIntArray(Arrays.copyOfRange(array, 0, size));
            }

package com.hivemq.client.internal.util.collections;

import com.hivemq.client.internal.util.Checks;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;

/**
 * @author Silvio Giebl
 */
public interface ImmutableIntList {

    @NotNull
    static ImmutableIntList of() {
        return ImmutableEmptyIntList.INSTANCE;
    }

    @NotNull
    static ImmutableIntList of(final int i) {
        return new ImmutableIntElement(i);
    }

    @NotNull
    static ImmutableIntList of(final int i1, final int i2) {
        return new ImmutableIntArray(i1, i2);
    }

    @NotNull
    static ImmutableIntList of(final int i1, final int i2, final int i3) {
        return new ImmutableIntArray(i1, i2, i3);
    }

    @NotNull
    static ImmutableIntList of(final int i1, final int i2, final int i3, @NotNull final int... others) {
        Checks.notNull(others, "Int array");
        final int[] array = new int[3 + others.length];
        array[0] = i1;
        array[0] = i2;
        array[0] = i3;
        System.arraycopy(others, 0, array, 3, others.length);
        return new ImmutableIntArray(array);
    }

    @NotNull
    static ImmutableIntList copyOf(final int @NotNull [] array) {
        Checks.notNull(array, "Int array");
        switch(array.length) {
            case 0:
                return ImmutableEmptyIntList.INSTANCE;
            case 1:
                return new ImmutableIntElement(array[0]);
            default:
                return new ImmutableIntArray(array.clone());
        }
    }

    @NotNull
    static Builder builder() {
        return new Builder();
    }

    @NotNull
    static Builder builder(final int capacity) {
        return new Builder(capacity);
    }

    int size();

    default boolean isEmpty() {
        return size() == 0;
    }

    int get(int index);

    class Builder {

        private static final int INITIAL_CAPACITY = 4;

        private int i;

        private int @Nullable [] array;

        private int size;

        private Builder() {
        }

        private Builder(final int capacity) {
            if (capacity > 1) {
                array = new int[capacity];
            }
        }

        private int newCapacity(final int capacity) {
            return capacity + (capacity >> 1);
        }

        @NotNull
        public Builder add(final int i) {
            if (size == 0) {
                this.i = i;
                size = 1;
            } else {
                if (array == null) {
                    array = new int[INITIAL_CAPACITY];
                } else if (size == array.length) {
                    array = Arrays.copyOf(array, newCapacity(array.length));
                }
                if (size == 1) {
                    array[0] = this.i;
                }
                array[size++] = i;
            }
            return this;
        }

        @NotNull
        public ImmutableIntList build() {


switch(id) {
                case 100:
                    if (response != null) {
                        processData(response);
                        NewPostListViewAdapter adapter = new NewPostListViewAdapter(mContext, result);
                        lv_new_post.setAdapter(adapter);
                    }
                    break;
                case 101:
                    Toast.makeText(mContext, "https", Toast.LENGTH_SHORT).show();
                    break;
            }

package com.atguigu.shoppingmall.community.fragment;

import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
import com.atguigu.shoppingmall.R;
import com.atguigu.shoppingmall.community.adapter.NewPostListViewAdapter;
import com.atguigu.shoppingmall.base.BaseFragment;
import com.atguigu.shoppingmall.community.bean.NewPostBean;
import com.atguigu.shoppingmall.utils.Constants;
import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.List;
import okhttp3.Call;
import okhttp3.Request;

public class NewPostFragment extends BaseFragment {

    private ListView lv_new_post;

    private List<NewPostBean.ResultBean> result;

    @Override
    public View initView() {
        View view = View.inflate(mContext, R.layout.fragment_new_post, null);
        lv_new_post = (ListView) view.findViewById(R.id.lv_new_post);
        return view;
    }

    @Override
    public void initData() {
        getDataFromNet();
    }

    public void getDataFromNet() {
        OkHttpUtils.get().url(Constants.NEW_POST_URL).id(100).build().execute(new MyStringCallback());
    }

    public class MyStringCallback extends StringCallback {

        @Override
        public void onBefore(Request request, int id) {
        }

        @Override
        public void onAfter(int id) {
        }

        @Override
        public void onError(Call call, Exception e, int id) {
            Log.e("TAG", "联网失败" + e.getMessage());
        }

        @Override
        public void onResponse(String response, int id) {

        }
    }

    private void processData(String json) {
        Gson gson = new Gson();
        NewPostBean newPostBean = gson.fromJson(json, NewPostBean.class);
        result = newPostBean.getResult();
    }
}


switch(opts.length) {
            case 0:
                throw new IllegalArgumentException("No test flag given");
            case 1:
                flag = opts[0].charAt(0);
                break;
            default:
                throw new IllegalArgumentException("Only one test flag is allowed");
        }

package org.apache.hadoop.fs.shell;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.security.AccessControlException;

/**
 * Perform shell-like file tests
 */
@InterfaceAudience.Private
@InterfaceStability.Unstable
class Test extends FsCommand {

    public static void registerCommands(CommandFactory factory) {
        factory.addClass(Test.class, "-test");
    }

    public static final String NAME = "test";

    public static final String USAGE = "-[defsz] <path>";

    public static final String DESCRIPTION = "Answer various questions about <path>, with result via exit status.\n" + "  -d  return 0 if <path> is a directory.\n" + "  -e  return 0 if <path> exists.\n" + "  -f  return 0 if <path> is a file.\n" + "  -s  return 0 if file <path> is greater " + "        than zero bytes in size.\n" + "  -w  return 0 if file <path> exists " + "        and write permission is granted.\n" + "  -r  return 0 if file <path> exists " + "        and read permission is granted.\n" + "  -z  return 0 if file <path> is " + "        zero bytes in size, else return 1.";

    private char flag;

    @Override
    protected void processOptions(LinkedList<String> args) {
        CommandFormat cf = new CommandFormat(1, 1, "e", "d", "f", "s", "z", "w", "r");
        cf.parse(args);
        String[] opts = cf.getOpts().toArray(new String[0]);

    }

    @Override
    protected void processPath(PathData item) throws IOException {
        boolean test = false;
        switch(flag) {
            case 'e':
                test = true;
                break;
            case 'd':
                test = item.stat.isDirectory();
                break;
            case 'f':
                test = item.stat.isFile();
                break;
            case 's':
                test = (item.stat.getLen() > 0);
                break;
            case 'z':
                test = (item.stat.getLen() == 0);
                break;
            case 'w':
                test = testAccess(item, FsAction.WRITE);
                break;
            case 'r':
                test = testAccess(item, FsAction.READ);
                break;
            default:
                break;
        }
        if (!test) {
            exitCode = 1;
        }
    }

    private boolean testAccess(PathData item, FsAction action) throws IOException {
        try {
            item.fs.access(item.path, action);
            return true;
        } catch (AccessControlException | FileNotFoundException e) {
            return false;
        }
    }

    @Override
    protected void processNonexistentPath(PathData item) throws IOException {
        exitCode = 1;
    }
}


switch(delta.getKind()) {
                case IResourceDelta.ADDED:
                case IResourceDelta.CHANGED:
                    return visit(delta.getResource());
            }

package com.hybris.hyeclipse.tsv.builder;

import java.util.Collection;
import java.util.EnumMap;
import java.util.LinkedHashSet;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import com.hybris.hyeclipse.tsv.validator.ItemsXmlValidator;
import com.hybris.ps.tsv.results.IResult;
import com.hybris.ps.tsv.results.ResultState;
import com.hybris.ps.tsv.rules.xml.RulePriority;

abstract class TsvBuilder extends IncrementalProjectBuilder {

    private static final Map<RulePriority, Integer> priorityMap = new EnumMap<>(RulePriority.class);

    static {
        priorityMap.put(RulePriority.H, IMarker.PRIORITY_HIGH);
        priorityMap.put(RulePriority.M, IMarker.PRIORITY_NORMAL);
        priorityMap.put(RulePriority.L, IMarker.PRIORITY_LOW);
    }

    class ItemsXmlFinder implements IResourceDeltaVisitor, IResourceVisitor {

        final Collection<IFile> files = new LinkedHashSet<>();

        @Override
        public boolean visit(final IResourceDelta delta) throws CoreException {

            return true;
        }

        @Override
        public boolean visit(final IResource resource) throws CoreException {
            if (resource instanceof IFile) {
                final IFile file = (IFile) resource;
                if (file.getName().endsWith("items.xml")) {
                    files.add(file);
                    return false;
                }
            }
            return true;
        }
    }

    public static final String MARKER_TYPE = "com.hybris.hyeclipse.tsv.tsvproblem";

    @Override
    protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException {
        // TODO find referenced extensions and their eclipse projects and return them
        if (kind == CLEAN_BUILD) {
            clean(monitor);
        } else if (kind == FULL_BUILD) {
            fullBuild(monitor);
        } else {
            IResourceDelta delta = getDelta(getProject());
            if (delta == null) {
                fullBuild(monitor);
            } else {
                incrementalBuild(delta, monitor);
            }
        }
        return null;
    }

    protected void clean(IProgressMonitor monitor) throws CoreException {
        // delete markers set and files created
        getProject().deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
    }

    protected abstract ItemsXmlValidator getValidator() throws CoreException;

    void checkTsv(final Collection<IFile> files, IProgressMonitor monitor) throws CoreException {
        final SubMonitor subMonitor = SubMonitor.convert(monitor, files.size() * 5);
        final ItemsXmlValidator validator = getValidator();
        for (final IFile file : files) {
            if (subMonitor.isCanceled()) {
                throw new OperationCanceledException("TSV Check cancelled");
            }
            subMonitor.subTask("Checking typesystem: " + file.getFullPath());
            processResults(file, validator.analyze(file, subMonitor.newChild(4)), subMonitor.newChild(1));
        }
    }

    private void processResults(final IFile file, final Collection<IResult> results, final IProgressMonitor monitor) throws CoreException {
        final SubMonitor progress = SubMonitor.convert(monitor, "Processing results", results.size());
        deleteMarkers(file);
        for (final IResult result : results) {
            if (result.getState() == ResultState.FAIL || result.getState() == ResultState.ERROR) {
                addMarker(file, result.getDescription(), result.getLine() != null ? result.getLine().intValue() : 1, IMarker.SEVERITY_ERROR, priorityMap.get(result.getRule().getPriority()));
            }
            progress.worked(1);
        }
    }

    private void addMarker(final IFile file, String message, int lineNumber, int severity, int priority) throws CoreException {
        final IMarker marker = file.createMarker(TsvBuilder.MARKER_TYPE);
        marker.setAttribute(IMarker.MESSAGE, message);
        marker.setAttribute(IMarker.SEVERITY, severity);
        if (lineNumber == -1) {
            lineNumber = 1;
        }
        marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
        marker.setAttribute(IMarker.PRIORITY, priority);
    }

    private void deleteMarkers(IFile file) throws CoreException {
        file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
    }

    protected void fullBuild(final IProgressMonitor monitor) throws CoreException {
        final ItemsXmlFinder finder = new ItemsXmlFinder();
        getProject().accept(finder);
        checkTsv(finder.files, monitor);
    }

    protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException {
        final ItemsXmlFinder finder = new ItemsXmlFinder();
        delta.accept(finder);
        checkTsv(finder.files, monitor);
    }
}