threshold.java

来自「270的linux说明」· Java 代码 · 共 200 行

JAVA
200
字号
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*/package com.intel.mobile.base;/** * Base class for all Thresholds.<br> * Thresholds are application-defined events that indicate a certain change or transition has occurred. * Thresholds are not used with static properties.<br> * To receive notification of a threshold event, applications do the following: * <li>Instantiate a Threshold object</li> * <li>Set the property of interest in the Threshold object by calling setObservedProperty() method</li> * <li>Specify the criteria for firing</li> * <li>Add an observer to the Threshold</li> * <li>Call Start() to monitor the event</li> */public abstract class Threshold extends Object{    /**     * Get specific type of this Threshold     * @return     * @throws IntelMobileException     */    public String GetType() throws IntelMobileException    {        return GetTypeNative();    }        /**     * Get the granularity period for poll check.     * @return     * @throws IntelMobileException     */    public int GetGranularityPeriod() throws IntelMobileException    {        return GetGranularityPeriodNative();    }        /**     * Get Property object which is monitored for this Threshold.     * @return     * @throws IntelMobileException     */    public Property GetObservedProperty() throws IntelMobileException    {        return GetObservedPropertyNative();    }        /**     * Set the granularity period for poll check.     * @param nPeriod     * @return     * @throws IntelMobileException     */    public boolean SetGranularityPeriod(int nPeriod) throws IntelMobileException    {        return SetGranularityPeriodNative(nPeriod);        /*if (SetGranularityPeriodNative(nPeriod) == false)        {            throw new IntelMobileException(                    "Failed to set granularity period.", "Threshold", "setGranularityPeriod()", "0x80045049");        }*/    }        /**     * Get the count of observer objects for this Threshold.     * @return     * @throws IntelMobileException     */    public int GetObserverCount() throws IntelMobileException    {        return GetObserverCountNative();    }        /**     * Get observer object by index.     * @param nIndex     * @return     * @throws IntelMobileException     */    public Observer GetObserver(int nIndex) throws IntelMobileException    {        return GetObserverNative(nIndex);    }        /**     * Add observer to this Threshold.     * When observed conditions match the target conditions, the notify() method of the observed object is invoked.     * @param observer     * @return     * @throws IntelMobileException     */    public boolean AddObserver(Observer observer) throws IntelMobileException    {        return AddObserverNative(observer);        /*if (AddObserverNative(observer) == false)        {            throw new IntelMobileException(                    "Failed to add observer.", "Threshold", "addObserver()", "0x8004504A");        }*/    }        /**     * Remove the observer from this Threshold.     * @param observer     * @return     * @throws IntelMobileException     */    public boolean RemoveObserver(Observer observer) throws IntelMobileException    {        return RemoveObserverNative(observer);    }        /**     * Remove all observers from this Threshold.     * @return     * @throws IntelMobileException     */    public boolean RemoveObservers() throws IntelMobileException    {        return RemoveObserversNative();    }        /**     * StartNative monitoring of the observed property value.     * @return     * @throws IntelMobileException     */    public boolean Start() throws IntelMobileException    {        return StartNative();    }        /**     * StopNative monitoring of the observed property value.     * @return     * @throws IntelMobileException     */    public boolean Stop() throws IntelMobileException    {        return StopNative();    }        // Use this method to determine what type of threshold this is.    private native String GetTypeNative() throws IntelMobileException;        private native int GetGranularityPeriodNative() throws IntelMobileException;    private native Property GetObservedPropertyNative() throws IntelMobileException;    private native boolean SetGranularityPeriodNative(int nPeriod) throws IntelMobileException;        // Observer related methods    private native int GetObserverCountNative() throws IntelMobileException;    private native Observer GetObserverNative(int nIndex) throws IntelMobileException;    private native boolean AddObserverNative(Observer observer) throws IntelMobileException;    private native boolean RemoveObserverNative(Observer observer) throws IntelMobileException;    private native boolean RemoveObserversNative() throws IntelMobileException;        private native boolean StartNative() throws IntelMobileException;    private native boolean StopNative() throws IntelMobileException;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?