public static boolean isValid(String componentId) {
        try {
            validate(componentId);
            return true;
        } catch (final IllegalArgumentException e) {
            return false;
        }
    }

package com.b2international.snowowl.snomed.cis;

import static com.google.common.base.Preconditions.checkArgument;
import java.util.Collection;
import com.b2international.commons.VerhoeffCheck;
import com.b2international.snowowl.core.terminology.ComponentCategory;
import com.b2international.snowowl.snomed.cis.internal.SnomedComponentIdentifierValidator;
import com.b2international.snowowl.snomed.cis.internal.SnomedIdentifierImpl;
import com.google.common.base.Strings;

/**
 * Contains utility methods related to SCTID part checks.
 *
 * @since 4.0
 */
public class SnomedIdentifiers {

    public static final String INT_NAMESPACE = "INT";

    // inclusive
    public static final long MIN_INT_ITEMID = 100L;

    public static final long MAX_INT_ITEMID = 9999_9999_9999_999L + 1L;

    // inclusive
    public static final long MIN_NAMESPACE_ITEMID = 1L;

    public static final long MAX_NAMESPACE_ITEMID = 9999_9999L + 1L;

    /**
     * @param componentId - the ID to check
     * @return true if the given componentId is a valid SNOMED CT core component identifier, false otherwise.
     * @see #validate(String)
     */

/**
     * Validates the given componentId by using the rules defined in the latest SNOMED CT Identifier specification, which are the following constraints:
     *

     *
Can't start with leading zeros

     *
Lengths should be between 6 and 18 characters

     *
Should parse to a long value

     *
Should have partition ID 0 or 1

     *
Should have a component ID of 0, 1 or 2

     *
Should pass the Verhoeff check-digit test

     *

     *
     * @param componentId
     * @see VerhoeffCheck
     * @throws IllegalArgumentException
     *             - if the given componentId is invalid according to the SNOMED
     *             CT Identifier specification
     */
    public static void validate(final String componentId) throws IllegalArgumentException {
        checkArgument(!Strings.isNullOrEmpty(componentId), "SCTID may not be null or empty");
        checkArgument(!componentId.startsWith("0"), "SCTID can't start with leading zero. Got: %s", componentId);
        checkArgument(componentId.length() >= 6 && componentId.length() <= 18, "SCTID length must be between 6-18 characters. Got: %s", componentId);
        try {
            Long.parseLong(componentId);
        } catch (final NumberFormatException e) {
            throw new IllegalArgumentException("SCTID should be parseable to a long value");
        }
        // may throw IllegalArgumentException if the componentId has incorrect partition ID
        isShortForm(componentId);
        // may throw IllegalArgumentException if the componentId has incorrect component identifier
        getComponentIdentifier(componentId);
        final CharSequence idHead = componentId.subSequence(0, componentId.length() - 1);
        final char originalChecksum = componentId.charAt(componentId.length() - 1);
        final char checksum = VerhoeffCheck.calculateChecksum(idHead, false);
        checkArgument(VerhoeffCheck.validateLastChecksumDigit(componentId), "%s has incorrect Verhoeff check-digit; expected %s, was %s", componentId, checksum, originalChecksum);
    }

    /**
     * Validates the given collection of componentIds by using the rules defined
     * in the latest SNOMED CT Identifier specification, which are the following
     * constraints:
     *

     *
Can't start with leading zeros

     *
Lengths should be between 6 and 18 characters

     *
Should parse to a long value

     *
Should pass the Verhoeff check-digit test

     *

     *
     * @param componentIds
     * @see VerhoeffCheck
     * @throws IllegalArgumentException
     *             - if the given collection contains a component ID which is
     *             invalid according to the SNOMED CT Identifier specification
     */
    public static void validate(final Collection<String> componentIds) {
        for (final String componentId : componentIds) {
            validate(componentId);
        }
    }

    public static String getNamespace(final String componentId) {
        final boolean shortForm = isShortForm(componentId);
        if (shortForm) {
            return "";
        } else {
            return componentId.substring(componentId.length() - 10, componentId.length() - 3);
        }
    }

    private static boolean isShortForm(final String componentId) {
        final char firstPartitionIdDigit = componentId.charAt(componentId.length() - 3);
        if (firstPartitionIdDigit == '0') {
            return true;
        } else if (firstPartitionIdDigit == '1') {
            return false;
        } else {
            throw new IllegalArgumentException(String.format("First digit of partition identifier must be '0' or '1', got '%s' for input '%s'.", firstPartitionIdDigit, componentId));
        }
    }

    public static ComponentCategory getComponentCategory(final String componentId) {
        return ComponentCategory.getByOrdinal(getComponentIdentifier(componentId));
    }

    private static int getComponentIdentifier(final String componentId) {
        final char secondPartitionIdDigit = componentId.charAt(componentId.length() - 2);
        final int ci = Character.digit(secondPartitionIdDigit, 10);
        if (ci >= 0 && ci <= 2) {
            return ci;
        } else {
            throw new IllegalArgumentException(String.format("Second digit of partition identifier must be between '0' and '2', got '%s' for input '%s'.", secondPartitionIdDigit, componentId));
        }
    }

    public static SnomedIdentifierValidator getIdentifierValidator(final ComponentCategory category) {
        switch(category) {
            case CONCEPT:
            case DESCRIPTION:
            case RELATIONSHIP:
                return new SnomedComponentIdentifierValidator(category);
            default:
                throw new UnsupportedOperationException("Can't create validator for category: " + category);
        }
    }

    public static boolean isConceptIdentifier(final String componentId) {
        try {
            validate(componentId);
            return ComponentCategory.CONCEPT == getComponentCategory(componentId);
        } catch (final IllegalArgumentException e) {
            return false;
        }
    }

    public static long getItemId(final String componentId) {
        final boolean shortForm = isShortForm(componentId);
        final String itemId;
        if (shortForm) {
            itemId = componentId.substring(0, componentId.length() - 3);
        } else {
            itemId = componentId.substring(0, componentId.length() - 10);
        }
        try {
            return Long.parseLong(itemId);
        } catch (final NumberFormatException e) {
            throw new IllegalArgumentException(String.format("Item identifier must be parseable to a long, got '%s' for input '%s'.", itemId, componentId));
        }
    }

    public static String getPartitionId(final String componentId) {
        return componentId.substring(componentId.length() - 3, componentId.length() - 1);
    }

    public static int getCheckDigit(final String componentId) {
        final char checkDigit = componentId.charAt(componentId.length() - 1);
        final int cd = Character.digit(checkDigit, 10);
        if (cd >= 0 && cd <= 9) {
            return cd;
        } else {
            throw new IllegalArgumentException(String.format("Check digit must be between '0' and '9', got '%s' for input '%s'.", checkDigit, componentId));
        }
    }

    /**
     * Creates a {@link SnomedIdentifier} instance from the given {@link String} componentId.
     */
    public static SnomedIdentifier create(final String componentId) {
        validate(componentId);
        final long itemId = getItemId(componentId);
        final String namespace = getNamespace(componentId);
        final int formatIdentifier = isShortForm(componentId) ? 0 : 1;
        final int componentIdentifier = getComponentIdentifier(componentId);
        final int checkDigit = getCheckDigit(componentId);
        return new SnomedIdentifierImpl(itemId, namespace, formatIdentifier, componentIdentifier, checkDigit);
    }
}


switch(category) {
            case CONCEPT:
            case DESCRIPTION:
            case RELATIONSHIP:
                return new SnomedComponentIdentifierValidator(category);
            default:
                throw new UnsupportedOperationException("Can't create validator for category: " + category);
        }

package com.b2international.snowowl.snomed.cis;

import static com.google.common.base.Preconditions.checkArgument;
import java.util.Collection;
import com.b2international.commons.VerhoeffCheck;
import com.b2international.snowowl.core.terminology.ComponentCategory;
import com.b2international.snowowl.snomed.cis.internal.SnomedComponentIdentifierValidator;
import com.b2international.snowowl.snomed.cis.internal.SnomedIdentifierImpl;
import com.google.common.base.Strings;

/**
 * Contains utility methods related to SCTID part checks.
 *
 * @since 4.0
 */
public class SnomedIdentifiers {

    public static final String INT_NAMESPACE = "INT";

    // inclusive
    public static final long MIN_INT_ITEMID = 100L;

    public static final long MAX_INT_ITEMID = 9999_9999_9999_999L + 1L;

    // inclusive
    public static final long MIN_NAMESPACE_ITEMID = 1L;

    public static final long MAX_NAMESPACE_ITEMID = 9999_9999L + 1L;

    /**
     * @param componentId - the ID to check
     * @return true if the given componentId is a valid SNOMED CT core component identifier, false otherwise.
     * @see #validate(String)
     */
    public static boolean isValid(String componentId) {
        try {
            validate(componentId);
            return true;
        } catch (final IllegalArgumentException e) {
            return false;
        }
    }

    /**
     * Validates the given componentId by using the rules defined in the latest SNOMED CT Identifier specification, which are the following constraints:
     *

     *
Can't start with leading zeros

     *
Lengths should be between 6 and 18 characters

     *
Should parse to a long value

     *
Should have partition ID 0 or 1

     *
Should have a component ID of 0, 1 or 2

     *
Should pass the Verhoeff check-digit test

     *

     *
     * @param componentId
     * @see VerhoeffCheck
     * @throws IllegalArgumentException
     *             - if the given componentId is invalid according to the SNOMED
     *             CT Identifier specification
     */
    public static void validate(final String componentId) throws IllegalArgumentException {
        checkArgument(!Strings.isNullOrEmpty(componentId), "SCTID may not be null or empty");
        checkArgument(!componentId.startsWith("0"), "SCTID can't start with leading zero. Got: %s", componentId);
        checkArgument(componentId.length() >= 6 && componentId.length() <= 18, "SCTID length must be between 6-18 characters. Got: %s", componentId);
        try {
            Long.parseLong(componentId);
        } catch (final NumberFormatException e) {
            throw new IllegalArgumentException("SCTID should be parseable to a long value");
        }
        // may throw IllegalArgumentException if the componentId has incorrect partition ID
        isShortForm(componentId);
        // may throw IllegalArgumentException if the componentId has incorrect component identifier
        getComponentIdentifier(componentId);
        final CharSequence idHead = componentId.subSequence(0, componentId.length() - 1);
        final char originalChecksum = componentId.charAt(componentId.length() - 1);
        final char checksum = VerhoeffCheck.calculateChecksum(idHead, false);
        checkArgument(VerhoeffCheck.validateLastChecksumDigit(componentId), "%s has incorrect Verhoeff check-digit; expected %s, was %s", componentId, checksum, originalChecksum);
    }

    /**
     * Validates the given collection of componentIds by using the rules defined
     * in the latest SNOMED CT Identifier specification, which are the following
     * constraints:
     *

     *
Can't start with leading zeros

     *
Lengths should be between 6 and 18 characters

     *
Should parse to a long value

     *
Should pass the Verhoeff check-digit test

     *

     *
     * @param componentIds
     * @see VerhoeffCheck
     * @throws IllegalArgumentException
     *             - if the given collection contains a component ID which is
     *             invalid according to the SNOMED CT Identifier specification
     */
    public static void validate(final Collection<String> componentIds) {
        for (final String componentId : componentIds) {
            validate(componentId);
        }
    }

    public static String getNamespace(final String componentId) {
        final boolean shortForm = isShortForm(componentId);
        if (shortForm) {
            return "";
        } else {
            return componentId.substring(componentId.length() - 10, componentId.length() - 3);
        }
    }

    private static boolean isShortForm(final String componentId) {
        final char firstPartitionIdDigit = componentId.charAt(componentId.length() - 3);
        if (firstPartitionIdDigit == '0') {
            return true;
        } else if (firstPartitionIdDigit == '1') {
            return false;
        } else {
            throw new IllegalArgumentException(String.format("First digit of partition identifier must be '0' or '1', got '%s' for input '%s'.", firstPartitionIdDigit, componentId));
        }
    }

    public static ComponentCategory getComponentCategory(final String componentId) {
        return ComponentCategory.getByOrdinal(getComponentIdentifier(componentId));
    }

    private static int getComponentIdentifier(final String componentId) {
        final char secondPartitionIdDigit = componentId.charAt(componentId.length() - 2);
        final int ci = Character.digit(secondPartitionIdDigit, 10);
        if (ci >= 0 && ci <= 2) {
            return ci;
        } else {
            throw new IllegalArgumentException(String.format("Second digit of partition identifier must be between '0' and '2', got '%s' for input '%s'.", secondPartitionIdDigit, componentId));
        }
    }

    public static SnomedIdentifierValidator getIdentifierValidator(final ComponentCategory category) {

    }

    public static boolean isConceptIdentifier(final String componentId) {
        try {
            validate(componentId);
            return ComponentCategory.CONCEPT == getComponentCategory(componentId);
        } catch (final IllegalArgumentException e) {
            return false;
        }
    }

    public static long getItemId(final String componentId) {
        final boolean shortForm = isShortForm(componentId);
        final String itemId;
        if (shortForm) {
            itemId = componentId.substring(0, componentId.length() - 3);
        } else {
            itemId = componentId.substring(0, componentId.length() - 10);
        }
        try {
            return Long.parseLong(itemId);
        } catch (final NumberFormatException e) {
            throw new IllegalArgumentException(String.format("Item identifier must be parseable to a long, got '%s' for input '%s'.", itemId, componentId));
        }
    }

    public static String getPartitionId(final String componentId) {
        return componentId.substring(componentId.length() - 3, componentId.length() - 1);
    }

    public static int getCheckDigit(final String componentId) {
        final char checkDigit = componentId.charAt(componentId.length() - 1);
        final int cd = Character.digit(checkDigit, 10);
        if (cd >= 0 && cd <= 9) {
            return cd;
        } else {
            throw new IllegalArgumentException(String.format("Check digit must be between '0' and '9', got '%s' for input '%s'.", checkDigit, componentId));
        }
    }

    /**
     * Creates a {@link SnomedIdentifier} instance from the given {@link String} componentId.
     */
    public static SnomedIdentifier create(final String componentId) {
        validate(componentId);
        final long itemId = getItemId(componentId);
        final String namespace = getNamespace(componentId);
        final int formatIdentifier = isShortForm(componentId) ? 0 : 1;
        final int componentIdentifier = getComponentIdentifier(componentId);
        final int checkDigit = getCheckDigit(componentId);
        return new SnomedIdentifierImpl(itemId, namespace, formatIdentifier, componentIdentifier, checkDigit);
    }
}


public Integer getLastTransitionEvent(Integer entityId) {
        return eventLogDAS.getLastTransitionEvent(entityId);
    }

/*
 jBilling - The Enterprise Open Source Billing System

 This file is part of jbilling.

 */
package com.sapienter.jbilling.server.util.audit;

import java.util.Date;
import com.sapienter.jbilling.server.user.db.CompanyDAS;
import com.sapienter.jbilling.server.user.db.UserDAS;
import com.sapienter.jbilling.server.util.Context;
import com.sapienter.jbilling.server.util.audit.db.EventLogDAS;
import com.sapienter.jbilling.server.util.audit.db.EventLogDTO;
import com.sapienter.jbilling.server.util.audit.db.EventLogMessageDAS;
import com.sapienter.jbilling.server.util.audit.db.EventLogModuleDAS;
import com.sapienter.jbilling.server.util.db.JbillingTableDAS;

public class EventLogger {

    // these are the messages constants, in synch with the db (event_log_message)
    // billing process
    public static final Integer BILLING_PROCESS_UNBILLED_PERIOD = new Integer(1);

    public static final Integer BILLING_PROCESS_NOT_ACTIVE_YET = new Integer(2);

    public static final Integer BILLING_PROCESS_ONE_PERIOD_NEEDED = new Integer(3);

    public static final Integer BILLING_PROCESS_RECENTLY_BILLED = new Integer(4);

    public static final Integer BILLING_PROCESS_WRONG_FLAG_ON = new Integer(5);

    public static final Integer BILLING_PROCESS_EXPIRED = new Integer(6);

    public static final Integer BILLING_REVIEW_NOT_APPROVED = new Integer(10);

    public static final Integer BILLING_REVIEW_NOT_GENERATED = new Integer(11);

    // user maintenance
    public static final Integer PASSWORD_CHANGE = new Integer(8);

    public static final Integer STATUS_CHANGE = new Integer(12);

    public static final Integer NO_FURTHER_STEP = new Integer(14);

    public static final Integer CANT_PAY_PARTNER = new Integer(15);

    public static final Integer SUBSCRIPTION_STATUS_CHANGE = new Integer(20);

    public static final Integer SUBSCRIPTION_STATUS_NO_CHANGE = new Integer(32);

    public static final Integer ACCOUNT_LOCKED = new Integer(21);

    public static final Integer DYNAMIC_BALANCE_CHANGE = new Integer(33);

    public static final Integer INVOICE_IF_CHILD_CHANGE = new Integer(34);

    // order maintenance
    public static final Integer ORDER_STATUS_CHANGE = new Integer(13);

    public static final Integer ORDER_LINE_UPDATED = new Integer(17);

    public static final Integer ORDER_NEXT_BILL_DATE_UPDATED = new Integer(18);

    public static final Integer ORDER_MAIN_SUBSCRIPTION_UPDATED = new Integer(22);

    public static final Integer ORDER_CANCEL_AND_CREDIT = new Integer(26);

    // payment
    public static final Integer PAYMENT_INSTRUMENT_NOT_FOUND = new Integer(24);

    // invoice related message
    public static final Integer INVOICE_ORDER_APPLIED = new Integer(16);

    // mediation
    public static final Integer CURRENT_ORDER_FINISHED = new Integer(23);

    // blacklist
    public static final Integer BLACKLIST_USER_ID_ADDED = new Integer(27);

    public static final Integer BLACKLIST_USER_ID_REMOVED = new Integer(28);

    // provisioning
    public static final Integer PROVISIONING_UUID = new Integer(29);

    public static final Integer PROVISIONING_COMMAND = new Integer(30);

    public static final Integer PROVISIONING_STATUS_CHANGE = new Integer(31);

    // others
    public static final Integer ROW_CREATED = new Integer(25);

    public static final Integer ROW_DELETED = new Integer(7);

    // field not specified
    public static final Integer ROW_UPDATED = new Integer(9);

    public static final Integer USER_TRANSITIONS_LIST = new Integer(19);

    // event log modules in synch with db (event_log_module)
    public static final Integer MODULE_BILLING_PROCESS = new Integer(1);

    public static final Integer MODULE_USER_MAINTENANCE = new Integer(2);

    public static final Integer MODULE_ITEM_MAINTENANCE = new Integer(3);

    public static final Integer MODULE_ITEM_TYPE_MAINTENANCE = new Integer(4);

    public static final Integer MODULE_ITEM_USER_PRICE_MAINTENANCE = new Integer(5);

    public static final Integer MODULE_PROMOTION_MAINTENANCE = new Integer(6);

    public static final Integer MODULE_ORDER_MAINTENANCE = new Integer(7);

    public static final Integer MODULE_CREDIT_CARD_MAINTENANCE = new Integer(8);

    public static final Integer MODULE_INVOICE_MAINTENANCE = new Integer(9);

    public static final Integer MODULE_PAYMENT_MAINTENANCE = new Integer(10);

    public static final Integer MODULE_TASK_MAINTENANCE = new Integer(11);

    public static final Integer MODULE_WEBSERVICES = new Integer(12);

    public static final Integer MODULE_MEDIATION = new Integer(13);

    public static final Integer MODULE_BLACKLIST = new Integer(14);

    public static final Integer MODULE_PROVISIONING = new Integer(15);

    // levels of logging
    public static final Integer LEVEL_DEBUG = new Integer(1);

    public static final Integer LEVEL_INFO = new Integer(2);

    public static final Integer LEVEL_WARNING = new Integer(3);

    public static final Integer LEVEL_ERROR = new Integer(4);

    public static final Integer LEVEL_FATAL = new Integer(5);

    private EventLogDAS eventLogDAS = null;

    private EventLogMessageDAS eventLogMessageDAS = null;

    private EventLogModuleDAS eventLogModuleDAS = null;

    private JbillingTableDAS jbDAS = null;

    public EventLogger() {
        eventLogDAS = new EventLogDAS();
        eventLogMessageDAS = new EventLogMessageDAS();
        eventLogModuleDAS = new EventLogModuleDAS();
        jbDAS = (JbillingTableDAS) Context.getBean(Context.Name.JBILLING_TABLE_DAS);
    }

    public static EventLogger getInstance() {
        return new EventLogger();
    }

    public void log(Integer level, Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        CompanyDAS company = new CompanyDAS();
        UserDAS user = new UserDAS();
        EventLogDTO dto = new EventLogDTO(null, jbDAS.findByName(table), null, user.find(userAffectedId), eventLogMessageDAS.find(message), eventLogModuleDAS.find(module), company.find(entity), rowId, level, null, null, null);
        eventLogDAS.save(dto);
    }

    public void debug(Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        log(LEVEL_DEBUG, entity, userAffectedId, rowId, module, message, table);
    }

    public void info(Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        log(LEVEL_INFO, entity, userAffectedId, rowId, module, message, table);
    }

    public void warning(Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        log(LEVEL_WARNING, entity, userAffectedId, rowId, module, message, table);
    }

    public void error(Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        log(LEVEL_ERROR, entity, userAffectedId, rowId, module, message, table);
    }

    public void fatal(Integer entity, Integer userAffectedId, Integer rowId, Integer module, Integer message, String table) {
        log(LEVEL_FATAL, entity, userAffectedId, rowId, module, message, table);
    }

    /*
     * This is intended for loggin a change in the database, where we want to
     * keep track of what changed
     */
    public void audit(Integer userExecutingId, Integer userAffectedId, String table, Integer rowId, Integer module, Integer message, Integer oldInt, String oldStr, Date oldDate) {
        UserDAS user = new UserDAS();
        EventLogDTO dto = new EventLogDTO(null, jbDAS.findByName(table), user.find(userExecutingId), (userAffectedId == null) ? null : user.find(userAffectedId), eventLogMessageDAS.find(message), eventLogModuleDAS.find(module), user.find(userExecutingId).getCompany(), rowId, LEVEL_INFO, oldInt, oldStr, oldDate);
        eventLogDAS.save(dto);
    }

    /*
     * Same as previous but the change its not being done by any given user
     * (no executor) but by a batch process.
     */
    public void auditBySystem(Integer entityId, Integer userAffectedId, String table, Integer rowId, Integer module, Integer message, Integer oldInt, String oldStr, Date oldDate) {
        CompanyDAS company = new CompanyDAS();
        UserDAS user = new UserDAS();
        EventLogDTO dto = new EventLogDTO(null, jbDAS.findByName(table), null, user.find(userAffectedId), eventLogMessageDAS.find(message), eventLogModuleDAS.find(module), company.find(entityId), rowId, LEVEL_INFO, oldInt, oldStr, oldDate);
        eventLogDAS.save(dto);
    }

    /**
     * Queries the event_log table to determine the position where the last query
     * of the user transitions ended. This is called if the user passes
     * null as the from parameter to the getUserTransitions
     * webservice call.
     * @return the id of the last queried transitions list.
     */


package cn.iocoder.mall.tradeservice.rpc.cart;

import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
import java.util.List;

/**
 * 购物车 Rpc 接口
 */
public interface CartRpc {

    /**
     * 添加商品到购物车
     *
     * @param addReqDTO 添加商品信息
     * @return 成功
     */
    CommonResult<Boolean> addCartItem(CartItemAddReqDTO addReqDTO);

    /**
     * 更新购物车商品数量
     *
     * @param updateQuantityReqDTO 更新商品数量 DTO
     * @return 成功
     */
    CommonResult<Boolean> updateCartItemQuantity(CartItemUpdateQuantityReqDTO updateQuantityReqDTO);

    /**
     * 更新购物车商品是否选中
     *
     * @param updateSelectedReqDTO 更新商品是否选中 DTO
     * @return 成功
     */

    /**
     * 删除购物车商品列表
     *
     * @param deleteListReqDTO 删除商品列表 DTO
     * @return 成功
     */
    CommonResult<Boolean> deleteCartItems(CartItemDeleteListReqDTO deleteListReqDTO);

    /**
     * 查询用户在购物车中的商品数量
     *
     * @param userId 用户编号
     * @return 商品数量
     */
    CommonResult<Integer> sumCartItemQuantity(Integer userId);

    /**
     * 查询用户在购物车种的商品列表
     *
     * @param listReqDTO 查询条件 DTO
     * @return 购物车中商品列表信息
     */
    CommonResult<List<CartItemRespDTO>> listCartItems(CartItemListReqDTO listReqDTO);
}


private static <T> MethodCallExpression constantArrayList(List<T> values, Class clazz) {
        return Expressions.call(BuiltInMethod.ARRAYS_AS_LIST.method, Expressions.newArrayInit(clazz, constantList(values)));
    }

package com.qihoo.qsql.org.apache.calcite.adapter.mongodb;

import com.google.common.collect.Lists;
import com.qihoo.qsql.org.apache.calcite.adapter.enumerable.*;
import com.qihoo.qsql.org.apache.calcite.config.CalciteSystemProperty;
import com.qihoo.qsql.org.apache.calcite.linq4j.tree.BlockBuilder;
import com.qihoo.qsql.org.apache.calcite.linq4j.tree.Expression;
import com.qihoo.qsql.org.apache.calcite.linq4j.tree.Expressions;
import com.qihoo.qsql.org.apache.calcite.linq4j.tree.MethodCallExpression;
import com.qihoo.qsql.org.apache.calcite.plan.*;
import com.qihoo.qsql.org.apache.calcite.rel.RelNode;
import com.qihoo.qsql.org.apache.calcite.rel.convert.ConverterImpl;
import com.qihoo.qsql.org.apache.calcite.rel.metadata.RelMetadataQuery;
import com.qihoo.qsql.org.apache.calcite.rel.type.RelDataType;
import com.qihoo.qsql.org.apache.calcite.runtime.Hook;
import com.qihoo.qsql.org.apache.calcite.util.BuiltInMethod;
import com.qihoo.qsql.org.apache.calcite.util.Pair;
import java.util.AbstractList;
import java.util.List;

/**
 * Relational expression representing a scan of a table in a Mongo data source.
 */
public class MongoToEnumerableConverter extends ConverterImpl implements EnumerableRel {

    protected MongoToEnumerableConverter(RelOptCluster cluster, RelTraitSet traits, RelNode input) {
        super(cluster, ConventionTraitDef.INSTANCE, traits, input);
    }

    @Override
    public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
        return new MongoToEnumerableConverter(getCluster(), traitSet, sole(inputs));
    }

    @Override
    public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
        return super.computeSelfCost(planner, mq).multiplyBy(.1);
    }

    public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
        // Generates a call to "find" or "aggregate", depending upon whether
        // an aggregate is present.
        final BlockBuilder list = new BlockBuilder();
        final MongoRel.Implementor mongoImplementor = new MongoRel.Implementor();
        mongoImplementor.visitChild(0, getInput());
        int aggCount = 0;
        int findCount = 0;
        String project = null;
        String filter = null;
        for (Pair<String, String> op : mongoImplementor.list) {
            if (op.left == null) {
                ++aggCount;
            }
            if (op.right.startsWith("{$match:")) {
                filter = op.left;
                ++findCount;
            }
            if (op.right.startsWith("{$project:")) {
                project = op.left;
                ++findCount;
            }
        }
        final RelDataType rowType = getRowType();
        final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), rowType, pref.prefer(JavaRowFormat.ARRAY));
        final Expression fields = list.append("fields", constantArrayList(Pair.zip(MongoRules.mongoFieldNames(rowType), new AbstractList<Class>() {

            @Override
            public Class get(int index) {
                return physType.fieldClass(index);
            }

            @Override
            public int size() {
                return rowType.getFieldCount();
            }
        }), Pair.class));
        final Expression table = list.append("table", mongoImplementor.table.getExpression(MongoTable.MongoQueryable.class));
        List<String> opList = Pair.right(mongoImplementor.list);
        final Expression ops = list.append("ops", constantArrayList(opList, String.class));
        Expression enumerable = list.append("enumerable", Expressions.call(table, MongoMethod.MONGO_QUERYABLE_AGGREGATE.method, fields, ops));
        if (CalciteSystemProperty.DEBUG.value()) {
            System.out.println("Mongo: " + opList);
        }
        Hook.QUERY_PLAN.run(opList);
        list.add(Expressions.return_(null, enumerable));
        return implementor.result(physType, list.toBlock());
    }

    /**
     * E.g. {@code constantArrayList("x", "y")} returns
     * "Arrays.asList('x', 'y')".
     *
     * @param values List of values
     * @param clazz Type of values
     * @return expression
     */

    private static <T> List<Expression> constantList(List<T> values) {
        return Lists.transform(values, Expressions::constant);
    }
}
// End MongoToEnumerableConverter.java


public InputSource loadSource(String href, String context, XSLTC xsltc);

package com.sun.org.apache.xalan.internal.xsltc.compiler;

import org.xml.sax.InputSource;

/**
 * @author Morten Jorgensen
 */
public interface SourceLoader {

    /**
     * This interface is used to plug external document loaders into XSLTC
     * (used with the <xsl:include> and <xsl:import> elements.
     *
     * @param href The URI of the document to load
     * @param context The URI of the currently loaded document
     * @param xsltc The compiler that resuests the document
     * @return An InputSource with the loaded document
     */


while ((line = bis.readLine()) != null) {
            System.out.println(line);
            if (line.contains(DISABLED_RESPONSE)) {
                break;
            }
        }

import java.io.*;
import java.net.*;
import com.sun.ejte.ccl.reporter.*;

/**
 * Unit test to ensure that the state of a virtual server may be
 * changed without requiring a server restart.
 *
 * This test:
 *
 * 1. Creates a virtual-server myvs and deploys a webapp to it
 *
 * 2. Makes sure that the webapp may be accessed
 *
 * 3. Disables the virtual server and ensures that a 403 response is
 *    returned when the webapp is accessed
 *
 * 4. Turns off the virtual server and ensures that a 404 response is
 *    returned when the webapp is accessed
 *
 * 5. Re-enables the virtual server and makes sure that the webapp may be
 *    accessed again.
 */
public class WebTest {

    private static SimpleReporterAdapter stat = new SimpleReporterAdapter("appserv-tests");

    private static String TEST_NAME = null;

    private static final String TEST_ROOT_NAME = "virtual-server-state-dynamic-reconfig";

    private static final String ON_RESPONSE = "Success!";

    private static final String DISABLED_RESPONSE = "HTTP/1.1 403 Virtual server myvs has been disabled";

    private static final String OFF_RESPONSE = "HTTP/1.1 404 Virtual server myvs has been turned off";

    private String host;

    private String port;

    private String contextRoot;

    private String run;

    public WebTest(String[] args) {
        host = args[0];
        port = args[1];
        contextRoot = args[2];
        run = args[3];
    }

    public static void main(String[] args) {
        stat.addDescription("Unit test for disabling a virtual server");
        WebTest webTest = new WebTest(args);
        try {
            if ("on".equals(webTest.run)) {
                TEST_NAME = TEST_ROOT_NAME + "-on";
                webTest.onRun();
            } else if ("disabled".equals(webTest.run)) {
                TEST_NAME = TEST_ROOT_NAME + "-disabled";
                webTest.disabledRun();
            } else if ("off".equals(webTest.run)) {
                TEST_NAME = TEST_ROOT_NAME + "-off";
                webTest.offRun();
            }
            stat.addStatus(TEST_NAME, stat.PASS);
        } catch (Exception ex) {
            stat.addStatus(TEST_NAME, stat.FAIL);
            ex.printStackTrace();
        }
        stat.printSummary(TEST_NAME);
    }

    /**
     * Make sure the webapp may be accessed on the newly created virtual
     * server.
     */
    private void onRun() throws Exception {
        Socket sock = new Socket(host, new Integer(port).intValue());
        OutputStream os = sock.getOutputStream();
        String get = "GET " + contextRoot + "/test.txt HTTP/1.1\n";
        System.out.println(get);
        os.write(get.getBytes());
        os.write("Host: myvs\n".getBytes());
        os.write("Connnection: Close\n".getBytes());
        os.write("\n".getBytes());
        InputStream is = sock.getInputStream();
        BufferedReader bis = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while ((line = bis.readLine()) != null) {
            System.out.println(line);
            if (line.equals(ON_RESPONSE)) {
                break;
            }
        }
        if (line == null) {
            throw new Exception("Missing expected response: " + ON_RESPONSE);
        }
    }

    /**
     * Make sure that a 403 response is returned when trying to access the
     * webapp after the virtual server on which it is deployed has been
     * disabled.
     */
    private void disabledRun() throws Exception {
        Socket sock = new Socket(host, new Integer(port).intValue());
        OutputStream os = sock.getOutputStream();
        String get = "GET " + contextRoot + "/test.txt HTTP/1.1\n";
        System.out.println(get);
        os.write(get.getBytes());
        os.write("Host: myvs\n".getBytes());
        os.write("Connnection: Close\n".getBytes());
        os.write("\n".getBytes());
        InputStream is = sock.getInputStream();
        BufferedReader bis = new BufferedReader(new InputStreamReader(is));
        String line = null;

        if (line == null) {
            throw new Exception("Missing expected response: " + DISABLED_RESPONSE);
        }
    }

    /**
     * Make sure that a 404 response is returned when trying to access the
     * webapp after the virtual server on which it is deployed has been
     * turned off.
     */
    private void offRun() throws Exception {
        Socket sock = new Socket(host, new Integer(port).intValue());
        OutputStream os = sock.getOutputStream();
        String get = "GET " + contextRoot + "/test.txt HTTP/1.1\n";
        System.out.println(get);
        os.write(get.getBytes());
        os.write("Host: myvs\n".getBytes());
        os.write("Connnection: Close\n".getBytes());
        os.write("\n".getBytes());
        InputStream is = sock.getInputStream();
        BufferedReader bis = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while ((line = bis.readLine()) != null) {
            System.out.println(line);
            if (line.contains(OFF_RESPONSE)) {
                break;
            }
        }
        if (line == null) {
            throw new Exception("Missing expected response: " + OFF_RESPONSE);
        }
    }
}


public T deserialize(byte[] input) throws IllegalArgumentException;

package com.iris.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * Class which can serialize objects of type {@code T}.  This class is
 * currently defined to handle binary serializers rather than character / String
 * serializers.
 */
public interface Deserializer<T> {

    /**
     * Deserializes an object from a byte array.  This call assumes
     * that the byte array contains a single object.  If the byte array
     * is longer than the number of bytes required by the deserializer, the
     * extra bytes will be ignored.  If it is too short and {@link IllegalArgumentException}
     * will be thrown.
     * @param input
     * @return
     * @throws IllegalArgumentException
     */

    /**
     * Serializes value to the OutputStream.  This call MUST NOT close
     * the input stream in order to allow multiple objects to be read from
     * a single stream.
     * @param input
     * @return
     * @throws IOException
     * @throws IllegalArgumentException
     */
    public T deserialize(InputStream input) throws IOException, IllegalArgumentException;
}


void endEvent(String aComponentName, String aEventType, String aResultMessage);

package org.apache.uima.util;

import org.apache.uima.UIMA_IllegalStateException;

/**
 * The InstrumentationFacility interface defines a standard way for UIMA components to
 * be instrumented for performance evaluation. The UIMA framework will provide each UIMA component
 * with access to an implementation of this interface.
 *
 * This interface is under development. In its current form, it basically just provides a write-only
 * interface to a {@link ProcessTrace} object.
 */
public interface InstrumentationFacility {

    /**
     * Records the start of an event. The event will be ended when there is a corresponding call to
     * {@link #endEvent(String,String,String)} with the same component name and event type. The
     * duration of the event will be automatically computed from the difference in time between the
     * start and end.
     *
     * @param aComponentName
     *          name of the component generating the event
     * @param aEventType
     *          type of the event. Standard types are defined as constants on the
     *          {@link ProcessTraceEvent} interface, but any string may be used.
     * @param aDescription
     *          description of the event
     */
    void startEvent(String aComponentName, String aEventType, String aDescription);

    /**
     * Records the end of an event. The event is identified by the component name and type. If there
     * is no open event that matches those values, a UIMA_IllegalStateException will be
     * thrown.
     *
     * @param aComponentName
     *          name of the component generating the event
     * @param aEventType
     *          type of the event. Standard types are defined as constants on the
     *          {@link ProcessTraceEvent} interface, but any string may be used.
     * @param aResultMessage
     *          describes the result of the event
     *
     * @throws UIMA_IllegalStateException
     *           if there is no open event matching the aComponentName and
     *           aEventType arguments.
     */

    /**
     * Records a completed event with the specified parameters.
     *
     * @param aResourceName
     *          name of the component generating the event
     * @param aType
     *          type of the event. Standard types are defined as constants on the
     *          {@link ProcessTraceEvent} interface, but any string may be used.
     * @param aDescription
     *          description of the event
     * @param aDuration
     *          duration of the event in milliseconds
     * @param aResultMsg
     *          result message of event
     */
    void addEvent(String aResourceName, String aType, String aDescription, int aDuration, String aResultMsg);
}


@Override
    public OptionHandler copy();

package org.apache.samoa.moa.options;

import org.apache.samoa.moa.MOAObject;
import org.apache.samoa.moa.core.ObjectRepository;
import org.apache.samoa.moa.tasks.TaskMonitor;
import com.github.javacliparser.Configurable;
import com.github.javacliparser.Options;

/**
 * Interface representing an object that handles options or parameters.
 *
 * @author Richard Kirkby (example@nnthink.com)
 * @version $Revision: 7 $
 */
public interface OptionHandler extends MOAObject, Configurable {

    /**
     * Gets the purpose of this object
     *
     * @return the string with the purpose of this object
     */
    public String getPurposeString();

    /**
     * Gets the options of this object
     *
     * @return the options of this object
     */
    public Options getOptions();

    /**
     * This method prepares this object for use.
     */
    public void prepareForUse();

    /**
     * This method prepares this object for use.
     *
     * @param monitor
     *          the TaskMonitor to use
     * @param repository
     *          the ObjectRepository to use
     */
    public void prepareForUse(TaskMonitor monitor, ObjectRepository repository);

    /**
     * This method produces a copy of this object.
     *
     * @return a copy of this object
     */

    /**
     * Gets the Command Line Interface text to create the object
     *
     * @return the Command Line Interface text to create the object
     */
    public String getCLICreationString(Class<?> expectedType);
}


package de.metas.handlingunits.model;

import java.math.BigDecimal;
import javax.annotation.Nullable;
import org.adempiere.model.ModelColumn;

/**
 * Generated Interface for M_HU_Instance_Properties_v
 *  @author metasfresh (generated)
 */
@SuppressWarnings("unused")
public interface I_M_HU_Instance_Properties_v {

    String Table_Name = "M_HU_Instance_Properties_v";

    int getAD_Client_ID();

    String COLUMNNAME_AD_Client_ID = "AD_Client_ID";

    /**
     * Set Organisation.
     * Organisational entity within client
     *
     *
Type: Search
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setAD_Org_ID(int AD_Org_ID);

    /**
     * Get Organisation.
     * Organisational entity within client
     *
     *
Type: Search
     *
Mandatory: false
     *
Virtual Column: false
     */
    int getAD_Org_ID();

    String COLUMNNAME_AD_Org_ID = "AD_Org_ID";

    /**
     * Set Attribute Name.
     * Name of the Attribute
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setAttributeName(@Nullable java.lang.String AttributeName);

    /**
     * Get Attribute Name.
     * Name of the Attribute
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.lang.String getAttributeName();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_AttributeName = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "AttributeName", null);

    String COLUMNNAME_AttributeName = "AttributeName";

    /**
     * Get Created.
     * Date this record was created
     *
     *
Type: DateTime
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.sql.Timestamp getCreated();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_Created = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "Created", null);

    String COLUMNNAME_Created = "Created";

    /**
     * Get Created By.
     * User who created this records
     *
     *
Type: Table
     *
Mandatory: false
     *
Virtual Column: false
     */
    int getCreatedBy();

    String COLUMNNAME_CreatedBy = "CreatedBy";

    /**
     * Set Document Name.
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setDocumentName(@Nullable java.lang.String DocumentName);

    /**
     * Get Document Name.
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.lang.String getDocumentName();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_DocumentName = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "DocumentName", null);

    String COLUMNNAME_DocumentName = "DocumentName";

    /**
     * Set Document No.
     * Document sequence number of the document
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setDocumentNo(@Nullable java.lang.String DocumentNo);

    /**
     * Get Document No.
     * Document sequence number of the document
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.lang.String getDocumentNo();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_DocumentNo = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "DocumentNo", null);

    String COLUMNNAME_DocumentNo = "DocumentNo";

    /**
     * Set Active.
     * The record is active in the system
     *
     *
Type: YesNo
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setIsActive(boolean IsActive);

    /**
     * Get Active.
     * The record is active in the system
     *
     *
Type: YesNo
     *
Mandatory: false
     *
Virtual Column: false
     */
    boolean isActive();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_IsActive = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "IsActive", null);

    String COLUMNNAME_IsActive = "IsActive";

    void setM_Attribute_ID(int M_Attribute_ID);

    int getM_Attribute_ID();

    String COLUMNNAME_M_Attribute_ID = "M_Attribute_ID";

    /**
     * Set Handling Unit.
     *
     *
Type: Search
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setM_HU_ID(int M_HU_ID);

    /**
     * Get Handling Unit.
     *
     *
Type: Search
     *
Mandatory: false
     *
Virtual Column: false
     */
    int getM_HU_ID();

    ModelColumn<I_M_HU_Instance_Properties_v, de.metas.handlingunits.model.I_M_HU> COLUMN_M_HU_ID = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "M_HU_ID", de.metas.handlingunits.model.I_M_HU.class);

    String COLUMNNAME_M_HU_ID = "M_HU_ID";

    /**
     * Set HU PI Name.
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setPIName(@Nullable java.lang.String PIName);

    /**
     * Get HU PI Name.
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.lang.String getPIName();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_PIName = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "PIName", null);

    String COLUMNNAME_PIName = "PIName";

    /**
     * Get Updated.
     * Date this record was updated
     *
     *
Type: DateTime
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.sql.Timestamp getUpdated();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_Updated = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "Updated", null);

    String COLUMNNAME_Updated = "Updated";

    /**
     * Get Updated By.
     * User who updated this records
     *
     *
Type: Table
     *
Mandatory: false
     *
Virtual Column: false
     */
    int getUpdatedBy();

    String COLUMNNAME_UpdatedBy = "UpdatedBy";

    /**
     * Set Search Key.
     * Search key for the record in the format required - must be unique
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setValue(@Nullable java.lang.String Value);

    /**
     * Get Search Key.
     * Search key for the record in the format required - must be unique
     *
     *
Type: String
     *
Mandatory: false
     *
Virtual Column: false
     */
    @Nullable
    java.lang.String getValue();

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_Value = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "Value", null);

    String COLUMNNAME_Value = "Value";

    /**
     * Set Numeric Value.
     * Numeric Value
     *
     *
Type: Number
     *
Mandatory: false
     *
Virtual Column: false
     */
    void setValueNumber(@Nullable BigDecimal ValueNumber);

    /**
     * Get Numeric Value.
     * Numeric Value
     *
     *
Type: Number
     *
Mandatory: false
     *
Virtual Column: false
     */

    ModelColumn<I_M_HU_Instance_Properties_v, Object> COLUMN_ValueNumber = new ModelColumn<>(I_M_HU_Instance_Properties_v.class, "ValueNumber", null);

    String COLUMNNAME_ValueNumber = "ValueNumber";
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jme3.gde.gui.multiview;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * @author normenhansen
 */
public class XmlHelper {

    public static Element findFirstChildElement(Element parent) {
        org.w3c.dom.Node ret = parent.getFirstChild();
        while (ret != null && (!(ret instanceof Element))) {
            ret = ret.getNextSibling();
        }
        return (Element) ret;
    }

    public static Element findChildElement(Element parent, String name) {
        if (parent == null) {
            return null;
        }
        org.w3c.dom.Node ret = parent.getFirstChild();
        while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) {
            ret = ret.getNextSibling();
        }
        return (Element) ret;
    }

    public static Element findNextElement(Node ret, String name) {
        ret = ret.getNextSibling();
        while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) {
            ret = ret.getNextSibling();
        }
        return (Element) ret;
    }

    public static Element findChildElementWithAttribute(Element parent, String name, String attribute, String value) {
        if (parent == null) {
            return null;
        }
        org.w3c.dom.Node ret = parent.getFirstChild();

        return (Element) ret;
    }

    public static Element findNextElementWithAttribute(Node ret, String name, String attribute, String value) {
        ret = ret.getNextSibling();
        while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name) || ((Element) ret).getAttribute(attribute) == null || !((Element) ret).getAttribute(attribute).equals(value))) {
            ret = ret.getNextSibling();
        }
        return (Element) ret;
    }

    public static Element findNextSiblingElement(Element current) {
        org.w3c.dom.Node ret = current.getNextSibling();
        while (ret != null) {
            if (ret instanceof Element) {
                return (Element) ret;
            }
            ret = ret.getNextSibling();
        }
        return null;
    }
}


static native int nsToJavaModifiers(int modifierFlags);

package sun.lwawt.macosx;

import java.awt.event.*;

/**
 * A class representing Cocoa NSEvent class with the fields only necessary for
 * JDK functionality.
 */
final class NSEvent {

    static final int SCROLL_PHASE_UNSUPPORTED = 1;

    static final int SCROLL_PHASE_BEGAN = 2;

    static final int SCROLL_PHASE_CONTINUED = 3;

    static final int SCROLL_PHASE_MOMENTUM_BEGAN = 4;

    static final int SCROLL_PHASE_ENDED = 5;

    private boolean hasDeadKey;

    private int deadKeyCode;

    private int type;

    private int modifierFlags;

    // Mouse event information
    private int clickCount;

    private int buttonNumber;

    private int x;

    private int y;

    private double scrollDeltaY;

    private double scrollDeltaX;

    private int scrollPhase;

    private int absX;

    private int absY;

    // Key event information
    private short keyCode;

    private String characters;

    private String charactersIgnoringModifiers;

    private String oldCharacters;

    private String oldCharactersIgnoringModifiers;

    private String charactersIgnoringModifiersAndShift;

    public boolean isHasDeadKey() {
        return hasDeadKey;
    }

    public int getDeadKeyCode() {
        return deadKeyCode;
    }

    // Called from native
    NSEvent(int type, int modifierFlags, short keyCode, String characters, String charactersIgnoringModifiers, String charactersIgnoringModifiersAndShift, boolean hasDeadKey, int deadKeyCode, String oldCharacters, String oldCharactersIgnoringModifiers) {
        this.type = type;
        this.modifierFlags = modifierFlags;
        this.keyCode = keyCode;
        this.characters = characters;
        this.charactersIgnoringModifiers = charactersIgnoringModifiers;
        this.charactersIgnoringModifiersAndShift = charactersIgnoringModifiersAndShift;
        this.hasDeadKey = hasDeadKey;
        this.deadKeyCode = deadKeyCode;
        this.oldCharacters = oldCharacters;
        this.oldCharactersIgnoringModifiers = oldCharactersIgnoringModifiers;
    }

    // Called from native
    NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, int x, int y, int absX, int absY, double scrollDeltaY, double scrollDeltaX, int scrollPhase) {
        this.type = type;
        this.modifierFlags = modifierFlags;
        this.clickCount = clickCount;
        this.buttonNumber = buttonNumber;
        this.x = x;
        this.y = y;
        this.absX = absX;
        this.absY = absY;
        this.scrollDeltaY = scrollDeltaY;
        this.scrollDeltaX = scrollDeltaX;
        this.scrollPhase = scrollPhase;
    }

    int getType() {
        return type;
    }

    int getModifierFlags() {
        return modifierFlags;
    }

    int getClickCount() {
        return clickCount;
    }

    int getButtonNumber() {
        return buttonNumber;
    }

    int getX() {
        return x;
    }

    int getY() {
        return y;
    }

    double getScrollDeltaY() {
        return scrollDeltaY;
    }

    double getScrollDeltaX() {
        return scrollDeltaX;
    }

    int getScrollPhase() {
        return scrollPhase;
    }

    int getAbsX() {
        return absX;
    }

    int getAbsY() {
        return absY;
    }

    short getKeyCode() {
        return keyCode;
    }

    String getCharactersIgnoringModifiers() {
        return charactersIgnoringModifiers;
    }

    String getCharactersIgnoringModifiersAndShift() {
        return charactersIgnoringModifiersAndShift;
    }

    String getCharacters() {
        return characters;
    }

    String getOldCharactersIgnoringModifiers() {
        return oldCharactersIgnoringModifiers;
    }

    String getOldCharacters() {
        return oldCharacters;
    }

    @Override
    public String toString() {
        return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," + getY() + " ," + getAbsX() + " ," + getAbsY() + " ," + getKeyCode() + " ," + getCharacters() + " ," + getCharactersIgnoringModifiers() + " ," + getCharactersIgnoringModifiersAndShift() + "]";
    }

    /*
     * Converts an NSEvent button number to a MouseEvent constant.
     */
    static int nsToJavaButton(int buttonNumber) {
        int jbuttonNumber = buttonNumber + 1;
        switch(buttonNumber) {
            case CocoaConstants.kCGMouseButtonLeft:
                jbuttonNumber = MouseEvent.BUTTON1;
                break;
            case CocoaConstants.kCGMouseButtonRight:
                jbuttonNumber = MouseEvent.BUTTON3;
                break;
            case CocoaConstants.kCGMouseButtonCenter:
                jbuttonNumber = MouseEvent.BUTTON2;
                break;
        }
        return jbuttonNumber;
    }

    /*
     * Converts NPCocoaEvent types to AWT event types.
     */
    static int npToJavaEventType(int npEventType) {
        int jeventType = 0;
        switch(npEventType) {
            case CocoaConstants.NPCocoaEventMouseDown:
                jeventType = MouseEvent.MOUSE_PRESSED;
                break;
            case CocoaConstants.NPCocoaEventMouseUp:
                jeventType = MouseEvent.MOUSE_RELEASED;
                break;
            case CocoaConstants.NPCocoaEventMouseMoved:
                jeventType = MouseEvent.MOUSE_MOVED;
                break;
            case CocoaConstants.NPCocoaEventMouseEntered:
                jeventType = MouseEvent.MOUSE_ENTERED;
                break;
            case CocoaConstants.NPCocoaEventMouseExited:
                jeventType = MouseEvent.MOUSE_EXITED;
                break;
            case CocoaConstants.NPCocoaEventMouseDragged:
                jeventType = MouseEvent.MOUSE_DRAGGED;
                break;
            case CocoaConstants.NPCocoaEventKeyDown:
                jeventType = KeyEvent.KEY_PRESSED;
                break;
            case CocoaConstants.NPCocoaEventKeyUp:
                jeventType = KeyEvent.KEY_RELEASED;
                break;
        }
        return jeventType;
    }

    /*
     * Converts NSEvent types to AWT event types.
     */
    static int nsToJavaEventType(int nsEventType) {
        int jeventType = 0;
        switch(nsEventType) {
            case CocoaConstants.NSLeftMouseDown:
            case CocoaConstants.NSRightMouseDown:
            case CocoaConstants.NSOtherMouseDown:
                jeventType = MouseEvent.MOUSE_PRESSED;
                break;
            case CocoaConstants.NSLeftMouseUp:
            case CocoaConstants.NSRightMouseUp:
            case CocoaConstants.NSOtherMouseUp:
                jeventType = MouseEvent.MOUSE_RELEASED;
                break;
            case CocoaConstants.NSMouseMoved:
                jeventType = MouseEvent.MOUSE_MOVED;
                break;
            case CocoaConstants.NSLeftMouseDragged:
            case CocoaConstants.NSRightMouseDragged:
            case CocoaConstants.NSOtherMouseDragged:
                jeventType = MouseEvent.MOUSE_DRAGGED;
                break;
            case CocoaConstants.NSMouseEntered:
                jeventType = MouseEvent.MOUSE_ENTERED;
                break;
            case CocoaConstants.NSMouseExited:
                jeventType = MouseEvent.MOUSE_EXITED;
                break;
            case CocoaConstants.NSScrollWheel:
                jeventType = MouseEvent.MOUSE_WHEEL;
                break;
            case CocoaConstants.NSKeyDown:
                jeventType = KeyEvent.KEY_PRESSED;
                break;
            case CocoaConstants.NSKeyUp:
                jeventType = KeyEvent.KEY_RELEASED;
                break;
        }
        return jeventType;
    }

    /**
     * Converts NSEvent key modifiers to AWT key modifiers. Note that this
     * method adds the current mouse state as a mouse modifiers.
     *
     * @param  modifierFlags the NSEvent key modifiers
     * @return the java key and mouse modifiers
     */

    /*
     * Converts NSEvent key info to AWT key info.
     */
    static native boolean nsToJavaKeyInfo(int[] in, int[] out);

    /*
     * Converts NSEvent key modifiers to AWT key info.
     */
    static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);

    /*
     * There is a small number of NS characters that need to be converted
     * into other characters before we pass them to AWT.
     */
    static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);

    static boolean isPopupTrigger(int jmodifiers) {
        final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
        final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
        final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0);
        return isRightButtonDown || (isControlDown && isLeftButtonDown);
    }
}


switch(buttonNumber) {
            case CocoaConstants.kCGMouseButtonLeft:
                jbuttonNumber = MouseEvent.BUTTON1;
                break;
            case CocoaConstants.kCGMouseButtonRight:
                jbuttonNumber = MouseEvent.BUTTON3;
                break;
            case CocoaConstants.kCGMouseButtonCenter:
                jbuttonNumber = MouseEvent.BUTTON2;
                break;
        }

package sun.lwawt.macosx;

import java.awt.event.*;

/**
 * A class representing Cocoa NSEvent class with the fields only necessary for
 * JDK functionality.
 */
final class NSEvent {

    static final int SCROLL_PHASE_UNSUPPORTED = 1;

    static final int SCROLL_PHASE_BEGAN = 2;

    static final int SCROLL_PHASE_CONTINUED = 3;

    static final int SCROLL_PHASE_MOMENTUM_BEGAN = 4;

    static final int SCROLL_PHASE_ENDED = 5;

    private boolean hasDeadKey;

    private int deadKeyCode;

    private int type;

    private int modifierFlags;

    // Mouse event information
    private int clickCount;

    private int buttonNumber;

    private int x;

    private int y;

    private double scrollDeltaY;

    private double scrollDeltaX;

    private int scrollPhase;

    private int absX;

    private int absY;

    // Key event information
    private short keyCode;

    private String characters;

    private String charactersIgnoringModifiers;

    private String oldCharacters;

    private String oldCharactersIgnoringModifiers;

    private String charactersIgnoringModifiersAndShift;

    public boolean isHasDeadKey() {
        return hasDeadKey;
    }

    public int getDeadKeyCode() {
        return deadKeyCode;
    }

    // Called from native
    NSEvent(int type, int modifierFlags, short keyCode, String characters, String charactersIgnoringModifiers, String charactersIgnoringModifiersAndShift, boolean hasDeadKey, int deadKeyCode, String oldCharacters, String oldCharactersIgnoringModifiers) {
        this.type = type;
        this.modifierFlags = modifierFlags;
        this.keyCode = keyCode;
        this.characters = characters;
        this.charactersIgnoringModifiers = charactersIgnoringModifiers;
        this.charactersIgnoringModifiersAndShift = charactersIgnoringModifiersAndShift;
        this.hasDeadKey = hasDeadKey;
        this.deadKeyCode = deadKeyCode;
        this.oldCharacters = oldCharacters;
        this.oldCharactersIgnoringModifiers = oldCharactersIgnoringModifiers;
    }

    // Called from native
    NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, int x, int y, int absX, int absY, double scrollDeltaY, double scrollDeltaX, int scrollPhase) {
        this.type = type;
        this.modifierFlags = modifierFlags;
        this.clickCount = clickCount;
        this.buttonNumber = buttonNumber;
        this.x = x;
        this.y = y;
        this.absX = absX;
        this.absY = absY;
        this.scrollDeltaY = scrollDeltaY;
        this.scrollDeltaX = scrollDeltaX;
        this.scrollPhase = scrollPhase;
    }

    int getType() {
        return type;
    }

    int getModifierFlags() {
        return modifierFlags;
    }

    int getClickCount() {
        return clickCount;
    }

    int getButtonNumber() {
        return buttonNumber;
    }

    int getX() {
        return x;
    }

    int getY() {
        return y;
    }

    double getScrollDeltaY() {
        return scrollDeltaY;
    }

    double getScrollDeltaX() {
        return scrollDeltaX;
    }

    int getScrollPhase() {
        return scrollPhase;
    }

    int getAbsX() {
        return absX;
    }

    int getAbsY() {
        return absY;
    }

    short getKeyCode() {
        return keyCode;
    }

    String getCharactersIgnoringModifiers() {
        return charactersIgnoringModifiers;
    }

    String getCharactersIgnoringModifiersAndShift() {
        return charactersIgnoringModifiersAndShift;
    }

    String getCharacters() {
        return characters;
    }

    String getOldCharactersIgnoringModifiers() {
        return oldCharactersIgnoringModifiers;
    }

    String getOldCharacters() {
        return oldCharacters;
    }

    @Override
    public String toString() {
        return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," + getY() + " ," + getAbsX() + " ," + getAbsY() + " ," + getKeyCode() + " ," + getCharacters() + " ," + getCharactersIgnoringModifiers() + " ," + getCharactersIgnoringModifiersAndShift() + "]";
    }

    /*
     * Converts an NSEvent button number to a MouseEvent constant.
     */
    static int nsToJavaButton(int buttonNumber) {
        int jbuttonNumber = buttonNumber + 1;

        return jbuttonNumber;
    }

    /*
     * Converts NPCocoaEvent types to AWT event types.
     */
    static int npToJavaEventType(int npEventType) {
        int jeventType = 0;
        switch(npEventType) {
            case CocoaConstants.NPCocoaEventMouseDown:
                jeventType = MouseEvent.MOUSE_PRESSED;
                break;
            case CocoaConstants.NPCocoaEventMouseUp:
                jeventType = MouseEvent.MOUSE_RELEASED;
                break;
            case CocoaConstants.NPCocoaEventMouseMoved:
                jeventType = MouseEvent.MOUSE_MOVED;
                break;
            case CocoaConstants.NPCocoaEventMouseEntered:
                jeventType = MouseEvent.MOUSE_ENTERED;
                break;
            case CocoaConstants.NPCocoaEventMouseExited:
                jeventType = MouseEvent.MOUSE_EXITED;
                break;
            case CocoaConstants.NPCocoaEventMouseDragged:
                jeventType = MouseEvent.MOUSE_DRAGGED;
                break;
            case CocoaConstants.NPCocoaEventKeyDown:
                jeventType = KeyEvent.KEY_PRESSED;
                break;
            case CocoaConstants.NPCocoaEventKeyUp:
                jeventType = KeyEvent.KEY_RELEASED;
                break;
        }
        return jeventType;
    }

    /*
     * Converts NSEvent types to AWT event types.
     */
    static int nsToJavaEventType(int nsEventType) {
        int jeventType = 0;
        switch(nsEventType) {
            case CocoaConstants.NSLeftMouseDown:
            case CocoaConstants.NSRightMouseDown:
            case CocoaConstants.NSOtherMouseDown:
                jeventType = MouseEvent.MOUSE_PRESSED;
                break;
            case CocoaConstants.NSLeftMouseUp:
            case CocoaConstants.NSRightMouseUp:
            case CocoaConstants.NSOtherMouseUp:
                jeventType = MouseEvent.MOUSE_RELEASED;
                break;
            case CocoaConstants.NSMouseMoved:
                jeventType = MouseEvent.MOUSE_MOVED;
                break;
            case CocoaConstants.NSLeftMouseDragged:
            case CocoaConstants.NSRightMouseDragged:
            case CocoaConstants.NSOtherMouseDragged:
                jeventType = MouseEvent.MOUSE_DRAGGED;
                break;
            case CocoaConstants.NSMouseEntered:
                jeventType = MouseEvent.MOUSE_ENTERED;
                break;
            case CocoaConstants.NSMouseExited:
                jeventType = MouseEvent.MOUSE_EXITED;
                break;
            case CocoaConstants.NSScrollWheel:
                jeventType = MouseEvent.MOUSE_WHEEL;
                break;
            case CocoaConstants.NSKeyDown:
                jeventType = KeyEvent.KEY_PRESSED;
                break;
            case CocoaConstants.NSKeyUp:
                jeventType = KeyEvent.KEY_RELEASED;
                break;
        }
        return jeventType;
    }

    /**
     * Converts NSEvent key modifiers to AWT key modifiers. Note that this
     * method adds the current mouse state as a mouse modifiers.
     *
     * @param  modifierFlags the NSEvent key modifiers
     * @return the java key and mouse modifiers
     */
    static native int nsToJavaModifiers(int modifierFlags);

    /*
     * Converts NSEvent key info to AWT key info.
     */
    static native boolean nsToJavaKeyInfo(int[] in, int[] out);

    /*
     * Converts NSEvent key modifiers to AWT key info.
     */
    static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);

    /*
     * There is a small number of NS characters that need to be converted
     * into other characters before we pass them to AWT.
     */
    static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);

    static boolean isPopupTrigger(int jmodifiers) {
        final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
        final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
        final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0);
        return isRightButtonDown || (isControlDown && isLeftButtonDown);
    }
}


default Value.Mutable<Integer> remainingFuel() {
        return this.requireValue(Keys.FUEL).asMutable();
    }

package org.spongepowered.api.block.entity.carrier.furnace;

import org.spongepowered.api.block.entity.carrier.NameableCarrierBlockEntity;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.item.recipe.Recipe;
import org.spongepowered.api.util.Ticks;

/**
 * Represents the types of furnaces in Vanilla minecraft.
 */
public interface FurnaceBlockEntity extends NameableCarrierBlockEntity {

    /**
     * Attempts to process the {@link Recipe} for results.
     *
     * @return If the process was successful.
     */
    boolean process();

    /**
     * Gets the {@link org.spongepowered.api.data.value.Value.Mutable} for the remaining fuel.
     *
     * @return The value for the remaining fuel
     */

    /**
     * Gets the {@link org.spongepowered.api.data.value.Value.Mutable} for the maximum amount of fuel that
     * can be supplied with the used fuel item.
     *
     * @return The value for the maximum amount of fuel that can be supplied
     *         with the used fuel item
     */
    default Value.Mutable<Ticks> maxBurnTime() {
        return this.requireValue(Keys.MAX_BURN_TIME).asMutable();
    }

    /**
     * Gets the {@link org.spongepowered.api.data.value.Value.Mutable} for the already passed cook time of
     * the item stack in this furnace.
     *
     * @return The value for the already passed cook time
     */
    default Value.Mutable<Ticks> passedCookTime() {
        return this.requireValue(Keys.PASSED_COOK_TIME).asMutable();
    }

    /**
     * Gets the {@link org.spongepowered.api.data.value.Value.Mutable} for the total time the item stack
     * has to cook until it is cooked.
     *
     * @return The value for the time the item has to cook
     */
    default Value.Mutable<Ticks> maxCookTime() {
        return this.requireValue(Keys.MAX_COOK_TIME).asMutable();
    }
}


while (true) {
            try {
                process();
            } catch (Exception e) {
                WriteLog.write(canal_destination, thread_name + "canal link failure!");
            } finally {
                if (connector != null) {
                    connector.disconnect();
                    connector = null;
                }
            }
        }

package com.sync.process;

import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.protocol.Message;
import com.alibaba.otter.canal.protocol.CanalEntry.Column;
import com.alibaba.otter.canal.protocol.CanalEntry.Entry;
import com.alibaba.otter.canal.protocol.CanalEntry.EntryType;
import com.alibaba.otter.canal.protocol.CanalEntry.EventType;
import com.alibaba.otter.canal.protocol.CanalEntry.RowChange;
import com.alibaba.otter.canal.protocol.CanalEntry.RowData;
import com.sync.common.GetProperties;
import com.sync.common.MemApi;
import com.sync.common.RedisApi;
import com.sync.common.Tool;
import com.sync.common.WriteLog;
import com.alibaba.fastjson.JSON;

/**
 * Cache Producer
 *
 * @author sasou <example@nnthink.com> web:http://example.com
 * @version 1.0.0
 */
public class Cache implements Runnable {

    private RedisApi RedisPool = null;

    private MemApi MemPool = null;

    private CanalConnector connector = null;

    private String thread_name = null;

    private String canal_destination = null;

    private String sign = null;

    public Cache(String name) {
        thread_name = "canal[" + name + "]:";
        canal_destination = name;
        sign = GetProperties.target.get(canal_destination).sign;
    }

    public void process() {
        int batchSize = 1000;
        connector = CanalConnectors.newSingleConnector(new InetSocketAddress(GetProperties.canal.ip, GetProperties.canal.port), canal_destination, GetProperties.canal.username, GetProperties.canal.password);
        connector.connect();
        connector.subscribe();
        try {
            if ("redis".equals(GetProperties.target.get(canal_destination).plugin)) {
                RedisPool = new RedisApi(canal_destination);
            }
            if ("memcached".equals(GetProperties.target.get(canal_destination).plugin)) {
                MemPool = new MemApi(canal_destination);
            }
            WriteLog.write(canal_destination, thread_name + "Start-up success!");
            while (true) {
                // get batch num
                Message message = connector.getWithoutAck(batchSize);
                long batchId = message.getId();
                int size = message.getEntries().size();
                if (!(batchId == -1 || size == 0)) {
                    if (syncEntry(message.getEntries())) {
                        // commit
                        connector.ack(batchId);
                    } else {
                        // rollback
                        connector.rollback(batchId);
                    }
                }
            }
        } catch (Exception e) {
            WriteLog.write(canal_destination, thread_name + WriteLog.eString(e));
        }
    }

    public void run() {

    }

    private boolean syncEntry(List<Entry> entrys) {
        String table = "";
        boolean ret = true;
        for (Entry entry : entrys) {
            EntryType type = entry.getEntryType();
            if (type == EntryType.TRANSACTIONBEGIN || type == EntryType.TRANSACTIONEND) {
                continue;
            }
            table = entry.getHeader().getSchemaName() + "." + entry.getHeader().getTableName();
            if (".".equals(table)) {
                continue;
            }
            RowChange rowChage = null;
            try {
                rowChage = RowChange.parseFrom(entry.getStoreValue());
            } catch (Exception e) {
                throw new RuntimeException(thread_name + "parser of eromanga-event has an error , data:" + entry.toString(), e);
            }
            EventType eventType = rowChage.getEventType();
            HashSet<String> versionField = new HashSet<String>();
            versionField.add(table);
            for (RowData rowData : rowChage.getRowDatasList()) {
                if (eventType == EventType.DELETE) {
                    updateColumn(versionField, rowData.getBeforeColumnsList(), table);
                } else if (eventType == EventType.INSERT) {
                    updateColumn(versionField, rowData.getAfterColumnsList(), table);
                } else {
                    updateColumn(versionField, rowData.getBeforeColumnsList(), table);
                    updateColumn(versionField, rowData.getAfterColumnsList(), table);
                }
            }
            try {
                Iterator<String> iterator = versionField.iterator();
                while (iterator.hasNext()) {
                    if ("redis".equals(GetProperties.target.get(canal_destination).plugin)) {
                        RedisPool.incr(sign + Tool.md5(iterator.next()));
                    }
                    if ("memcached".equals(GetProperties.target.get(canal_destination).plugin)) {
                        MemPool.incr(sign + Tool.md5(iterator.next()));
                    }
                }
                if (GetProperties.system_debug > 0) {
                    String text = JSON.toJSONString(versionField);
                    WriteLog.write(canal_destination + ".access", thread_name + "data(" + text + ")");
                }
            } catch (Exception e) {
                WriteLog.write(canal_destination + ".error", thread_name + "cache link failure!" + WriteLog.eString(e));
                ret = false;
            }
            versionField.clear();
            versionField = null;
        }
        return ret;
    }

    @SuppressWarnings("rawtypes")
    private void updateColumn(HashSet<String> versionField, List<Column> columns, String table) {
        Map field = (Map) GetProperties.target.get(canal_destination).filterMap.get(table);
        for (Column column : columns) {
            String key = table + "." + column.getName();
            if (column.getIsKey()) {
                versionField.add(key + "." + column.getValue());
            } else {
                if (field != null && field.containsKey(column.getName())) {
                    versionField.add(key + "." + column.getValue());
                }
            }
        }
    }

    protected void finalize() throws Throwable {
        if (connector != null) {
            connector.disconnect();
            connector = null;
        }
    }
}


switch(type) {
            case STRING:
            case FACET:
                return value;
            case INTEGER:
                return Integer.parseInt(value);
            case LONG:
                return Long.parseLong(value);
            case FLOAT:
                return Float.parseFloat(value);
            case DOUBLE:
                return Double.parseDouble(value);
            default:
                throw new IllegalStateException("Unsupported linden type");
        }

package com.xiaomi.linden.core;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.util.Bits;
import com.xiaomi.linden.common.schema.LindenSchemaConf;
import com.xiaomi.linden.thrift.common.LindenFieldSchema;
import com.xiaomi.linden.thrift.common.LindenType;

public class LindenUtil {

    public static Float getFieldFloatValue(List<AtomicReaderContext> leaves, int docId, String fieldName) throws IOException {
        AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
        FieldCache.Floats floats = FieldCache.DEFAULT.getFloats(atomicReaderContext.reader(), fieldName, false);
        return floats.get(docId - atomicReaderContext.docBase);
    }

    public static Double getFieldDoubleValue(List<AtomicReaderContext> leaves, int docId, String fieldName) throws IOException {
        AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
        FieldCache.Doubles doubles = FieldCache.DEFAULT.getDoubles(atomicReaderContext.reader(), fieldName, false);
        return doubles.get(docId - atomicReaderContext.docBase);
    }

    public static String getFieldStringValue(List<AtomicReaderContext> leaves, int docId, String fieldName) throws IOException {
        AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
        BinaryDocValues terms = FieldCache.DEFAULT.getTerms(atomicReaderContext.reader(), fieldName, false);
        return terms.get(docId - atomicReaderContext.docBase).utf8ToString();
    }

    public static Long getFieldLongValue(List<AtomicReaderContext> leaves, int docId, String fieldName) throws IOException {
        AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
        FieldCache.Longs longs = FieldCache.DEFAULT.getLongs(atomicReaderContext.reader(), fieldName, false);
        return longs.get(docId - atomicReaderContext.docBase);
    }

    public static Integer getFieldIntValue(List<AtomicReaderContext> leaves, int docId, String fieldName) throws IOException {
        AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
        FieldCache.Ints ints = FieldCache.DEFAULT.getInts(atomicReaderContext.reader(), fieldName, false);
        return ints.get(docId - atomicReaderContext.docBase);
    }

    // We are not sure whether dynamic schema string field is tokenized or not
    public static boolean possibleTokenizedString(LindenFieldSchema fieldSchema) {
        return fieldSchema.getType() == LindenType.STRING && (fieldSchema.isTokenized() || fieldSchema.isDynamicSchema());
    }

    /**
     * Get fields by doc id.
     *
     * @param indexSearcher The IndexSearcher
     * @param docId         Doc ID.
     * @param id            Id field value
     * @param sourceFields  Specify the fields, if null get all fields values.
     * @param config        the lindenConfig for search
     * @return JSON String which contains field values.
     * @throws IOException
     */
    public static String getSource(IndexSearcher indexSearcher, int docId, String id, List<String> sourceFields, LindenConfig config) throws IOException {
        List<AtomicReaderContext> leaves = indexSearcher.getIndexReader().leaves();
        int idx = ReaderUtil.subIndex(docId, leaves);
        AtomicReaderContext atomicReaderContext = leaves.get(idx);
        AtomicReader reader = atomicReaderContext.reader();
        int locDocId = docId - atomicReaderContext.docBase;
        JSONObject src = new JSONObject();
        String idFieldName = config.getSchema().getId();
        if (id != null) {
            src.put(idFieldName, id);
        } else {
            src.put(idFieldName, FieldCache.DEFAULT.getTerms(reader, idFieldName, false).get(locDocId).utf8ToString());
        }
        List<LindenFieldSchema> fields = new ArrayList<>();
        if (sourceFields != null && !sourceFields.isEmpty()) {
            for (String sourceField : sourceFields) {
                if (sourceField.equals(idFieldName)) {
                    continue;
                }
                LindenFieldSchema fieldSchema = config.getFieldSchema(sourceField);
                fields.add(fieldSchema);
            }
        } else {
            fields.addAll(config.getSchema().getFields());
        }
        Map<String, LindenFieldSchema> storedFields = new HashMap<>();
        for (LindenFieldSchema fieldSchema : fields) {
            String name = fieldSchema.getName();
            boolean fieldCache = false;
            if (fieldSchema.isMulti()) {
                /**
                 * multi-field has multiple values, each value is indexed to the document according to field type
                 * multi-field source value is in JSONArray format, something like "["MI4","MI Note","RedMI3"]"
                 * multi-field source value is stored in BinaryDocValues
                 */
                String blob = FieldCache.DEFAULT.getTerms(reader, name, false).get(locDocId).utf8ToString();
                if (StringUtils.isNotEmpty(blob)) {
                    src.put(name, JSON.parseArray(blob));
                }
            } else if (fieldSchema.isDocValues()) {
                fieldCache = true;
            } else if (fieldSchema.isIndexed() && fieldSchema.isStored()) {
                // field cache doesn't support tokenized string field
                if (config.isEnableSourceFieldCache() && !possibleTokenizedString(fieldSchema)) {
                    fieldCache = true;
                } else {
                    storedFields.put(name, fieldSchema);
                }
            } else if (fieldSchema.isIndexed()) {
                if (!possibleTokenizedString(fieldSchema)) {
                    fieldCache = true;
                }
            } else if (fieldSchema.isStored()) {
                storedFields.put(name, fieldSchema);
            }
            if (fieldCache) {
                Object val;
                switch(fieldSchema.getType()) {
                    case STRING:
                    case FACET:
                        val = FieldCache.DEFAULT.getTerms(reader, name, false).get(locDocId).utf8ToString();
                        String v = (String) val;
                        fieldCache = !v.isEmpty() || actualContain(reader, name, locDocId);
                        break;
                    case INTEGER:
                        val = FieldCache.DEFAULT.getInts(reader, name, false).get(locDocId);
                        fieldCache = ((int) val) != 0 || actualContain(reader, name, locDocId);
                        break;
                    case LONG:
                        val = FieldCache.DEFAULT.getLongs(reader, name, false).get(locDocId);
                        fieldCache = ((long) val != 0) || actualContain(reader, name, locDocId);
                        break;
                    case FLOAT:
                        val = FieldCache.DEFAULT.getFloats(reader, name, false).get(locDocId);
                        fieldCache = ((float) val != 0) || actualContain(reader, name, locDocId);
                        break;
                    case DOUBLE:
                        val = FieldCache.DEFAULT.getDoubles(reader, name, false).get(locDocId);
                        fieldCache = ((double) val != 0) || actualContain(reader, name, locDocId);
                        break;
                    default:
                        throw new IllegalStateException("Unsupported linden type");
                }
                if (fieldCache) {
                    src.put(name, val);
                }
            }
        }
        if (!storedFields.isEmpty()) {
            Document doc = indexSearcher.doc(docId, storedFields.keySet());
            for (IndexableField field : doc.getFields()) {
                String name = field.name();
                LindenFieldSchema schema = storedFields.get(name);
                Object obj = src.get(name);
                Object val = parseLindenValue(field.stringValue(), storedFields.get(name).getType());
                if (obj == null) {
                    if (schema.isMulti()) {
                        JSONArray array = new JSONArray();
                        array.add(val);
                        src.put(name, array);
                    } else {
                        src.put(name, val);
                    }
                } else if (obj instanceof JSONArray) {
                    ((JSONArray) obj).add(val);
                } else {
                    JSONArray array = new JSONArray();
                    array.add(obj);
                    array.add(val);
                    src.put(name, array);
                }
            }
        }
        return src.toJSONString();
    }

    public static Object parseLindenValue(String value, LindenType type) {

    }

    private static boolean actualContain(AtomicReader reader, String field, int locDocId) {
        try {
            // index really contains such field of this doc
            return FieldCache.DEFAULT.getDocsWithField(reader, field).get(locDocId);
        } catch (IOException e) {
            return false;
        }
    }

    public static LindenFieldSchema parseDynamicFieldSchema(String name) {
        LindenFieldSchema fieldSchema = new LindenFieldSchema();
        // Linden dynamic field is always indexed and stored
        fieldSchema.setStored(true);
        fieldSchema.setIndexed(true);
        fieldSchema.setDynamicSchema(true);
        int idx = name.lastIndexOf(LindenSchemaConf.DYNAMIC_TYPE_SEPARATOR);
        String tag = idx >= 0 ? name.substring(idx + 1) : "";
        switch(tag.toLowerCase()) {
            case LindenSchemaConf.INT:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.INTEGER);
                break;
            case LindenSchemaConf.LONG:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.LONG);
                break;
            case LindenSchemaConf.DOUBLE:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.DOUBLE);
                break;
            case LindenSchemaConf.FLOAT:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.FLOAT);
                break;
            case LindenSchemaConf.STRING:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.STRING);
                break;
            case LindenSchemaConf.FACET:
                fieldSchema.setName(name.substring(0, idx));
                fieldSchema.setType(LindenType.FACET);
                break;
            default:
                // default field type is STRING
                fieldSchema.setName(name);
                fieldSchema.setType(LindenType.STRING);
                break;
        }
        return fieldSchema;
    }
}


package com.tiger.tgcloud.security.core.social.weixin.api;

/**
 * 微信API调用接口
 *
 * @author
 */
public interface Weixin {

    /**
     * Gets user info.
     *
     * @param openId the open id
     *
     * @return the user info
     */


public abstract String getLongDisplayValue();

package com.android.ide.common.resources.configuration;

/**
 * Base class for resource qualifiers.
 *
The resource qualifier classes are designed as immutable.
 */
public abstract class ResourceQualifier implements Comparable<ResourceQualifier> {

    /**
     * Returns the human readable name of the qualifier.
     */
    public abstract String getName();

    /**
     * Returns a shorter human readable name for the qualifier.
     * @see #getName()
     */
    public abstract String getShortName();

    /**
     * Returns when this qualifier was added to Android.
     */
    public abstract int since();

    /**
     * Whether this qualifier is deprecated.
     */
    public boolean deprecated() {
        return false;
    }

    /**
     * Returns whether the qualifier has a valid filter value.
     */
    public abstract boolean isValid();

    /**
     * Returns whether the qualifier has a fake value.
     *
Fake values are used internally and should not be used as real qualifier value.
     */
    public abstract boolean hasFakeValue();

    /**
     * Check if the value is valid for this qualifier, and if so sets the value
     * into a Folder Configuration.
     * @param value The value to check and set. Must not be null.
     * @param config The folder configuration to receive the value. Must not be null.
     * @return true if the value was valid and was set.
     */
    public abstract boolean checkAndSet(String value, FolderConfiguration config);

    /**
     * Returns a string formatted to be used in a folder name.
     *
This is declared as abstract to force children classes to implement it.
     */
    public abstract String getFolderSegment();

    /**
     * Returns whether the given qualifier is a match for the receiver.
     *
The default implementation returns the result of {@link #equals(Object)}.
     *
Children class that re-implements this must implement
     * {@link #isBetterMatchThan(ResourceQualifier, ResourceQualifier)} too.
     * @param qualifier the reference qualifier
     * @return true if the receiver is a match.
     */
    public boolean isMatchFor(ResourceQualifier qualifier) {
        return equals(qualifier);
    }

    /**
     * Returns true if the receiver is a better match for the given <var>reference</var> than
     * the given <var>compareTo</var> comparable.
     * @param compareTo The {@link ResourceQualifier} to compare to. Can be null, in which
     * case the method must return true.
     * @param reference The reference qualifier value for which the match is.
     * @return true if the receiver is a better match.
     */
    public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) {
        // the default is to always return false. This gives less overhead than always returning
        // true, as it would only compare same values anyway.
        return false;
    }

    @Override
    public String toString() {
        return getFolderSegment();
    }

    /**
     * Returns a string formatted for display purpose.
     */
    public abstract String getShortDisplayValue();

    /**
     * Returns a string formatted for display purpose.
     */

/**
     * Returns true if both objects are equal.
     *
This is declared as abstract to force children classes to implement it.
     */
    @Override
    public abstract boolean equals(Object object);

    /**
     * Returns a hash code value for the object.
     *
This is declared as abstract to force children classes to implement it.
     */
    @Override
    public abstract int hashCode();

    @Override
    public final int compareTo(ResourceQualifier o) {
        return toString().compareTo(o.toString());
    }
}


public static DefaultInstalledAppContext from(UpdateData updateData) {
        return new DefaultInstalledAppContext(updateData.getInstalledApp(), updateData.getAuthToken(), updateData.getRefreshToken());
    }

package com.smartthings.sdk.smartapp.core.extensions.contextstore;

import java.time.Instant;
import java.util.Objects;
import com.smartthings.sdk.smartapp.core.models.InstallData;
import com.smartthings.sdk.smartapp.core.models.InstalledApp;
import com.smartthings.sdk.smartapp.core.models.UpdateData;
import com.smartthings.sdk.smartapp.core.service.Token;

/**
 * This is the default implementation of InstalledAppContext which stores
 * basic information related to installed apps. In particular, this includes
 * token information to allow for keeping them up-to-date for out of band
 * API requests.
 *
 * Instances of this class are created and managed by the context store.
 */
public class DefaultInstalledAppContext implements InstalledAppContext {

    private InstalledApp installedApp;

    private Token token;

    /**
     * Helper method for creating the context from the install data.
     */
    public static DefaultInstalledAppContext from(InstallData installData) {
        return new DefaultInstalledAppContext(installData.getInstalledApp(), installData.getAuthToken(), installData.getRefreshToken());
    }

    /**
     * Helper method for creating the context from the update data.
     */

    public DefaultInstalledAppContext() {
        // Include empty constructor to make this class as amenable to
        // persistence engines as possible.
    }

    public DefaultInstalledAppContext(InstalledApp installedApp, Token token) {
        this.installedApp = installedApp;
        this.token = token;
    }

    public DefaultInstalledAppContext(InstalledApp installedApp, String accessToken, String refreshToken) {
        this.installedApp = installedApp;
        Instant now = Instant.now();
        token = new Token().accessToken(accessToken).accessTokenExpiration(now.plus(Token.ACCESS_TOKEN_DURATION)).refreshToken(refreshToken).refreshTokenExpiration(now.plus(Token.REFRESH_TOKEN_DURATION));
    }

    @Override
    public String getInstalledAppId() {
        return installedApp != null ? installedApp.getInstalledAppId() : null;
    }

    public InstalledApp getInstalledApp() {
        return installedApp;
    }

    public void setInstalledApp(InstalledApp installedApp) {
        this.installedApp = installedApp;
    }

    public DefaultInstalledAppContext installedApp(InstalledApp installedApp) {
        this.installedApp = installedApp;
        return this;
    }

    public Token getToken() {
        return token;
    }

    public void setToken(Token token) {
        this.token = token;
    }

    public DefaultInstalledAppContext token(Token token) {
        this.token = token;
        return this;
    }

    public String getAuth() {
        if (token == null || token.getAccessToken() == null) {
            throw new NullPointerException("context is missing access token");
        }
        return "Bearer " + token.getAccessToken();
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof DefaultInstalledAppContext)) {
            return false;
        }
        DefaultInstalledAppContext defaultInstalledAppContext = (DefaultInstalledAppContext) o;
        return Objects.equals(installedApp, defaultInstalledAppContext.installedApp) && Objects.equals(token, defaultInstalledAppContext.token);
    }

    @Override
    public int hashCode() {
        return Objects.hash(installedApp, token);
    }

    @Override
    public String toString() {
        return "{" + " installedApp='" + getInstalledApp() + "'" + ", token='" + getToken() + "'" + "}";
    }
}