当前位置: 首页>>代码示例>>Java>>正文


Java Pair.getKey方法代码示例

本文整理汇总了Java中com.musala.atmosphere.commons.util.Pair.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.getKey方法的具体用法?Java Pair.getKey怎么用?Java Pair.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.musala.atmosphere.commons.util.Pair的用法示例。


在下文中一共展示了Pair.getKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAndExecuteShellCommand

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Executes a passed shell command from the console.
 *
 * @param passedShellCommand
 *        - the passed shell command.
 * @throws IllegalArgumentException
 *         - if the passed argument is <b>null</b>
 */
public void parseAndExecuteShellCommand(String passedShellCommand) {
    if (passedShellCommand != null) {
        Pair<String, List<String>> parsedCommand = ConsoleControl.parseShellCommand(passedShellCommand);
        String command = parsedCommand.getKey();
        List<String> params = parsedCommand.getValue();

        AgentCommand commandForExecution = AgentCommandFactory.getCommandInstance(command, params);
        if (commandForExecution != null) {
            currentAgentState.executeCommand(commandForExecution);
        } else {
            String helpCommand = AgentConsoleCommands.AGENT_HELP.getCommand();
            String errorMessage = String.format("Unknown command \"%s\". Type '%s' for all available commands.",
                                                command,
                                                helpCommand);
            agentConsole.writeLine(errorMessage);
        }
    } else {
        LOGGER.error("Error in console: trying to execute 'null' as a command.");
        throw new IllegalArgumentException("Command passed for execution to agent is 'null'");
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:30,代码来源:Agent.java

示例2: validatePointOnScreen

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Checks whether the given point is inside the bounds of the screen, and throws an {@link IllegalArgumentException}
 * otherwise.
 *
 * @param point
 *        - the point to be checked
 */
private void validatePointOnScreen(Point point) {
    Pair<Integer, Integer> resolution = deviceInformation.getResolution();

    boolean hasPositiveCoordinates = point.getX() >= 0 && point.getY() >= 0;
    boolean isOnScreen = point.getX() <= resolution.getKey() && point.getY() <= resolution.getValue();

    if (!hasPositiveCoordinates || !isOnScreen) {
        String exeptionMessageFormat = "The passed point with coordinates (%d, %d) is outside the bounds of the screen. Screen dimentions (%d, %d)";
        String message = String.format(exeptionMessageFormat,
                                       point.getX(),
                                       point.getY(),
                                       resolution.getKey(),
                                       resolution.getValue());
        LOGGER.error(message);
        throw new IllegalArgumentException(message);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:25,代码来源:GestureEntity.java

示例3: Device

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Creates new device with the given serial number, device identifier and passkey.
 *
 * @param deviceInformation
 *        - the {@link DeviceInformation information} of this device
 * @param deviceId
 *        - the identifier of this device
 * @param passkeyAuthority
 *        - a passkey for validating authority
 */
public Device(DeviceInformation deviceInformation, String deviceId, long passkeyAuthority) {
    apiLevel = deviceInformation.getApiLevel();
    cpu = deviceInformation.getCpu();
    dpi = deviceInformation.getDpi();
    manufacturer = deviceInformation.getManufacturer();
    model = deviceInformation.getModel();
    os = deviceInformation.getOS();
    ram = deviceInformation.getRam();
    Pair<Integer, Integer> resolution = deviceInformation.getResolution();
    resolutionWidth = resolution.getValue();
    resolutionHeight = resolution.getKey();
    serialNumber = deviceInformation.getSerialNumber();
    isEmulator = deviceInformation.isEmulator();
    isTablet = deviceInformation.isTablet();
    hasCamera = deviceInformation.hasCamera();
    this.deviceId = deviceId;
    passkey = passkeyAuthority;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:29,代码来源:Device.java

示例4: setDeviceInformation

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
@Override
public void setDeviceInformation(DeviceInformation information) {
    apiLevel = information.getApiLevel();
    cpu = information.getCpu();
    dpi = information.getDpi();
    manufacturer = information.getManufacturer();
    model = information.getModel();
    os = information.getOS();
    ram = information.getRam();
    Pair<Integer, Integer> resolution = information.getResolution();
    resolutionWidth = resolution.getValue();
    resolutionHeight = resolution.getKey();
    serialNumber = information.getSerialNumber();
    isEmulator = information.isEmulator();
    isTablet = information.isTablet();
    hasCamera = information.hasCamera();
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:Device.java

示例5: parseAndExecuteShellCommand

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Executes a passed command from the console.
 *
 * @param passedShellCommand
 *        - the passed shell command.
 * @throws IOException
 */
private void parseAndExecuteShellCommand(String passedShellCommand) throws IOException {
    if (passedShellCommand != null) {
        Pair<String, List<String>> parsedCommand = ConsoleControl.parseShellCommand(passedShellCommand);
        String command = parsedCommand.getKey();
        List<String> paramsAsList = parsedCommand.getValue();

        if (!command.isEmpty()) {
            String[] params = new String[paramsAsList.size()];
            paramsAsList.toArray(params);
            executeShellCommand(command, params);
        }
    } else {
        LOGGER.error("Error in console: trying to execute 'null' as a command.");
        throw new IllegalArgumentException("Command passed to server is 'null'");
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:24,代码来源:Server.java

示例6: printBuffer

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Prints/Write data from the LogCat buffer and returns the total number of the lines.
 *
 * @param bufferedWriter
 *        - a {@link BufferedWriter}
 * @param buffer
 *        - {@link Pair} of control number and log data
 * @param expectedLineId
 *        - a control ID that verifies that the log data is received in consistent order
 * @return the ID of the next expected line from the buffer.
 * @throws IOException
 *         throw when fails to write the data from the buffer
 */
private int printBuffer(BufferedWriter bufferedWriter, List<Pair<Integer, String>> buffer, int expectedLineId)
    throws IOException {
    if (buffer.size() > 0) {
        for (Pair<Integer, String> idToLogLine : buffer) {
            if (expectedLineId != idToLogLine.getKey()) {
                LOGGER.error("Some logcat output is missing.");
            }
            System.out.println(idToLogLine.getValue());
            bufferedWriter.write(idToLogLine.getValue() + System.getProperty("line.separator"));
            expectedLineId++;
        }
    }

    return expectedLineId;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:29,代码来源:Device.java

示例7: testDevicePinchInInvalidPoint

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testDevicePinchInInvalidPoint() {
    DeviceInformation deviceInfo = testDevice.getInformation();
    Pair<Integer, Integer> resolution = deviceInfo.getResolution();
    Point testPoint = new Point(resolution.getKey() + 1, resolution.getValue() + 1);

    testDevice.pinchIn(testPoint, testPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:9,代码来源:PinchTest.java

示例8: testDevicePinchOutInvalidPoint

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testDevicePinchOutInvalidPoint() {
    DeviceInformation deviceInfo = testDevice.getInformation();
    Pair<Integer, Integer> resolution = deviceInfo.getResolution();
    Point testPoint = new Point(resolution.getKey() + 1, resolution.getValue() + 1);

    testDevice.pinchOut(testPoint, testPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:9,代码来源:PinchTest.java

示例9: checkClients

import com.musala.atmosphere.commons.util.Pair; //导入方法依赖的package包/类
/**
 * Checks whether a client {@link DeviceSelector selector} is applicable to the newly available device(published or
 * released).
 *
 * @param deviceInformation
 *        - information about the {@link IDevice device}
 */
private void checkClients(DeviceInformation deviceInformation) {
    synchronized (waitingClients) {
        availableDeviceLatch = new CountDownLatch(COUNTDOWN_NUMBER);

        ListIterator<Pair<DeviceSelector, String>> li = waitingClients.listIterator(waitingClients.size());
        while (li.hasPrevious()) {
            Pair<DeviceSelector, String> clientInfo = li.previous();
            DeviceSelector deviceSelector = clientInfo.getKey();
            String clientId = clientInfo.getValue();

            boolean isApplicable = slectorResolver.isApplicable(deviceSelector, deviceInformation);

            if (isApplicable) {
                DeviceAllocationInformation dAlloc = allocate(deviceSelector);

                if (dAlloc != null) {
                    li.remove();
                    clientIdForDeviceAllocationInformation.put(clientId, dAlloc);
                    clientIdForLatch.get(clientId).countDown();
                    break;
                }
            }
        }

        availableDeviceLatch.countDown();
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:35,代码来源:DeviceAllocationManager.java


注:本文中的com.musala.atmosphere.commons.util.Pair.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。