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


Java Platform类代码示例

本文整理汇总了Java中com.sun.jna.Platform的典型用法代码示例。如果您正苦于以下问题:Java Platform类的具体用法?Java Platform怎么用?Java Platform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: dndWithCopy

import com.sun.jna.Platform; //导入依赖的package包/类
public void dndWithCopy() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    // caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    WebElement list = driver.findElement(By.cssSelector("list"));
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
    WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
    WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
    listitem1.click();
    driver.clearlogs(LogType.DRIVER);
    Keys copyKey = Keys.ALT;
    if (Platform.isWindows()) {
        copyKey = Keys.CONTROL;
    }
    new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform();
    waitTillDropCompletes(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list);
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:DragAndDropTest.java

示例2: findExecutableOnPath

import com.sun.jna.Platform; //导入依赖的package包/类
public static String findExecutableOnPath(String name) {
    if (!Platform.isWindows() || name.endsWith(".exe") || name.endsWith(".bat")) {
        return getPathTo(name);
    }
    String path;
    path = getPathTo(name + ".exe");
    if (path != null)
        return path;
    path = getPathTo(name + ".cmd");
    if (path != null)
        return path;
    return getPathTo(name + ".bat");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:LaunchWebStartTest.java

示例3: getHostname

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * @return the hostname the of the current machine
 */
public static String getHostname() {
    if (Platform.isWindows()) {
        return Kernel32Util.getComputerName();
    } else {
        // For now, we'll consider anyhting other than Windows to be unix-ish enough to have gethostname
        // TODO - Consider http://stackoverflow.com/a/10543006 as a possibly better MacOS option
        
        byte[] hostnameBuffer = new byte[4097];
        // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html suggests
        // the actual limit would be 255.
        
        int result = UnixCLibrary.INSTANCE.gethostname(hostnameBuffer, hostnameBuffer.length);
        if (result != 0) {
            throw new RuntimeException("gethostname call failed");
        }
        
        return Native.toString(hostnameBuffer);
    }
}
 
开发者ID:mattsheppard,项目名称:gethostname4j,代码行数:23,代码来源:Hostname.java

示例4: getImplInstance

import com.sun.jna.Platform; //导入依赖的package包/类
private static final NativeCalls getImplInstance() {
  if (Platform.isLinux()) {
    return new LinuxNativeCalls();
  }
  if (Platform.isWindows()) {
    return new WinNativeCalls();
  }
  if (Platform.isSolaris()) {
    return new SolarisNativeCalls();
  }
  if (Platform.isMac()) {
    return new MacOSXNativeCalls();
  }
  if (Platform.isFreeBSD()) {
    return new FreeBSDNativeCalls();
  }
  return new POSIXNativeCalls();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:NativeCallsJNAImpl.java

示例5: lockMemory

import com.sun.jna.Platform; //导入依赖的package包/类
public static void lockMemory() {
  int result = 0;
  try {
    Native.register(Platform.C_LIBRARY_NAME);
    result = mlockall(1);
    if (result == 0) {
      return;
    }
  } catch (Throwable t) {
    throw new IllegalStateException("Error trying to lock memory", t);
  }

  int errno = Native.getLastError();
  String msg = "mlockall failed: " + errno;
  if (errno == 1 || errno == 12) { // EPERM || ENOMEM
    msg = "Unable to lock memory due to insufficient free space or privileges.  "
        + "Please check the RLIMIT_MEMLOCK soft resource limit (ulimit -l) and "
        + "increase the available memory if needed";
  }
  throw new IllegalStateException(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:GemFireCacheImpl.java

示例6: installSslLib

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * 安装ssllib到c:\windown\system32下
 */
static void installSslLib(ClassLoader classLoader, String ospath, String name) {
	String libname = mapSharedLibraryName(name);//lib全名.dll .so
	if(Platform.isWindows()) {
		String fullPath = "C:\\Windows\\System32\\" + libname;
		File dest = new File(fullPath);
		if(!dest.exists()) {
			File dir = dest.getParentFile();
	    	if(!dir.exists()) {
	    		dir.mkdirs();
	    	}
        	String libClassPath = ospath + "/" + libname;
			extract(classLoader, libClassPath, dest);
		} else {
			System.out.println("have install : " + fullPath);
		}
	}
}
 
开发者ID:xtuhcy,项目名称:webkit4j,代码行数:21,代码来源:InstallLibs.java

示例7: getInstance

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * @return an instance of this class.
 */
public static NativeLibExporter getInstance() {
    if (instance == null) {
        instance = new NativeLibExporter();

        try {
            if (Platform.isMac())
                instance.exportLibrary("lib/darwin/libmediainfo.dylib");
            else if (Platform.isWindows() && Platform.is64Bit())
                instance.exportLibrary("lib/win64/MediaInfo64.dll");
            else if (Platform.isWindows())
                instance.exportLibrary("lib/win32/MediaInfo.dll");
        } catch (Throwable e) {
            System.err.println(e.getMessage());
        }
    }

    return instance;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:22,代码来源:NativeLibExporter.java

示例8: getPlatformFolder

import com.sun.jna.Platform; //导入依赖的package包/类
private static String getPlatformFolder() {
    String result;

    if (Platform.isMac()) {
        result = "macosx";
    } else if (Platform.isWindows()) {
        result = "win";
    } else if (Platform.isLinux()) {
        result = "linux";
    } else if (Platform.isFreeBSD()) {
        result = "freebsd";
    } else if (Platform.isOpenBSD()) {
        result = "openbsd";
    } else {
        throw new IllegalStateException("Platform " + Platform.getOSType() + " is not supported");
    }

    return result;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:20,代码来源:PtyUtil.java

示例9: registerPlayers

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * Registers known transcoding engines.
 *
 * @throws InterruptedException
 */
private static void registerPlayers() throws InterruptedException {
	if (Platform.isWindows()) {
		registerPlayer(new AviSynthFFmpeg());
		registerPlayer(new AviSynthMEncoder());
	}

	registerPlayer(new FFmpegAudio());
	registerPlayer(new MEncoderVideo());
	registerPlayer(new FFMpegVideo());
	registerPlayer(new VLCVideo());
	registerPlayer(new FFmpegWebVideo());
	registerPlayer(new MEncoderWebVideo());
	registerPlayer(new VLCWebVideo());
	registerPlayer(new TsMuxeRVideo());
	registerPlayer(new TsMuxeRAudio());
	registerPlayer(new VideoLanAudioStreaming());
	registerPlayer(new VideoLanVideoStreaming());
	registerPlayer(new DCRaw());
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:25,代码来源:PlayerFactory.java

示例10: getProcessId

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * Retrieves the process ID (PID) for the specified {@link Process}.
 *
 * @param process the {@link Process} for whose PID to retrieve.
 * @return The PID or zero if the PID couldn't be retrieved.
 */
public static int getProcessId(@Nullable Process process) {
	if (process == null) {
		return 0;
	}
	try {
		Field field;
		if (Platform.isWindows()) {
			field = process.getClass().getDeclaredField("handle");
			field.setAccessible(true);
			int pid = Kernel32.INSTANCE.GetProcessId(new HANDLE(new Pointer(field.getLong(process))));
			if (pid == 0 && LOGGER.isDebugEnabled()) {
				int lastError = Kernel32.INSTANCE.GetLastError();
				LOGGER.debug("KERNEL32.getProcessId() failed with error {}", lastError);
			}
			return pid;
		}
		field = process.getClass().getDeclaredField("pid");
		field.setAccessible(true);
		return field.getInt(process);
	} catch (Exception e) {
		LOGGER.warn("Failed to get process id for process \"{}\": {}", process, e.getMessage());
		LOGGER.trace("", e);
		return 0;
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:32,代码来源:ProcessManager.java

示例11: isValidFileName

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * Checks for valid file name syntax. Path is not allowed.
 *
 * @param fileName the file name to be verified
 * @return whether or not the file name is valid
 */
public static boolean isValidFileName(String fileName) {
	if (Platform.isWindows()) {
		if (fileName.matches("^[^\"*:<>?/\\\\]+$")) {
			return true;
		}
	} else if (Platform.isMac()) {
		if (fileName.matches("^[^:/]+$")) {
			return true;
		}
	} else {
		// Assuming POSIX
		if (fileName.matches("^[A-Za-z0-9._][A-Za-z0-9._-]*$")) {
			return true;
		}
	}
	return false;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:24,代码来源:FileUtil.java

示例12: getUnixUID

import com.sun.jna.Platform; //导入依赖的package包/类
/**
 * Gets the user ID on Unix based systems. This should not change during a
 * session and the lookup is expensive, so we cache the result.
 *
 * @return The Unix user ID
 * @throws IOException
 */
public static int getUnixUID() throws IOException {
	if (
		Platform.isAIX() || Platform.isFreeBSD() || Platform.isGNU() || Platform.iskFreeBSD() ||
		Platform.isLinux() || Platform.isMac() || Platform.isNetBSD() || Platform.isOpenBSD() ||
		Platform.isSolaris()
	) {
		synchronized (unixUIDLock) {
			if (unixUID < 0) {
				String response;
			    Process id;
				id = Runtime.getRuntime().exec("id -u");
			    try (BufferedReader reader = new BufferedReader(new InputStreamReader(id.getInputStream(), Charset.defaultCharset()))) {
			    	response = reader.readLine();
			    }
			    try {
			    	unixUID = Integer.parseInt(response);
			    } catch (NumberFormatException e) {
			    	throw new UnsupportedOperationException("Unexpected response from OS: " + response, e);
			    }
			}
			return unixUID;
		}
	}
	throw new UnsupportedOperationException("getUnixUID can only be called on Unix based OS'es");
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:33,代码来源:FileUtil.java

示例13: getName

import com.sun.jna.Platform; //导入依赖的package包/类
@Override
public String getName() {
	if (this.getConf().getName() == null) {
		String name = null;
		File file = getFile();
		if (file.getName().trim().isEmpty()) {
			if (Platform.isWindows()) {
				name = BasicSystemUtils.INSTANCE.getDiskLabel(file);
			}
			if (name != null && name.length() > 0) {
				name = file.getAbsolutePath().substring(0, 1) + ":\\ [" + name + "]";
			} else {
				name = file.getAbsolutePath().substring(0, 1);
			}
		} else {
			name = file.getName();
		}
		this.getConf().setName(name);
	}
	return this.getConf().getName().replaceAll("_imdb([^_]+)_", "");
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:22,代码来源:RealFile.java

示例14: runInNewThread

import com.sun.jna.Platform; //导入依赖的package包/类
@Override
public void runInNewThread() {
	if (!Platform.isWindows()) {
		mkin.getPipeProcess().runInNewThread();
		mkout.getPipeProcess().runInNewThread();

		// Allow the threads some time to do their work before
		// starting the main thread
		try {
			Thread.sleep(150);
		} catch (InterruptedException e) {
		}
	}

	start();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:PipeIPCProcess.java

示例15: runInSameThread

import com.sun.jna.Platform; //导入依赖的package包/类
@Override
public void runInSameThread() {
	if (!Platform.isWindows()) {
		mkin.getPipeProcess().runInNewThread();
		mkout.getPipeProcess().runInNewThread();

		// Allow the threads some time to do their work before
		// running the main thread
		try {
			Thread.sleep(150);
		} catch (InterruptedException e) {
		}
	}

	run();
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:17,代码来源:PipeIPCProcess.java


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