protected void grabKeyboardFocus() {
        name.setFocus(true);
    }

package org.jboss.errai.demo.grocery.client.local;

import static com.google.gwt.dom.client.Style.Unit.PX;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.validation.Validator;
import org.jboss.errai.databinding.client.api.DataBinder;
import org.jboss.errai.databinding.client.api.StateSync;
import org.jboss.errai.demo.grocery.client.shared.Department;
import org.jboss.errai.demo.grocery.client.shared.GroceryList;
import org.jboss.errai.demo.grocery.client.shared.Item;
import org.jboss.errai.demo.grocery.client.shared.User;
import org.jboss.errai.ui.shared.api.annotations.AutoBound;
import org.jboss.errai.ui.shared.api.annotations.Bound;
import org.jboss.errai.ui.shared.api.annotations.DataField;
import org.jboss.errai.ui.shared.api.annotations.EventHandler;
import com.google.gwt.animation.client.Animation;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.TextBox;

public abstract class Form extends Composite {

    @Inject
    protected EntityManager em;

    @Inject
    protected Validator validator;

    @Inject
    protected User user;

    @Inject
    protected GroceryList groceryList;

    @Inject
    @AutoBound
    protected DataBinder<Item> itemBinder;

    @Inject
    @DataField
    protected Label overallErrorMessage;

    @Inject
    @Bound
    @DataField
    protected SuggestBox name;

    @Inject
    @Bound
    @DataField
    protected TextBox comment;

    @Inject
    @Bound(property = "department.name")
    @DataField
    protected SuggestBox department;

    @Inject
    @DataField
    protected Button saveButton;

    @Inject
    @DataField
    protected Button clearButton;

    @DataField
    protected Element otherFields = DOM.createDiv();

    protected Runnable afterSaveAction;

    protected HandlerRegistration handlerRegistration;

    public Form() {
        super();
    }

    @PostConstruct
    protected void setupSuggestions() {
        MultiWordSuggestOracle iso = (MultiWordSuggestOracle) name.getSuggestOracle();
        for (Item i : em.createNamedQuery("allItems", Item.class).getResultList()) {
            iso.add(i.getName());
        }
        MultiWordSuggestOracle dso = (MultiWordSuggestOracle) department.getSuggestOracle();
        for (Department d : em.createNamedQuery("allDepartments", Department.class).getResultList()) {
            dso.add(d.getName());
        }
        name.getValueBox().addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                if ("0px".equals(otherFields.getStyle().getHeight())) {
                    new Animation() {

                        @Override
                        protected void onUpdate(double progress) {
                            otherFields.getStyle().setHeight(Window.getClientWidth() > 768 ? 215 : 145 * progress, PX);
                        }
                    }.run(1000);
                }
            }
        });
        hideOtherFields();
        handlerRegistration = addEnterKeyHandler();
    }

    @PreDestroy
    void cleanup() {
        itemBinder.unbind();
        handlerRegistration.removeHandler();
    }

    @EventHandler("saveButton")
    public abstract void onSaveButtonClicked(ClickEvent event);

    @EventHandler("clearButton")
    public abstract void onClearButtonClicked(ClickEvent event);

    protected void onNewItem(@Observes Item newItem) {
        System.out.println("ItemForm@" + System.identityHashCode(this) + " got new item event");
        ((MultiWordSuggestOracle) name.getSuggestOracle()).add(newItem.getName());
    }

    /**
     * Gives keyboard focus to the appropriate widget in this form.
     */

    protected void hideOtherFields() {
        otherFields.getStyle().setHeight(0, PX);
    }

    protected HandlerRegistration addEnterKeyHandler() {
        return this.addDomHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                    saveButton.click();
            }
        }, KeyUpEvent.getType());
    }

    protected boolean isValidName() {
        if (name.getText() == null)
            return false;
        else if (name.getText().isEmpty())
            return false;
        else if (// if name.getText() contains at least one word character
        name.getText().matches(".*\\w.*"))
            return true;
        return false;
    }

    public void setItem(Item item) {
        if (item.getDepartment() == null) {
            item.setDepartment(new Department());
        }
        itemBinder.setModel(item, StateSync.FROM_MODEL);
    }

    /**
     * Returns the store instance that is permanently associated with this form. The returned instance is bound to this
     * store's fields: updates to the form fields will cause matching updates in the returned object's state, and
     * vice-versa.
     *
     * @return the Item instance that is bound to the fields of this form.
     */
    public Item getItem() {
        return itemBinder.getModel();
    }

    public DataBinder<Item> getItemBinder() {
        return itemBinder;
    }
}


public void setRouterFunction(@Nullable RouterFunction<?> routerFunction) {
        this.routerFunction = routerFunction;
    }

package org.springframework.web.servlet.function.support;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.RouterFunctions;
import org.springframework.web.servlet.function.ServerRequest;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;

/**
 * {@code HandlerMapping} implementation that supports {@link RouterFunction}s.
 *
If no {@link RouterFunction} is provided at
 * {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect
 * all router functions in the application context, and consult them in
 * {@linkplain org.springframework.core.annotation.Order order}.
 *
 * @author Arjen Poutsma
 * @since 5.2
 */
public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean {

    @Nullable
    private RouterFunction<?> routerFunction;

    private List<HttpMessageConverter<?>> messageConverters = Collections.emptyList();

    private boolean detectHandlerFunctionsInAncestorContexts = false;

    /**
     * Create an empty {@code RouterFunctionMapping}.
     *
If this constructor is used, this mapping will detect all {@link RouterFunction} instances
     * available in the application context.
     */
    public RouterFunctionMapping() {
    }

    /**
     * Create a {@code RouterFunctionMapping} with the given {@link RouterFunction}.
     *
If this constructor is used, no application context detection will occur.
     * @param routerFunction the router function to use for mapping
     */
    public RouterFunctionMapping(RouterFunction<?> routerFunction) {
        this.routerFunction = routerFunction;
    }

    /**
     * Set the router function to map to.
     *
If this property is used, no application context detection will occur.
     */

/**
     * Return the configured {@link RouterFunction}.
     *
Note: When router functions are detected from the
     * ApplicationContext, this method may return {@code null} if invoked
     * prior to {@link #afterPropertiesSet()}.
     * @return the router function or {@code null}
     */
    @Nullable
    public RouterFunction<?> getRouterFunction() {
        return this.routerFunction;
    }

    public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
        this.messageConverters = messageConverters;
    }

    /**
     * Set whether to detect handler functions in ancestor ApplicationContexts.
     *
Default is "false": Only handler functions in the current ApplicationContext
     * will be detected, i.e. only in the context that this HandlerMapping itself
     * is defined in (typically the current DispatcherServlet's context).
     *
Switch this flag on to detect handler beans in ancestor contexts
     * (typically the Spring root WebApplicationContext) as well.
     */
    public void setDetectHandlerFunctionsInAncestorContexts(boolean detectHandlerFunctionsInAncestorContexts) {
        this.detectHandlerFunctionsInAncestorContexts = detectHandlerFunctionsInAncestorContexts;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        if (this.routerFunction == null) {
            initRouterFunction();
        }
        if (CollectionUtils.isEmpty(this.messageConverters)) {
            initMessageConverters();
        }
    }

    /**
     * Detect a all {@linkplain RouterFunction router functions} in the
     * current application context.
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    private void initRouterFunction() {
        ApplicationContext applicationContext = obtainApplicationContext();
        Map<String, RouterFunction> beans = (this.detectHandlerFunctionsInAncestorContexts ? BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RouterFunction.class) : applicationContext.getBeansOfType(RouterFunction.class));
        List<RouterFunction> routerFunctions = new ArrayList<>(beans.values());
        if (!CollectionUtils.isEmpty(routerFunctions) && logger.isInfoEnabled()) {
            routerFunctions.forEach(routerFunction -> logger.info("Mapped " + routerFunction));
        }
        this.routerFunction = routerFunctions.stream().reduce(RouterFunction::andOther).orElse(null);
    }

    /**
     * Initializes a default set of {@linkplain HttpMessageConverter message converters}.
     */
    private void initMessageConverters() {
        List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(4);
        messageConverters.add(new ByteArrayHttpMessageConverter());
        messageConverters.add(new StringHttpMessageConverter());
        try {
            messageConverters.add(new SourceHttpMessageConverter<>());
        } catch (Error err) {
            // Ignore when no TransformerFactory implementation is available
        }
        messageConverters.add(new AllEncompassingFormHttpMessageConverter());
        this.messageConverters = messageConverters;
    }

    @Nullable
    @Override
    protected Object getHandlerInternal(@NotNull HttpServletRequest servletRequest) throws Exception {
        if (this.routerFunction != null) {
            ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters);
            servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request);
            return this.routerFunction.route(request).orElse(null);
        } else {
            return null;
        }
    }
}


public Object getLineHeight() {
        return lineHeight;
    }

package org.primefaces.model.charts.axes.cartesian;

import java.io.IOException;
import java.io.Serializable;
import org.primefaces.util.ChartUtils;
import org.primefaces.util.FastStringWriter;

/**
 * The scale label configuration is nested under the scale configuration in the scaleLabel key.
 * It defines options for the scale title.
 */
public class CartesianScaleLabel implements Serializable {

    private static final long serialVersionUID = 1L;

    private boolean display;

    private String labelString;

    private Object lineHeight;

    private String fontColor;

    private String fontFamily;

    private Number fontSize;

    private String fontStyle;

    private Object padding;

    /**
     * Gets the display
     *
     * @return display
     */
    public boolean isDisplay() {
        return display;
    }

    /**
     * Sets the display
     *
     * @param display If true, display the axis title.
     */
    public void setDisplay(boolean display) {
        this.display = display;
    }

    /**
     * Gets the labelString
     *
     * @return labelString
     */
    public String getLabelString() {
        return labelString;
    }

    /**
     * Sets the labelString
     *
     * @param labelString The text for the title.
     */
    public void setLabelString(String labelString) {
        this.labelString = labelString;
    }

    /**
     * Gets the lineHeight
     *
     * @return lineHeight
     */

    /**
     * Sets the lineHeight
     *
     * @param lineHeight Height of an individual line of text
     */
    public void setLineHeight(Object lineHeight) {
        this.lineHeight = lineHeight;
    }

    /**
     * Gets the fontColor
     *
     * @return fontColor
     */
    public String getFontColor() {
        return fontColor;
    }

    /**
     * Sets the fontColor
     *
     * @param fontColor Font color for scale title.
     */
    public void setFontColor(String fontColor) {
        this.fontColor = fontColor;
    }

    /**
     * Gets the fontFamily
     *
     * @return fontFamily
     */
    public String getFontFamily() {
        return fontFamily;
    }

    /**
     * Sets the fontFamily
     *
     * @param fontFamily Font family for the scale title, follows CSS font-family options.
     */
    public void setFontFamily(String fontFamily) {
        this.fontFamily = fontFamily;
    }

    /**
     * Gets the fontSize
     *
     * @return fontSize
     */
    public Number getFontSize() {
        return fontSize;
    }

    /**
     * Sets the fontSize
     *
     * @param fontSize Font size for scale title.
     */
    public void setFontSize(Number fontSize) {
        this.fontSize = fontSize;
    }

    /**
     * Gets the fontStyle
     *
     * @return fontStyle
     */
    public String getFontStyle() {
        return fontStyle;
    }

    /**
     * Sets the fontStyle
     *
     * @param fontStyle Font style for the scale title, follows CSS font-style options.
     */
    public void setFontStyle(String fontStyle) {
        this.fontStyle = fontStyle;
    }

    /**
     * Gets the padding
     *
     * @return padding
     */
    public Object getPadding() {
        return padding;
    }

    /**
     * Sets the padding
     *
     * @param padding Padding to apply around scale labels. Only top and bottom are implemented.
     */
    public void setPadding(Object padding) {
        this.padding = padding;
    }

    /**
     * Write the options of scale label
     *
     * @return options as JSON object
     * @throws java.io.IOException If an I/O error occurs
     */
    public String encode() throws IOException {
        try (FastStringWriter fsw = new FastStringWriter()) {
            fsw.write("{");
            ChartUtils.writeDataValue(fsw, "display", this.display, false);
            ChartUtils.writeDataValue(fsw, "labelString", this.labelString, true);
            ChartUtils.writeDataValue(fsw, "lineHeight", this.lineHeight, true);
            ChartUtils.writeDataValue(fsw, "fontColor", this.fontColor, true);
            ChartUtils.writeDataValue(fsw, "fontFamily", this.fontFamily, true);
            ChartUtils.writeDataValue(fsw, "fontSize", this.fontSize, true);
            ChartUtils.writeDataValue(fsw, "fontStyle", this.fontStyle, true);
            ChartUtils.writeDataValue(fsw, "padding", this.padding, true);
            fsw.write("}");
            return fsw.toString();
        }
    }
}


public Set<Player> getRecipients() {
        return recipients;
    }

package org.bukkit.event.player;

import java.util.IllegalFormatException;
import java.util.Set;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * This event will sometimes fire synchronously, depending on how it was
 * triggered.
 *

 * The constructor provides a boolean to indicate if the event was fired
 * synchronously or asynchronously. When asynchronous, this event can be
 * called from any thread, sans the main thread, and has limited access to the
 * API.
 *

 * If a player is the direct cause of this event by an incoming packet, this
 * event will be asynchronous. If a plugin triggers this event by compelling a
 * player to chat, this event will be synchronous.
 *

 * Care should be taken to check {@link #isAsynchronous()} and treat the event
 * appropriately.
 */
public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {

    private static final HandlerList handlers = new HandlerList();

    private boolean cancel = false;

    private String message;

    private String format = "<%1$s> %2$s";

    private final Set<Player> recipients;

    /**
     * @param async This changes the event to a synchronous state.
     * @param who the chat sender
     * @param message the message sent
     * @param players the players to receive the message. This may be a lazy
     *     or unmodifiable collection.
     */
    public AsyncPlayerChatEvent(final boolean async, final Player who, final String message, final Set<Player> players) {
        super(who, async);
        this.message = message;
        recipients = players;
    }

    /**
     * Gets the message that the player is attempting to send. This message
     * will be used with {@link #getFormat()}.
     *
     * @return Message the player is attempting to send
     */
    public String getMessage() {
        return message;
    }

    /**
     * Sets the message that the player will send. This message will be used
     * with {@link #getFormat()}.
     *
     * @param message New message that the player will send
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * Gets the format to use to display this chat message.
     *

     * When this event finishes execution, the first format parameter is the
     * {@link Player#getDisplayName()} and the second parameter is {@link
     * #getMessage()}
     *
     * @return {@link String#format(String, Object...)} compatible format
     *     string
     */
    public String getFormat() {
        return format;
    }

    /**
     * Sets the format to use to display this chat message.
     *

     * When this event finishes execution, the first format parameter is the
     * {@link Player#getDisplayName()} and the second parameter is {@link
     * #getMessage()}
     *
     * @param format {@link String#format(String, Object...)} compatible
     *     format string
     * @throws IllegalFormatException if the underlying API throws the
     *     exception
     * @throws NullPointerException if format is null
     * @see String#format(String, Object...)
     */
    public void setFormat(final String format) throws IllegalFormatException, NullPointerException {
        // Oh for a better way to do this!
        try {
            String.format(format, player, message);
        } catch (RuntimeException ex) {
            ex.fillInStackTrace();
            throw ex;
        }
        this.format = format;
    }

    /**
     * Gets a set of recipients that this chat message will be displayed to.
     *

     * The set returned is not guaranteed to be mutable and may auto-populate
     * on access. Any listener accessing the returned set should be aware that
     * it may reduce performance for a lazy set implementation.
     *

     * Listeners should be aware that modifying the list may throw {@link
     * UnsupportedOperationException} if the event caller provides an
     * unmodifiable set.
     *
     * @return All Players who will see this chat message
     */

    public boolean isCancelled() {
        return cancel;
    }

    public void setCancelled(boolean cancel) {
        this.cancel = cancel;
    }

    @Override
    public HandlerList getHandlers() {
        return handlers;
    }

    public static HandlerList getHandlerList() {
        return handlers;
    }
}


while ((I = WdbIn.read(tempBuffer)) != -1) raf.write(tempBuffer, 0, I);

package decrypt12;

/*
 *
 *** decrypt12.jar: Decrypts WhatsApp msgstore.db.crypt12 files. ***
 *
 * Status	:	Production
 * Version	:	1.0
 *
 */
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.security.Security;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.jce.provider.BouncyCastleProvider;

public class decrypt12 {

    static {
        Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 1);
    }

    public static void decrypt(String KeyFile, String C12File, String SQLFile) throws Exception {
        final File tempFile = new File(System.getProperty("java.io.tmpdir") + "/" + (int) (System.currentTimeMillis() / 1000L) + "-msgstore.enc");
        if (!new File(KeyFile).isFile())
            quit("The specified input key file does not exist.");
        else if (new File(KeyFile).length() != 158)
            quit("The specified input key file is invalid.");
        else if (!new File(C12File).isFile())
            quit("The specified input crypt12 file does not exist.");
        InputStream KeyIn = new FileInputStream(KeyFile);
        InputStream WdbIn = new BufferedInputStream(new FileInputStream(C12File));
        byte[] KeyData = new byte[158];
        KeyIn.read(KeyData);
        byte[] T1 = new byte[32];
        System.arraycopy(KeyData, 30, T1, 0, 32);
        byte[] KEY = new byte[32];
        System.arraycopy(KeyData, 126, KEY, 0, 32);
        KeyIn.close();
        byte[] C12Data = new byte[67];
        WdbIn.read(C12Data);
        byte[] T2 = new byte[32];
        System.arraycopy(C12Data, 3, T2, 0, 32);
        byte[] IV = new byte[16];
        System.arraycopy(C12Data, 51, IV, 0, 16);
        if (!new String(T1, 0, T1.length, "ASCII").equals(new String(T2, 0, T2.length, "ASCII")))
            quit("Key file mismatch or crypt12 file is corrupt.");
        int InputLength = WdbIn.available();
        RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
        byte[] tempBuffer = new byte[1024];
        int I;

        raf.setLength(InputLength - 20);
        raf.close();
        WdbIn.close();
        InputStream PdbSt = new BufferedInputStream(new FileInputStream(tempFile));
        Cipher cipher;
        Security.addProvider(new BouncyCastleProvider());
        // BouncyCastle
        cipher = Cipher.getInstance("AES/GCM/NoPadding", "BC");
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
        CipherInputStream CipherStream = new CipherInputStream(PdbSt, cipher);
        InflaterInputStream CryptOutput = new InflaterInputStream(CipherStream, new Inflater(false));
        try {
            FileOutputStream InflateBuffer = new FileOutputStream(SQLFile);
            int N = 0;
            byte[] CryptBuffer = new byte[8192];
            while ((N = CryptOutput.read(CryptBuffer)) != -1) {
                InflateBuffer.write(CryptBuffer, 0, N);
            }
            InflateBuffer.close();
        } catch (IOException ex) {
            quit("Fatal error:" + ex);
        }
        CipherStream.close();
        tempFile.delete();
        InputStream SqlDB = new FileInputStream(SQLFile);
        byte[] SqlData = new byte[6];
        SqlDB.read(SqlData);
        byte[] MS = new byte[6];
        System.arraycopy(SqlData, 0, MS, 0, 6);
        SqlDB.close();
        if (!new String(MS, 0, MS.length, "ASCII").toLowerCase().equals("sqlite")) {
            new File(SQLFile).delete();
            quit("Decryption of crypt12 file has failed.");
        } else
            quit("Decryption of crypt12 file was successful.");
    }

    private static void quit(String Msg) {
        System.out.println(Msg);
        System.exit(0);
    }

    public static void main(String[] args) throws Exception {
        String outFile;
        if (args.length > 1 && args.length < 4) {
            if (args.length == 3)
                outFile = args[2];
            else
                outFile = "msgstore.db";
            decrypt(args[0], args[1], outFile);
        } else {
            System.out.println("\nWhatsApp Crypt12 Database Decrypter 1.0 Copyright (C) 2016 by TripCode");
            System.out.println("\tUsage: java -jar decrypt12.jar key msgstore.db.crypt12 msgstore.db\n");
        }
    }
}


private void checkByteCodeEventNeeded(int bytecode) {
        JVMTIEvents.E event = JVMTI.byteCodeEventNeeded(bytecode);
        if (event != null) {
            eventSettings |= event.bit;
        }
    }

package com.oracle.max.vm.ext.jvmti.t1x.armv7;

import static com.oracle.max.vm.ext.t1x.T1XTemplateTag.*;
import java.util.*;
import com.oracle.max.vm.ext.jvmti.*;
import com.oracle.max.vm.ext.jvmti.t1x.*;
import com.oracle.max.vm.ext.t1x.*;
import com.oracle.max.vm.ext.t1x.armv7.*;
import com.sun.cri.bytecode.*;
import com.sun.max.vm.*;
import com.sun.max.vm.actor.member.*;
import com.sun.max.vm.classfile.*;
import com.sun.max.vm.compiler.deps.*;
import com.sun.max.vm.jni.*;
import com.sun.max.vm.profile.*;

/**
 * Custom compilation class for generating JVMTI code-related events.
 *
 * When any JVMTI agents have requested <i>any</i> of the events that require compiled code modifications, an instance
 * of this class is used to compile a method.
 *
 * This class is capable of compiling code that is an exact match for the set of events that are needed. However, for
 * the debugging events, it can also operate in a mode where all possible events are compiled in from the
 * outset. Since single-step is one such event this effectively puts the code in interpreted mode, as the event delivery
 * code will be called on every bytecode. Evidently, it is the responsibility of the event delivery code to suppress
 * delivery of unwanted events. The remainder of the discussion assumes the strict mode.
 *
 * Prior to compilation, in {@link #initCompile}, a check is made for which kinds of events are required. This results
 * in {@link #eventSettings} having those bits sets, where the bit numbers correspond to the {@link JVMTIEvents} values.
 *
 * Some events, e.g., field access/modification events, require that modified templates be used to translate the
 * bytecode. Prior to each bytecode translation, the templates are set appropriately in {@link #setTemplates(boolean)}.
 *
 * Breakpoints are handled by checking every bytecode location against the list of set breakpoints and on a match,
 * generating the code for the breakpoint event (via a template for {@link Bytecodes#BREAKPOINT) before the code for the
 * actual bytecode (before advice essentially). There is no compelling need to recompile to remove a breakpoint, we just
 * don't deliver the event.
 *
 * TODO: Since field events are specified per field by the agent, a further optimization would be to determine whether
 * the specific field being accessed is subject to a watch.
 *
 * All per-compilation fields are reset in {@link #initCompile} so no extra {@link #cleanup() cleanup} is needed.
 */
public class JVMTI_ARMV7T1XCompilation extends ARMV7T1XCompilation {

    /**
     * The specific templates to be used for processing the current bytecode,
     * based on whether there are any agents registered for associated events.
     *
     * The choice is between {@link #compiler#templates} which are JVMTI enabled
     * and (@link altT1X#compiler#templates} which are the standard templates.
     */
    private T1XTemplate[] templates;

    /**
     * The breakpoints set in this method, or {@code null} if none. Sorted by location.
     */
    private long[] breakpoints;

    /**
     * The index of the next breakpoint (if any) to check for.
     */
    private int breakpointIndex;

    /**
     * {@link MethodID} for the method.
     */
    private MethodID methodID;

    /**
     * Indicates whether a bytecode has an associated event.
     */
    private BitSet eventBci;

    /**
     * The settings as a {@link JVMTIEvents} bitmask in effect for this compilation.
     */
    private long eventSettings;

    private static final JVMTIEvents.E GETFIELD_EVENT = JVMTI.eventForBytecode(Bytecodes.GETFIELD);

    private static final JVMTIEvents.E PUTFIELD_EVENT = JVMTI.eventForBytecode(Bytecodes.PUTFIELD);

    private static final JVMTIEvents.E RETURN_EVENT = JVMTI.eventForBytecode(Bytecodes.RETURN);

    private static final long DEBUG_EVENTS = JVMTIEvents.E.BREAKPOINT.bit | JVMTIEvents.E.SINGLE_STEP.bit | JVMTIEvents.E.FRAME_POP.bit | JVMTIEvents.E.EXCEPTION_CATCH.bit;

    /**
     * If {@code true}, all debugging-related events will compiled in from the get go.
     */
    private static boolean JVMTI_CDEARM;

    static {
        VMOptions.addFieldOption("-XX:", "JVMTI_CDEARM", JVMTI_ARMV7T1XCompilation.class, "Compile for all debugging events");
    }

    private final T1X defaultT1X;

    public JVMTI_ARMV7T1XCompilation(T1X compiler) {
        super(compiler);
        defaultT1X = T1X.stdT1X;
        templates = defaultT1X.templates;
    }

    @Override
    protected T1XTargetMethod newT1XTargetMethod(T1XCompilation comp, boolean install) {
        // if we compiled any event calls create a JVMTI_T1XTargetMethod, otherwise a vanilla one
        if (!eventBci.isEmpty()) {
            // disable the method profiler
            MethodProfile methodProfile = methodProfileBuilder.methodProfileObject();
            methodProfile.compilationDisabled = true;
            methodProfile.entryBackedgeCount = Integer.MAX_VALUE;
            // register the dependency
            Dependencies deps = JVMTI_DependencyProcessor.recordInstrumentation(method.holder(), eventSettings, breakpoints);
            assert deps != null;
            T1XTargetMethod targetMethod = new JVMTI_T1XTargetMethod(comp, install, eventBci);
            Dependencies.registerValidatedTarget(deps, targetMethod);
            return targetMethod;
        } else {
            return new T1XTargetMethod(comp, install);
        }
    }

    @Override
    protected void initCompile(ClassMethodActor method, CodeAttribute codeAttribute) {
        super.initCompile(method, codeAttribute);
        eventSettings = 0;
        eventBci = new BitSet(bciToPos.length);
        breakpoints = JVMTIBreakpoints.getBreakpoints(method);
        // N.B. Just because there are breakpoints defined, doesn't mean that
        // breakpoint events are currently enabled by the agent.
        // For simplicity, we make the connection in this code.
        if (breakpoints != null) {
            eventSettings |= JVMTIEvents.E.BREAKPOINT.bit;
        }
        breakpointIndex = 0;
        if (JVMTIBreakpoints.isSingleStepEnabled()) {
            eventSettings |= JVMTIEvents.E.SINGLE_STEP.bit;
        }
        methodID = MethodID.fromMethodActor(method);
        // METHOD_ENTRY
        checkByteCodeEventNeeded(-1);
        // METHOD_EXIT
        checkByteCodeEventNeeded(-2);
        checkByteCodeEventNeeded(Bytecodes.GETFIELD);
        checkByteCodeEventNeeded(Bytecodes.PUTFIELD);
        checkByteCodeEventNeeded(Bytecodes.RETURN);
        if (JVMTIEvents.isEventSet(JVMTIEvents.E.EXCEPTION_CATCH)) {
            eventSettings |= JVMTIEvents.E.EXCEPTION_CATCH.bit;
        }
        if (JVMTI_CDEARM) {
            // any debug events => all debug events
            if ((eventSettings & DEBUG_EVENTS) != 0) {
                eventSettings = DEBUG_EVENTS;
            }
        }
    }

    /**
     * Check whether instrumentation is needed for given bytecode, and set {@link #eventSettings} if so.
     * @param bytecode
     * @return the corresponding eventId or zero if not needed.
     */

    @Override
    protected void do_methodTraceEntry() {
        if ((eventSettings & JVMTIEvents.E.METHOD_ENTRY.bit) != 0) {
            templates = compiler.templates;
            start(TRACE_METHOD_ENTRY);
            assignObject(0, "methodActor", method);
            finish();
        } else {
            super.do_methodTraceEntry();
        }
    }

    @Override
    protected void beginBytecode(int opcode) {
        // may invoke emitLoadException() if at handler
        super.beginBytecode(opcode);
        int currentBCI = stream.currentBCI();
        long id = 0;
        boolean eventCall = false;
        boolean singleStep = (eventSettings & JVMTIEvents.E.SINGLE_STEP.bit) != 0;
        boolean breakPossible = breakpoints != null && breakpointIndex < breakpoints.length;
        if (singleStep || breakPossible) {
            if (breakPossible && JVMTIBreakpoints.getLocation(breakpoints[breakpointIndex]) == currentBCI) {
                id = breakpoints[breakpointIndex++];
                if (singleStep) {
                    id |= JVMTIBreakpoints.SINGLE_STEP_AND_BREAK;
                }
            } else {
                if (singleStep) {
                    id = JVMTIBreakpoints.createSingleStepId(methodID, currentBCI);
                    switch(opcode) {
                        case Bytecodes.INVOKEINTERFACE:
                        case Bytecodes.INVOKESPECIAL:
                        case Bytecodes.INVOKESTATIC:
                        case Bytecodes.INVOKEVIRTUAL:
                            id |= JVMTIBreakpoints.SINGLE_STEP_AT_INVOKE;
                            break;
                        default:
                    }
                }
            }
            if (id != 0) {
                templates = compiler.templates;
                start(BREAKPOINT);
                assignLong(0, "id", id);
                finish();
                eventCall = true;
            }
        }
        boolean bytecodeEvent = false;
        switch(opcode) {
            case Bytecodes.GETFIELD:
            case Bytecodes.GETSTATIC:
                bytecodeEvent = (eventSettings & GETFIELD_EVENT.bit) != 0;
                break;
            case Bytecodes.PUTFIELD:
            case Bytecodes.PUTSTATIC:
                bytecodeEvent = (eventSettings & PUTFIELD_EVENT.bit) != 0;
                break;
            case Bytecodes.IRETURN:
            case Bytecodes.LRETURN:
            case Bytecodes.FRETURN:
            case Bytecodes.DRETURN:
            case Bytecodes.ARETURN:
            case Bytecodes.RETURN:
                bytecodeEvent = ((eventSettings & RETURN_EVENT.bit) != 0) || ((eventSettings & JVMTIEvents.E.METHOD_EXIT.bit) != 0);
                break;
            default:
        }
        if (bytecodeEvent) {
            eventCall = true;
            setTemplates(eventCall);
        }
        if (eventCall) {
            eventBci.set(currentBCI);
        }
    }

    @Override
    protected void emitLoadException(int bci) {
        if ((eventSettings & JVMTIEvents.E.EXCEPTION_CATCH.bit) != 0) {
            setTemplates(true);
            eventBci.set(bci);
        }
        super.emitLoadException(bci);
    }

    private void setTemplates(boolean jvmti) {
        templates = jvmti ? compiler.templates : defaultT1X.templates;
    }

    @Override
    protected T1XTemplate getTemplate(T1XTemplateTag tag) {
        // Use the templates chosen in beginBytecode/do_methodTraceEntry
        T1XTemplate tx1Template = templates[tag.ordinal()];
        // reset to default
        templates = defaultT1X.templates;
        return tx1Template;
    }
}


switch(opcode) {
                        case Bytecodes.INVOKEINTERFACE:
                        case Bytecodes.INVOKESPECIAL:
                        case Bytecodes.INVOKESTATIC:
                        case Bytecodes.INVOKEVIRTUAL:
                            id |= JVMTIBreakpoints.SINGLE_STEP_AT_INVOKE;
                            break;
                        default:
                    }

package com.oracle.max.vm.ext.jvmti.t1x.armv7;

import static com.oracle.max.vm.ext.t1x.T1XTemplateTag.*;
import java.util.*;
import com.oracle.max.vm.ext.jvmti.*;
import com.oracle.max.vm.ext.jvmti.t1x.*;
import com.oracle.max.vm.ext.t1x.*;
import com.oracle.max.vm.ext.t1x.armv7.*;
import com.sun.cri.bytecode.*;
import com.sun.max.vm.*;
import com.sun.max.vm.actor.member.*;
import com.sun.max.vm.classfile.*;
import com.sun.max.vm.compiler.deps.*;
import com.sun.max.vm.jni.*;
import com.sun.max.vm.profile.*;

/**
 * Custom compilation class for generating JVMTI code-related events.
 *
 * When any JVMTI agents have requested <i>any</i> of the events that require compiled code modifications, an instance
 * of this class is used to compile a method.
 *
 * This class is capable of compiling code that is an exact match for the set of events that are needed. However, for
 * the debugging events, it can also operate in a mode where all possible events are compiled in from the
 * outset. Since single-step is one such event this effectively puts the code in interpreted mode, as the event delivery
 * code will be called on every bytecode. Evidently, it is the responsibility of the event delivery code to suppress
 * delivery of unwanted events. The remainder of the discussion assumes the strict mode.
 *
 * Prior to compilation, in {@link #initCompile}, a check is made for which kinds of events are required. This results
 * in {@link #eventSettings} having those bits sets, where the bit numbers correspond to the {@link JVMTIEvents} values.
 *
 * Some events, e.g., field access/modification events, require that modified templates be used to translate the
 * bytecode. Prior to each bytecode translation, the templates are set appropriately in {@link #setTemplates(boolean)}.
 *
 * Breakpoints are handled by checking every bytecode location against the list of set breakpoints and on a match,
 * generating the code for the breakpoint event (via a template for {@link Bytecodes#BREAKPOINT) before the code for the
 * actual bytecode (before advice essentially). There is no compelling need to recompile to remove a breakpoint, we just
 * don't deliver the event.
 *
 * TODO: Since field events are specified per field by the agent, a further optimization would be to determine whether
 * the specific field being accessed is subject to a watch.
 *
 * All per-compilation fields are reset in {@link #initCompile} so no extra {@link #cleanup() cleanup} is needed.
 */
public class JVMTI_ARMV7T1XCompilation extends ARMV7T1XCompilation {

    /**
     * The specific templates to be used for processing the current bytecode,
     * based on whether there are any agents registered for associated events.
     *
     * The choice is between {@link #compiler#templates} which are JVMTI enabled
     * and (@link altT1X#compiler#templates} which are the standard templates.
     */
    private T1XTemplate[] templates;

    /**
     * The breakpoints set in this method, or {@code null} if none. Sorted by location.
     */
    private long[] breakpoints;

    /**
     * The index of the next breakpoint (if any) to check for.
     */
    private int breakpointIndex;

    /**
     * {@link MethodID} for the method.
     */
    private MethodID methodID;

    /**
     * Indicates whether a bytecode has an associated event.
     */
    private BitSet eventBci;

    /**
     * The settings as a {@link JVMTIEvents} bitmask in effect for this compilation.
     */
    private long eventSettings;

    private static final JVMTIEvents.E GETFIELD_EVENT = JVMTI.eventForBytecode(Bytecodes.GETFIELD);

    private static final JVMTIEvents.E PUTFIELD_EVENT = JVMTI.eventForBytecode(Bytecodes.PUTFIELD);

    private static final JVMTIEvents.E RETURN_EVENT = JVMTI.eventForBytecode(Bytecodes.RETURN);

    private static final long DEBUG_EVENTS = JVMTIEvents.E.BREAKPOINT.bit | JVMTIEvents.E.SINGLE_STEP.bit | JVMTIEvents.E.FRAME_POP.bit | JVMTIEvents.E.EXCEPTION_CATCH.bit;

    /**
     * If {@code true}, all debugging-related events will compiled in from the get go.
     */
    private static boolean JVMTI_CDEARM;

    static {
        VMOptions.addFieldOption("-XX:", "JVMTI_CDEARM", JVMTI_ARMV7T1XCompilation.class, "Compile for all debugging events");
    }

    private final T1X defaultT1X;

    public JVMTI_ARMV7T1XCompilation(T1X compiler) {
        super(compiler);
        defaultT1X = T1X.stdT1X;
        templates = defaultT1X.templates;
    }

    @Override
    protected T1XTargetMethod newT1XTargetMethod(T1XCompilation comp, boolean install) {
        // if we compiled any event calls create a JVMTI_T1XTargetMethod, otherwise a vanilla one
        if (!eventBci.isEmpty()) {
            // disable the method profiler
            MethodProfile methodProfile = methodProfileBuilder.methodProfileObject();
            methodProfile.compilationDisabled = true;
            methodProfile.entryBackedgeCount = Integer.MAX_VALUE;
            // register the dependency
            Dependencies deps = JVMTI_DependencyProcessor.recordInstrumentation(method.holder(), eventSettings, breakpoints);
            assert deps != null;
            T1XTargetMethod targetMethod = new JVMTI_T1XTargetMethod(comp, install, eventBci);
            Dependencies.registerValidatedTarget(deps, targetMethod);
            return targetMethod;
        } else {
            return new T1XTargetMethod(comp, install);
        }
    }

    @Override
    protected void initCompile(ClassMethodActor method, CodeAttribute codeAttribute) {
        super.initCompile(method, codeAttribute);
        eventSettings = 0;
        eventBci = new BitSet(bciToPos.length);
        breakpoints = JVMTIBreakpoints.getBreakpoints(method);
        // N.B. Just because there are breakpoints defined, doesn't mean that
        // breakpoint events are currently enabled by the agent.
        // For simplicity, we make the connection in this code.
        if (breakpoints != null) {
            eventSettings |= JVMTIEvents.E.BREAKPOINT.bit;
        }
        breakpointIndex = 0;
        if (JVMTIBreakpoints.isSingleStepEnabled()) {
            eventSettings |= JVMTIEvents.E.SINGLE_STEP.bit;
        }
        methodID = MethodID.fromMethodActor(method);
        // METHOD_ENTRY
        checkByteCodeEventNeeded(-1);
        // METHOD_EXIT
        checkByteCodeEventNeeded(-2);
        checkByteCodeEventNeeded(Bytecodes.GETFIELD);
        checkByteCodeEventNeeded(Bytecodes.PUTFIELD);
        checkByteCodeEventNeeded(Bytecodes.RETURN);
        if (JVMTIEvents.isEventSet(JVMTIEvents.E.EXCEPTION_CATCH)) {
            eventSettings |= JVMTIEvents.E.EXCEPTION_CATCH.bit;
        }
        if (JVMTI_CDEARM) {
            // any debug events => all debug events
            if ((eventSettings & DEBUG_EVENTS) != 0) {
                eventSettings = DEBUG_EVENTS;
            }
        }
    }

    /**
     * Check whether instrumentation is needed for given bytecode, and set {@link #eventSettings} if so.
     * @param bytecode
     * @return the corresponding eventId or zero if not needed.
     */
    private void checkByteCodeEventNeeded(int bytecode) {
        JVMTIEvents.E event = JVMTI.byteCodeEventNeeded(bytecode);
        if (event != null) {
            eventSettings |= event.bit;
        }
    }

    @Override
    protected void do_methodTraceEntry() {
        if ((eventSettings & JVMTIEvents.E.METHOD_ENTRY.bit) != 0) {
            templates = compiler.templates;
            start(TRACE_METHOD_ENTRY);
            assignObject(0, "methodActor", method);
            finish();
        } else {
            super.do_methodTraceEntry();
        }
    }

    @Override
    protected void beginBytecode(int opcode) {
        // may invoke emitLoadException() if at handler
        super.beginBytecode(opcode);
        int currentBCI = stream.currentBCI();
        long id = 0;
        boolean eventCall = false;
        boolean singleStep = (eventSettings & JVMTIEvents.E.SINGLE_STEP.bit) != 0;
        boolean breakPossible = breakpoints != null && breakpointIndex < breakpoints.length;
        if (singleStep || breakPossible) {
            if (breakPossible && JVMTIBreakpoints.getLocation(breakpoints[breakpointIndex]) == currentBCI) {
                id = breakpoints[breakpointIndex++];
                if (singleStep) {
                    id |= JVMTIBreakpoints.SINGLE_STEP_AND_BREAK;
                }
            } else {
                if (singleStep) {
                    id = JVMTIBreakpoints.createSingleStepId(methodID, currentBCI);

                }
            }
            if (id != 0) {
                templates = compiler.templates;
                start(BREAKPOINT);
                assignLong(0, "id", id);
                finish();
                eventCall = true;
            }
        }
        boolean bytecodeEvent = false;
        switch(opcode) {
            case Bytecodes.GETFIELD:
            case Bytecodes.GETSTATIC:
                bytecodeEvent = (eventSettings & GETFIELD_EVENT.bit) != 0;
                break;
            case Bytecodes.PUTFIELD:
            case Bytecodes.PUTSTATIC:
                bytecodeEvent = (eventSettings & PUTFIELD_EVENT.bit) != 0;
                break;
            case Bytecodes.IRETURN:
            case Bytecodes.LRETURN:
            case Bytecodes.FRETURN:
            case Bytecodes.DRETURN:
            case Bytecodes.ARETURN:
            case Bytecodes.RETURN:
                bytecodeEvent = ((eventSettings & RETURN_EVENT.bit) != 0) || ((eventSettings & JVMTIEvents.E.METHOD_EXIT.bit) != 0);
                break;
            default:
        }
        if (bytecodeEvent) {
            eventCall = true;
            setTemplates(eventCall);
        }
        if (eventCall) {
            eventBci.set(currentBCI);
        }
    }

    @Override
    protected void emitLoadException(int bci) {
        if ((eventSettings & JVMTIEvents.E.EXCEPTION_CATCH.bit) != 0) {
            setTemplates(true);
            eventBci.set(bci);
        }
        super.emitLoadException(bci);
    }

    private void setTemplates(boolean jvmti) {
        templates = jvmti ? compiler.templates : defaultT1X.templates;
    }

    @Override
    protected T1XTemplate getTemplate(T1XTemplateTag tag) {
        // Use the templates chosen in beginBytecode/do_methodTraceEntry
        T1XTemplate tx1Template = templates[tag.ordinal()];
        // reset to default
        templates = defaultT1X.templates;
        return tx1Template;
    }
}


public static void main(String[] args) {
        WordList wl = new WordList(2);
    }

/*
 * 文件名：WordList.java
 * 描述：程序总入口
 * 修改人：xpqiu
 * 修改时间：Nov 30, 2008
 * 修改内容：新增
 *
 * 修改人：〈修改人〉
 * 修改时间：YYYY-MM-DD
 * 跟踪单号：〈跟踪单号〉
 * 修改单号：〈修改单号〉
 * 修改内容：〈修改内容〉
 */
package edu.fudan.nlp.corpus;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/**
 * @author xpqiu
 * @version 1.0
 * WordList
 */
public class WordList {

    class WordTree implements Serializable {

        private static final long serialVersionUID = 523580450351093949L;

        HashSet<String> wordSet;

        int depth;

        String tag;

        ArrayList<WordTree> childs;

        public WordTree() {
            wordSet = new HashSet<String>();
            childs = new ArrayList<WordTree>();
        }
    }

    // 字典，用来生成字典特征
    public static WordTree dicts = null;

    public String dicDir = "../Data/wordlist";

    public WordList(int depth) {
        if (dicts == null) {
            loaddict(depth);
        }
    }

    public String getFeatures(String word, String tag) {
        return getFeaturesFromNodes(dicts, word, tag, 1);
    }

    public String getFeaturesFromNodes(WordTree node, String word, String tag, int depth) {
        if (node.depth > depth)
            return " ";
        String res = "";
        String newfeature = tag;
        newfeature = newfeature + node.tag + ".";
        if (node.wordSet.size() > 0) {
            if (node.wordSet.contains(word))
                newfeature = newfeature + "1 ";
            else
                newfeature = newfeature + "0 ";
            res = res + newfeature;
        }
        Iterator<WordTree> it = node.childs.iterator();
        while (it.hasNext()) {
            WordTree subnode = it.next();
            if (subnode == null)
                continue;
            res = res + getFeaturesFromNodes(subnode, word, newfeature, depth);
        }
        return res;
    }

    private void loaddict(int depth) {
        dicts = new WordTree();
        dicts.depth = -1;
        dicts.tag = "";
        File f = new File(dicDir);
        if (!f.exists())
            return;
        else
            loadDir(f, dicts, depth);
    }

    /**
     * @param dicts
     * @param file
     */
    private void loadDir(File f, WordTree parent, int depth) {
        WordTree current;
        if (parent.depth >= depth)
            current = parent;
        else {
            current = new WordTree();
            parent.childs.add(current);
            current.depth = parent.depth + 1;
            current.tag = f.getName().replace(".dic", "");
        }
        if (f.isDirectory()) {
            File[] flist = f.listFiles(new FilenameFilter() {

                public boolean accept(File dir, String name) {
                    if (name.endsWith(".dic"))
                        return true;
                    else
                        return false;
                }
            });
            for (int i = 0; i < flist.length; i++) loadDir(flist[i], current, depth);
        } else {
            if (!f.toString().endsWith(".dic"))
                return;
            try {
                InputStreamReader read = new InputStreamReader(new FileInputStream(f.toString()), "utf-8");
                BufferedReader bin = new BufferedReader(read);
                String w;
                while ((w = bin.readLine()) != null) {
                    current.wordSet.add(w.trim());
                }
            } catch (Exception e) {
            }
        }
    }

    /**
     * @param args
     */


while (it.hasNext()) {
            WordTree subnode = it.next();
            if (subnode == null)
                continue;
            res = res + getFeaturesFromNodes(subnode, word, newfeature, depth);
        }

/*
 * 文件名：WordList.java
 * 描述：程序总入口
 * 修改人：xpqiu
 * 修改时间：Nov 30, 2008
 * 修改内容：新增
 *
 * 修改人：〈修改人〉
 * 修改时间：YYYY-MM-DD
 * 跟踪单号：〈跟踪单号〉
 * 修改单号：〈修改单号〉
 * 修改内容：〈修改内容〉
 */
package edu.fudan.nlp.corpus;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/**
 * @author xpqiu
 * @version 1.0
 * WordList
 */
public class WordList {

    class WordTree implements Serializable {

        private static final long serialVersionUID = 523580450351093949L;

        HashSet<String> wordSet;

        int depth;

        String tag;

        ArrayList<WordTree> childs;

        public WordTree() {
            wordSet = new HashSet<String>();
            childs = new ArrayList<WordTree>();
        }
    }

    // 字典，用来生成字典特征
    public static WordTree dicts = null;

    public String dicDir = "../Data/wordlist";

    public WordList(int depth) {
        if (dicts == null) {
            loaddict(depth);
        }
    }

    public String getFeatures(String word, String tag) {
        return getFeaturesFromNodes(dicts, word, tag, 1);
    }

    public String getFeaturesFromNodes(WordTree node, String word, String tag, int depth) {
        if (node.depth > depth)
            return " ";
        String res = "";
        String newfeature = tag;
        newfeature = newfeature + node.tag + ".";
        if (node.wordSet.size() > 0) {
            if (node.wordSet.contains(word))
                newfeature = newfeature + "1 ";
            else
                newfeature = newfeature + "0 ";
            res = res + newfeature;
        }
        Iterator<WordTree> it = node.childs.iterator();

        return res;
    }

    private void loaddict(int depth) {
        dicts = new WordTree();
        dicts.depth = -1;
        dicts.tag = "";
        File f = new File(dicDir);
        if (!f.exists())
            return;
        else
            loadDir(f, dicts, depth);
    }

    /**
     * @param dicts
     * @param file
     */
    private void loadDir(File f, WordTree parent, int depth) {
        WordTree current;
        if (parent.depth >= depth)
            current = parent;
        else {
            current = new WordTree();
            parent.childs.add(current);
            current.depth = parent.depth + 1;
            current.tag = f.getName().replace(".dic", "");
        }
        if (f.isDirectory()) {
            File[] flist = f.listFiles(new FilenameFilter() {

                public boolean accept(File dir, String name) {
                    if (name.endsWith(".dic"))
                        return true;
                    else
                        return false;
                }
            });
            for (int i = 0; i < flist.length; i++) loadDir(flist[i], current, depth);
        } else {
            if (!f.toString().endsWith(".dic"))
                return;
            try {
                InputStreamReader read = new InputStreamReader(new FileInputStream(f.toString()), "utf-8");
                BufferedReader bin = new BufferedReader(read);
                String w;
                while ((w = bin.readLine()) != null) {
                    current.wordSet.add(w.trim());
                }
            } catch (Exception e) {
            }
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        WordList wl = new WordList(2);
    }
}


public void fatalError(String domain, String key, XMLParseException ex) throws XNIException {
        printError("Fatal Error", ex);
        throw ex;
    }

package com.sun.org.apache.xerces.internal.util;

import java.io.PrintWriter;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;

/**
 * Default error handler.
 *
 * @author Andy Clark, IBM
 */
public class DefaultErrorHandler implements XMLErrorHandler {

    // Data
    /**
     * Print writer.
     */
    protected PrintWriter fOut;

    // Constructors
    /**
     * Constructs an error handler that prints error messages to
     * System.err.
     */
    public DefaultErrorHandler() {
        this(new PrintWriter(System.err));
    }

    /**
     * Constructs an error handler that prints error messages to the
     * specified PrintWriter</code.
     */
    public DefaultErrorHandler(PrintWriter out) {
        fOut = out;
    }

    // ErrorHandler methods
    public void warning(String domain, String key, XMLParseException ex) throws XNIException {
        printError("Warning", ex);
    }

    public void error(String domain, String key, XMLParseException ex) throws XNIException {
        printError("Error", ex);
    }

    /**
     * Fatal error.
     */

    // Private methods
    /**
     * Prints the error message.
     */
    private void printError(String type, XMLParseException ex) {
        fOut.print("[");
        fOut.print(type);
        fOut.print("] ");
        String systemId = ex.getExpandedSystemId();
        if (systemId != null) {
            int index = systemId.lastIndexOf('/');
            if (index != -1)
                systemId = systemId.substring(index + 1);
            fOut.print(systemId);
        }
        fOut.print(':');
        fOut.print(ex.getLineNumber());
        fOut.print(':');
        fOut.print(ex.getColumnNumber());
        fOut.print(": ");
        fOut.print(ex.getMessage());
        fOut.println();
        fOut.flush();
    }
}


public float getPetalLength() {
        return petalLength;
    }

package ai.djl.onnxruntime.zoo.tabular.softmax_regression;

/**
 * A class holds the iris flower features.
 */
public class IrisFlower {

    private float sepalLength;

    private float sepalWidth;

    private float petalLength;

    private float petalWidth;

    /**
     * Constructs a new {@code IrisFlower} instance.
     *
     * @param sepalLength the sepal length
     * @param sepalWidth the sepal width
     * @param petalLength the petal length
     * @param petalWidth the petal width
     */
    public IrisFlower(float sepalLength, float sepalWidth, float petalLength, float petalWidth) {
        this.sepalLength = sepalLength;
        this.sepalWidth = sepalWidth;
        this.petalLength = petalLength;
        this.petalWidth = petalWidth;
    }

    /**
     * Returns the sepal length.
     *
     * @return the sepal length
     */
    public float getSepalLength() {
        return sepalLength;
    }

    /**
     * Returns the sepal width.
     *
     * @return the sepal width
     */
    public float getSepalWidth() {
        return sepalWidth;
    }

    /**
     * Returns the petal length.
     *
     * @return the petal length
     */

    /**
     * Returns the petal width.
     *
     * @return the petal width
     */
    public float getPetalWidth() {
        return petalWidth;
    }
}


public List<Pair<T, Double>> getPmf() {
        final List<Pair<T, Double>> samples = new ArrayList<>(probabilities.length);
        for (int i = 0; i < probabilities.length; i++) {
            samples.add(new Pair<>(singletons.get(i), probabilities[i]));
        }
        return samples;
    }

package org.apache.commons.math4.legacy.distribution;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math4.legacy.exception.MathArithmeticException;
import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.math4.legacy.exception.NotFiniteNumberException;
import org.apache.commons.math4.legacy.exception.NotPositiveException;
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.sampling.DiscreteProbabilityCollectionSampler;
import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.math4.legacy.core.Pair;

/**
 *
A generic implementation of a
 *
 * discrete probability distribution (Wikipedia) over a finite sample space,
 * based on an enumerated list of <value, probability> pairs.  Input probabilities must all be non-negative,
 * but zero values are allowed and their sum does not have to equal one. Constructors will normalize input
 * probabilities to make them sum to one.

 *
 *
The list of <value, probability> pairs does not, strictly speaking, have to be a function and it can
 * contain null values.  The pmf created by the constructor will combine probabilities of equal values and
 * will treat null values as equal.  For example, if the list of pairs <"dog", 0.2>, <null, 0.1>,
 * <"pig", 0.2>, <"dog", 0.1>, <null, 0.4> is provided to the constructor, the resulting
 * pmf will assign mass of 0.5 to null, 0.3 to "dog" and 0.2 to pig.

 *
 * @param <T> type of the elements in the sample space.
 * @since 3.2
 */
public class EnumeratedDistribution<T> {

    /**
     * List of random variable values.
     */
    private final List<T> singletons;

    /**
     * Probabilities of respective random variable values. For i = 0, ..., singletons.size() - 1,
     * probability[i] is the probability that a random variable following this distribution takes
     * the value singletons[i].
     */
    private final double[] probabilities;

    /**
     * Cumulative probabilities, cached to speed up sampling.
     */
    private final double[] cumulativeProbabilities;

    /**
     * Create an enumerated distribution using the given random number generator
     * and probability mass function enumeration.
     *
     * @param pmf probability mass function enumerated as a list of
     * {@code <T, probability>} pairs.
     * @throws NotPositiveException if any of the probabilities are negative.
     * @throws NotFiniteNumberException if any of the probabilities are infinite.
     * @throws NotANumberException if any of the probabilities are NaN.
     * @throws MathArithmeticException all of the probabilities are 0.
     */
    public EnumeratedDistribution(final List<Pair<T, Double>> pmf) throws NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException {
        singletons = new ArrayList<>(pmf.size());
        final double[] probs = new double[pmf.size()];
        int count = 0;
        for (Pair<T, Double> sample : pmf) {
            singletons.add(sample.getKey());
            final double p = sample.getValue();
            if (p < 0) {
                throw new NotPositiveException(sample.getValue());
            }
            if (Double.isInfinite(p)) {
                throw new NotFiniteNumberException(p);
            }
            if (Double.isNaN(p)) {
                throw new NotANumberException();
            }
            probs[count++] = p;
        }
        probabilities = MathArrays.normalizeArray(probs, 1.0);
        cumulativeProbabilities = new double[probabilities.length];
        double sum = 0;
        for (int i = 0; i < probabilities.length; i++) {
            sum += probabilities[i];
            cumulativeProbabilities[i] = sum;
        }
    }

    /**
     *
For a random variable {@code X} whose values are distributed according to
     * this distribution, this method returns {@code P(X = x)}. In other words,
     * this method represents the probability mass function (PMF) for the
     * distribution.

     *
     *
Note that if {@code x1} and {@code x2} satisfy {@code x1.equals(x2)},
     * or both are null, then {@code probability(x1) = probability(x2)}.

     *
     * @param x the point at which the PMF is evaluated
     * @return the value of the probability mass function at {@code x}
     */
    double probability(final T x) {
        double probability = 0;
        for (int i = 0; i < probabilities.length; i++) {
            if ((x == null && singletons.get(i) == null) || (x != null && x.equals(singletons.get(i)))) {
                probability += probabilities[i];
            }
        }
        return probability;
    }

    /**
     *
Return the probability mass function as a list of <value, probability> pairs.

     *
     *
Note that if duplicate and / or null values were provided to the constructor
     * when creating this EnumeratedDistribution, the returned list will contain these
     * values.  If duplicates values exist, what is returned will not represent
     * a pmf (i.e., it is up to the caller to consolidate duplicate mass points).

     *
     * @return the probability mass function.
     */

/**
     * Creates a {@link Sampler}.
     *
     * @param rng Random number generator.
     * @return a new sampler instance.
     */
    public Sampler createSampler(final UniformRandomProvider rng) {
        return new Sampler(rng);
    }

    /**
     * Sampler functionality.
     *
     *

     *

     *   The cumulative probability distribution is created (and sampled from)
     *   using the input order of the {@link EnumeratedDistribution#EnumeratedDistribution(List)
     *   constructor arguments}: A different input order will create a different
     *   sequence of samples.
     *   The samples will only be reproducible with the same RNG starting from
     *   the same RNG state and the same input order to constructor.
     *

     *

     *   The minimum supported probability is 2-53.
     *

     *

     */
    public class Sampler {

        /**
         * Underlying sampler.
         */
        private final DiscreteProbabilityCollectionSampler<T> sampler;

        /**
         * @param rng Random number generator.
         */
        Sampler(UniformRandomProvider rng) {
            sampler = new DiscreteProbabilityCollectionSampler<T>(rng, singletons, probabilities);
        }

        /**
         * Generates a random value sampled from this distribution.
         *
         * @return a random value.
         */
        public T sample() {
            return sampler.sample();
        }

        /**
         * Generates a random sample from the distribution.
         *
         * @param sampleSize the number of random values to generate.
         * @return an array representing the random sample.
         * @throws NotStrictlyPositiveException if {@code sampleSize} is not
         * positive.
         */
        public Object[] sample(int sampleSize) throws NotStrictlyPositiveException {
            if (sampleSize <= 0) {
                throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize);
            }
            final Object[] out = new Object[sampleSize];
            for (int i = 0; i < sampleSize; i++) {
                out[i] = sample();
            }
            return out;
        }

        /**
         * Generates a random sample from the distribution.
         *

         * If the requested samples fit in the specified array, it is returned
         * therein. Otherwise, a new array is allocated with the runtime type of
         * the specified array and the size of this collection.
         *
         * @param sampleSize the number of random values to generate.
         * @param array the array to populate.
         * @return an array representing the random sample.
         * @throws NotStrictlyPositiveException if {@code sampleSize} is not positive.
         * @throws NullArgumentException if {@code array} is null
         */
        public T[] sample(int sampleSize, final T[] array) throws NotStrictlyPositiveException {
            if (sampleSize <= 0) {
                throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize);
            }
            if (array == null) {
                throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
            }
            T[] out;
            if (array.length < sampleSize) {
                // safe as both are of type T
                @SuppressWarnings("unchecked")
                final T[] unchecked = (T[]) Array.newInstance(array.getClass().getComponentType(), sampleSize);
                out = unchecked;
            } else {
                out = array;
            }
            for (int i = 0; i < sampleSize; i++) {
                out[i] = sample();
            }
            return out;
        }
    }
}


public boolean isSelected() {
        return selected;
    }

/*
 *
 *
 * Open Source Software ("FLOSS") applications as described in Silverpeas's
 * FLOSS exception.  You should have received a copy of the text describing
 * the FLOSS exception, and it is also available here:
 * "http://example.com"
 *
 */
package org.silverpeas.web.silverstatistics.vo;

public class StatisticAxisVO {

    private String id = null;

    private String name = null;

    private String description = null;

    private boolean selected = false;

    /**
     * Default constructor
     * @param id
     * @param name
     * @param description
     * @param selected
     */
    public StatisticAxisVO(String id, String name, String description, boolean selected) {
        super();
        this.id = id;
        this.name = name;
        this.description = description;
        this.selected = selected;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the selected
     */

    /**
     * @param selected the selected to set
     */
    public void setSelected(boolean selected) {
        this.selected = selected;
    }
}


switch(c) {
                        case 0:
                        case '<':
                        case '>':
                        case '/':
                        case '=':
                        case '!':
                        case '?':
                        case '"':
                        case '\'':
                            back();
                            return Boolean.TRUE;
                    }

package org.json;

/**
 * The XMLTokener extends the JSONTokener to provide additional methods
 * for the parsing of XML texts.
 * @author JSON.org
 * @version 2008-09-18
 */
public class XMLTokener extends JSONTokener {

    /**
     * The table of entity values. It initially contains Character values for
     * amp, apos, gt, lt, quot.
     */
    public static final java.util.HashMap entity;

    static {
        entity = new java.util.HashMap(8);
        entity.put("amp", XML.AMP);
        entity.put("apos", XML.APOS);
        entity.put("gt", XML.GT);
        entity.put("lt", XML.LT);
        entity.put("quot", XML.QUOT);
    }

    /**
     * Construct an XMLTokener from a string.
     * @param s A source string.
     */
    public XMLTokener(String s) {
        super(s);
    }

    /**
     * Get the text in the CDATA block.
     * @return The string up to the ]]>.
     * @throws JSONException If the ]]> is not found.
     */
    public String nextCDATA() throws JSONException {
        char c;
        int i;
        StringBuffer sb = new StringBuffer();
        for (; ; ) {
            c = next();
            if (c == 0) {
                throw syntaxError("Unclosed CDATA");
            }
            sb.append(c);
            i = sb.length() - 3;
            if (i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
                sb.setLength(i);
                return sb.toString();
            }
        }
    }

    /**
     * Get the next XML outer token, trimming whitespace. There are two kinds
     * of tokens: the '<' character which begins a markup tag, and the content
     * text between markup tags.
     *
     * @return  A string, or a '<' Character, or null if there is no more
     * source text.
     * @throws JSONException
     */
    public Object nextContent() throws JSONException {
        char c;
        StringBuffer sb;
        do {
            c = next();
        } while (Character.isWhitespace(c));
        if (c == 0) {
            return null;
        }
        if (c == '<') {
            return XML.LT;
        }
        sb = new StringBuffer();
        for (; ; ) {
            if (c == '<' || c == 0) {
                back();
                return sb.toString().trim();
            }
            if (c == '&') {
                sb.append(nextEntity(c));
            } else {
                sb.append(c);
            }
            c = next();
        }
    }

    /**
     * Return the next entity. These entities are translated to Characters:
     *     &  '  >  <  ".
     * @param a An ampersand character.
     * @return  A Character or an entity String if the entity is not recognized.
     * @throws JSONException If missing ';' in XML entity.
     */
    public Object nextEntity(char a) throws JSONException {
        StringBuffer sb = new StringBuffer();
        for (; ; ) {
            char c = next();
            if (Character.isLetterOrDigit(c) || c == '#') {
                sb.append(Character.toLowerCase(c));
            } else if (c == ';') {
                break;
            } else {
                throw syntaxError("Missing ';' in XML entity: &" + sb);
            }
        }
        String s = sb.toString();
        Object e = entity.get(s);
        return e != null ? e : a + s + ";";
    }

    /**
     * Returns the next XML meta token. This is used for skipping over <!...>
     * and <?...?> structures.
     * @return Syntax characters (< > / = ! ?) are returned as
     *  Character, and strings and names are returned as Boolean. We don't care
     *  what the values actually are.
     * @throws JSONException If a string is not properly closed or if the XML
     *  is badly structured.
     */
    public Object nextMeta() throws JSONException {
        char c;
        char q;
        do {
            c = next();
        } while (Character.isWhitespace(c));
        switch(c) {
            case 0:
                throw syntaxError("Misshaped meta tag");
            case '<':
                return XML.LT;
            case '>':
                return XML.GT;
            case '/':
                return XML.SLASH;
            case '=':
                return XML.EQ;
            case '!':
                return XML.BANG;
            case '?':
                return XML.QUEST;
            case '"':
            case '\'':
                q = c;
                for (; ; ) {
                    c = next();
                    if (c == 0) {
                        throw syntaxError("Unterminated string");
                    }
                    if (c == q) {
                        return Boolean.TRUE;
                    }
                }
            default:
                for (; ; ) {
                    c = next();
                    if (Character.isWhitespace(c)) {
                        return Boolean.TRUE;
                    }

                }
        }
    }

    /**
     * Get the next XML Token. These tokens are found inside of angle
     * brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
     * may be a string wrapped in single quotes or double quotes, or it may be a
     * name.
     * @return a String or a Character.
     * @throws JSONException If the XML is not well formed.
     */
    public Object nextToken() throws JSONException {
        char c;
        char q;
        StringBuffer sb;
        do {
            c = next();
        } while (Character.isWhitespace(c));
        switch(c) {
            case 0:
                throw syntaxError("Misshaped element");
            case '<':
                throw syntaxError("Misplaced '<'");
            case '>':
                return XML.GT;
            case '/':
                return XML.SLASH;
            case '=':
                return XML.EQ;
            case '!':
                return XML.BANG;
            case '?':
                return XML.QUEST;
            // Quoted string
            case '"':
            case '\'':
                q = c;
                sb = new StringBuffer();
                for (; ; ) {
                    c = next();
                    if (c == 0) {
                        throw syntaxError("Unterminated string");
                    }
                    if (c == q) {
                        return sb.toString();
                    }
                    if (c == '&') {
                        sb.append(nextEntity(c));
                    } else {
                        sb.append(c);
                    }
                }
            default:
                // Name
                sb = new StringBuffer();
                for (; ; ) {
                    sb.append(c);
                    c = next();
                    if (Character.isWhitespace(c)) {
                        return sb.toString();
                    }
                    switch(c) {
                        case 0:
                            return sb.toString();
                        case '>':
                        case '/':
                        case '=':
                        case '!':
                        case '?':
                        case '[':
                        case ']':
                            back();
                            return sb.toString();
                        case '<':
                        case '"':
                        case '\'':
                            throw syntaxError("Bad character in a name");
                    }
                }
        }
    }

    /**
     * Skip characters until past the requested string.
     * If it is not found, we are left at the end of the source with a result of false.
     * @param to A string to skip past.
     * @throws JSONException
     */
    public boolean skipPast(String to) throws JSONException {
        boolean b;
        char c;
        int i;
        int j;
        int offset = 0;
        int n = to.length();
        char[] circle = new char[n];
        /*
         * First fill the circle buffer with as many characters as are in the
         * to string. If we reach an early end, bail.
         */
        for (i = 0; i < n; i += 1) {
            c = next();
            if (c == 0) {
                return false;
            }
            circle[i] = c;
        }
        /*
    	 * We will loop, possibly for all of the remaining characters.
    	 */
        for (; ; ) {
            j = offset;
            b = true;
            /*
    		 * Compare the circle buffer with the to string.
    		 */
            for (i = 0; i < n; i += 1) {
                if (circle[j] != to.charAt(i)) {
                    b = false;
                    break;
                }
                j += 1;
                if (j >= n) {
                    j -= n;
                }
            }
            /*
    		 * If we exit the loop with b intact, then victory is ours.
    		 */
            if (b) {
                return true;
            }
            /*
    		 * Get the next character. If there isn't one, then defeat is ours.
    		 */
            c = next();
            if (c == 0) {
                return false;
            }
            /*
    		 * Shove the character in the circle buffer and advance the
    		 * circle offset. The offset is mod n.
    		 */
            circle[offset] = c;
            offset += 1;
            if (offset >= n) {
                offset -= n;
            }
        }
    }
}