本文整理汇总了Java中org.microemu.device.InputMethod.validate方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethod.validate方法的具体用法?Java InputMethod.validate怎么用?Java InputMethod.validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.microemu.device.InputMethod
的用法示例。
在下文中一共展示了InputMethod.validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TextField
import org.microemu.device.InputMethod; //导入方法依赖的package包/类
public TextField(String label, String text, int maxSize, int constraints) {
super(label);
super.setUI(DeviceFactory.getDevice().getUIFactory().createTextFieldUI(this));
if (maxSize <= 0) {
throw new IllegalArgumentException();
}
setConstraints(constraints);
if (!InputMethod.validate(text, constraints)) {
throw new IllegalArgumentException();
}
if (maxSize <= 0) {
throw new IllegalArgumentException();
}
this.maxSize = maxSize;
stringComponent = new StringComponent();
if (text != null) {
setString(text);
} else {
setString("");
}
stringComponent.setWidthDecreaser(8);
}
示例2: setString
import org.microemu.device.InputMethod; //导入方法依赖的package包/类
void setString(String text, int caret) {
if (!InputMethod.validate(text, constraints)) {
throw new IllegalArgumentException("text is illegal for the current input constraints");
}
if (text == null) {
field = "";
stringComponent.setText("");
} else {
if (text.length() > maxSize) {
throw new IllegalArgumentException("text exceeds the current maximum capacity");
}
field = text;
if ((constraints & PASSWORD) == 0) {
stringComponent.setText(text);
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
sb.append('*');
}
stringComponent.setText(sb.toString());
}
}
setCaretPosition(caret);
setCaretVisible(false);
repaint();
}
示例3: insert
import org.microemu.device.InputMethod; //导入方法依赖的package包/类
public void insert(String src, int position) {
if (!InputMethod.validate(src, constraints)) {
throw new IllegalArgumentException();
}
if (field.length() + src.length() > maxSize) {
throw new IllegalArgumentException();
}
String newtext = "";
if (position > 0) {
newtext = ((AndroidTextFieldUI) ui).getString();
}
newtext += src;
if (position < field.length()) {
newtext += ((AndroidTextFieldUI) ui).getString().substring(position + 1);
}
((AndroidTextFieldUI) ui).setString(newtext);
}
示例4: setChars
import org.microemu.device.InputMethod; //导入方法依赖的package包/类
public void setChars(char[] data, int offset, int length) {
if (data == null) {
setString("");
} else {
if (length > maxSize) {
throw new IllegalArgumentException();
}
String newtext = new String(data, offset, length);
if (!InputMethod.validate(newtext, constraints)) {
throw new IllegalArgumentException();
}
setString(newtext);
}
repaint();
}
示例5: setConstraints
import org.microemu.device.InputMethod; //导入方法依赖的package包/类
public final void setConstraints(int constraints) {
if ((constraints & TextField.CONSTRAINT_MASK) < ANY
|| (constraints & TextField.CONSTRAINT_MASK) > DECIMAL) {
throw new IllegalArgumentException("constraints " + constraints + " is an illegal value");
}
this.constraints = constraints;
if (!InputMethod.validate(getString(), constraints)) {
setString("");
}
((TextFieldUI) ui).setConstraints(constraints);
}