本文整理汇总了Java中com.sun.jna.Pointer.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.getString方法的具体用法?Java Pointer.getString怎么用?Java Pointer.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.Pointer
的用法示例。
在下文中一共展示了Pointer.getString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finalizeClashesByGuid
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* @param modelId
* @param size
* @return
*/
public Set<RenderEngineClash> finalizeClashesByGuid(Pointer modelId, int size) {
Set<RenderEngineClash> clashes = new HashSet<RenderEngineClash>();
Memory pG1 = new Memory(size * 4 * getPlatformMultiplier());
Memory pG2 = new Memory(size * 4 * getPlatformMultiplier());
engine.finalizeClashesByGuid(modelId, pG1, pG2);
for (int i = 0; i < size; i++) {
Pointer memory1 = pG1.getPointer(i * 4 * getPlatformMultiplier());
String pG1Str = memory1.getString(0);
Pointer memory2 = pG2.getPointer(i * 4 * getPlatformMultiplier());
String pG2Str = memory2.getString(0);
RenderEngineClash clash = new RenderEngineClash();
clash.setGuid1(pG1Str);
clash.setGuid2(pG2Str);
clashes.add(clash);
}
return clashes;
}
示例2: invoke
import com.sun.jna.Pointer; //导入方法依赖的package包/类
@Override
public void invoke(Pointer streamRef, Pointer clientCallBackInfo, NativeLong numEvents, Pointer eventPaths, Pointer eventFlags, Pointer eventIds) {
final long st = System.currentTimeMillis();
final int length = numEvents.intValue();
final Pointer[] pointers = eventPaths.getPointerArray(0, length);
int flags[];
if (eventFlags == null) {
flags = new int[length];
LOG.log(DEBUG_LOG_LEVEL, "FSEventStreamCallback eventFlags == null, expected int[] of size {0}", length); //NOI18N
} else {
flags = eventFlags.getIntArray(0, length);
}
for (int i=0; i<length; i++) {
final Pointer p = pointers[i];
int flag = flags[i];
final String path = p.getString(0);
if ((flag & kFSEventStreamEventFlagMustScanSubDirs) == kFSEventStreamEventFlagMustScanSubDirs ||
(flag & kFSEventStreamEventFlagMount) == kFSEventStreamEventFlagMount ||
(flag & kFSEventStreamEventFlagUnmount) == kFSEventStreamEventFlagUnmount) {
events.add(ALL_CHANGE);
} else {
events.add(path);
}
LOG.log(DEBUG_LOG_LEVEL, "Event on {0}", new Object[]{path});
}
LOG.log(PERF_LOG_LEVEL, "Callback time: {0}", (System.currentTimeMillis() - st));
}
示例3: getStringFromCFStringRef
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Converts CFString object to String.
*
* @param cfStringPointer Pointer to CFString object
* @return String from CFString
*/
private String getStringFromCFStringRef(Pointer cfStringPointer) {
if (cfStringPointer != null) {
long lenght = cfLibrary.CFStringGetLength(cfStringPointer);
long maxSize = cfLibrary.CFStringGetMaximumSizeForEncoding(lenght, 0x08000100); // 0x08000100 = UTF-8
Pointer buffer = new Memory(maxSize);
if (cfLibrary.CFStringGetCString(cfStringPointer, buffer, maxSize, 0x08000100)) { // 0x08000100 = UTF-8
return buffer.getString(0L);
}
}
return null;
}
示例4: macImpl
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/** try to install our custom rule profile into sandbox_init() to block execution */
private static void macImpl(Path tmpFile) throws IOException {
// first be defensive: we can give nice errors this way, at the very least.
boolean supported = Constants.MAC_OS_X;
if (supported == false) {
throw new IllegalStateException("bug: should not be trying to initialize seatbelt for an unsupported OS");
}
// we couldn't link methods, could be some really ancient OS X (< Leopard) or some bug
if (libc_mac == null) {
throw new UnsupportedOperationException("seatbelt unavailable: could not link methods. requires Leopard or above.");
}
// write rules to a temporary file, which will be passed to sandbox_init()
Path rules = Files.createTempFile(tmpFile, "es", "sb");
Files.write(rules, Collections.singleton(SANDBOX_RULES));
boolean success = false;
try {
PointerByReference errorRef = new PointerByReference();
int ret = libc_mac.sandbox_init(rules.toAbsolutePath().toString(), SANDBOX_NAMED, errorRef);
// if sandbox_init() fails, add the message from the OS (e.g. syntax error) and free the buffer
if (ret != 0) {
Pointer errorBuf = errorRef.getValue();
RuntimeException e = new UnsupportedOperationException("sandbox_init(): " + errorBuf.getString(0));
libc_mac.sandbox_free_error(errorBuf);
throw e;
}
logger.debug("OS X seatbelt initialization successful");
success = true;
} finally {
if (success) {
Files.delete(rules);
} else {
IOUtils.deleteFilesIgnoringExceptions(rules);
}
}
}
示例5: engiGetAggrElement
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Returns a data field in the actual aggregate element.
*
* @param aggregate
* Existing aggregation
* @param elementIndex
* Position in the existing aggregation, first position is 0
* @param valueType
* Type of output value
* @return Value of the specific element in the aggregation
*/
public Object engiGetAggrElement(Pointer aggregate, int elementIndex, SdaiTypes valueType) {
Object returnValue = null;
switch (valueType) {
case INTEGER:
IntByReference intRef = new IntByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), intRef);
returnValue = new Integer(intRef.getValue());
break;
case REAL:
DoubleByReference dblRef = new DoubleByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), dblRef);
returnValue = new Double(dblRef.getValue());
break;
case STRING:
PointerByReference strRef = new PointerByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), strRef);
Pointer strPtr = strRef.getValue();
if (strPtr != null)
returnValue = strPtr.getString(0);
break;
default:
PointerByReference ptrRef = new PointerByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), ptrRef);
returnValue = ptrRef.getValue();
break;
}
return returnValue;
}
示例6: getOCRText
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Gets recognized text.
*
* @param filename input file name. Needed only for reading a UNLV zone
* file.
* @param pageNum page number; needed for hocr paging.
* @return the recognized text
*/
protected String getOCRText(String filename, int pageNum) {
if (filename != null && !filename.isEmpty()) {
api.TessBaseAPISetInputName(handle, filename);
}
Pointer utf8Text = renderedFormat == RenderedFormat.HOCR ? api.TessBaseAPIGetHOCRText(handle, pageNum - 1) : api.TessBaseAPIGetUTF8Text(handle);
String str = utf8Text.getString(0);
api.TessDeleteText(utf8Text);
return str;
}
示例7: getWords
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Gets recognized words at specified page iterator level.
*
* @param bi input image
* @param pageIteratorLevel TessPageIteratorLevel enum
* @return list of <code>Word</code>
*/
public List<Word> getWords(BufferedImage bi, int pageIteratorLevel) {
this.init();
this.setTessVariables();
List<Word> words = new ArrayList<Word>();
try {
setImage(bi, null);
api.TessBaseAPIRecognize(handle, null);
TessResultIterator ri = api.TessBaseAPIGetIterator(handle);
TessPageIterator pi = api.TessResultIteratorGetPageIterator(ri);
api.TessPageIteratorBegin(pi);
do {
Pointer ptr = api.TessResultIteratorGetUTF8Text(ri, pageIteratorLevel);
String text = ptr.getString(0);
api.TessDeleteText(ptr);
float confidence = api.TessResultIteratorConfidence(ri, pageIteratorLevel);
IntBuffer leftB = IntBuffer.allocate(1);
IntBuffer topB = IntBuffer.allocate(1);
IntBuffer rightB = IntBuffer.allocate(1);
IntBuffer bottomB = IntBuffer.allocate(1);
api.TessPageIteratorBoundingBox(pi, pageIteratorLevel, leftB, topB, rightB, bottomB);
int left = leftB.get();
int top = topB.get();
int right = rightB.get();
int bottom = bottomB.get();
Word word = new Word(text, confidence, new Rectangle(left, top, right - left, bottom - top));
words.add(word);
} while (api.TessPageIteratorNext(pi, pageIteratorLevel) == TRUE);
return words;
} catch (Exception e) {
return words;
} finally {
dispose();
}
}
示例8: getOCRText
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Gets recognized text.
*
* @param filename input file name. Needed only for reading a UNLV zone
* file.
* @param pageNum page number; needed for hocr paging.
* @return the recognized text
*/
protected String getOCRText(String filename, int pageNum) {
if (filename != null && !filename.isEmpty()) {
TessBaseAPISetInputName(handle, filename);
}
Pointer utf8Text = renderedFormat == RenderedFormat.HOCR ? TessBaseAPIGetHOCRText(handle, pageNum - 1) : TessBaseAPIGetUTF8Text(handle);
String str = utf8Text.getString(0);
TessDeleteText(utf8Text);
return str;
}
示例9: macImpl
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/** try to install our custom rule profile into sandbox_init() to block execution */
private static void macImpl(Path tmpFile) throws IOException {
// first be defensive: we can give nice errors this way, at the very least.
boolean supported = Constants.MAC_OS_X;
if (supported == false) {
throw new IllegalStateException("bug: should not be trying to initialize seatbelt for an unsupported OS");
}
// we couldn't link methods, could be some really ancient OS X (< Leopard) or some bug
if (libc_mac == null) {
throw new UnsupportedOperationException("seatbelt unavailable: could not link methods. requires Leopard or above.");
}
// write rules to a temporary file, which will be passed to sandbox_init()
Path rules = Files.createTempFile(tmpFile, "es", "sb");
Files.write(rules, Collections.singleton(SANDBOX_RULES), StandardCharsets.UTF_8);
boolean success = false;
try {
PointerByReference errorRef = new PointerByReference();
int ret = libc_mac.sandbox_init(rules.toAbsolutePath().toString(), SANDBOX_NAMED, errorRef);
// if sandbox_init() fails, add the message from the OS (e.g. syntax error) and free the buffer
if (ret != 0) {
Pointer errorBuf = errorRef.getValue();
RuntimeException e = new UnsupportedOperationException("sandbox_init(): " + errorBuf.getString(0));
libc_mac.sandbox_free_error(errorBuf);
throw e;
}
logger.debug("OS X seatbelt initialization successful");
success = true;
} finally {
if (success) {
Files.delete(rules);
} else {
IOUtils.deleteFilesIgnoringExceptions(rules);
}
}
}
示例10: getWords
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* Gets recognized words at specified page iterator level.
*
* @param bi input image
* @param pageIteratorLevel TessPageIteratorLevel enum
* @return list of <code>Word</code>
*/
public List<Word> getWords(BufferedImage bi, int pageIteratorLevel) {
this.init();
this.setTessVariables();
List<Word> words = new ArrayList<Word>();
try {
setImage(bi, null);
TessBaseAPIRecognize(handle, null);
TessResultIterator ri = TessBaseAPIGetIterator(handle);
TessPageIterator pi = TessResultIteratorGetPageIterator(ri);
TessPageIteratorBegin(pi);
do {
Pointer ptr = TessResultIteratorGetUTF8Text(ri, pageIteratorLevel);
String text = ptr.getString(0);
TessAPI1.TessDeleteText(ptr);
float confidence = TessResultIteratorConfidence(ri, pageIteratorLevel);
IntBuffer leftB = IntBuffer.allocate(1);
IntBuffer topB = IntBuffer.allocate(1);
IntBuffer rightB = IntBuffer.allocate(1);
IntBuffer bottomB = IntBuffer.allocate(1);
TessPageIteratorBoundingBox(pi, pageIteratorLevel, leftB, topB, rightB, bottomB);
int left = leftB.get();
int top = topB.get();
int right = rightB.get();
int bottom = bottomB.get();
Word word = new Word(text, confidence, new Rectangle(left, top, right - left, bottom - top));
words.add(word);
} while (TessPageIteratorNext(pi, pageIteratorLevel) == TRUE);
return words;
} catch (Exception e) {
return words;
} finally {
dispose();
}
}