本文整理了Java中org.openide.util.Utilities.isJavaIdentifier()
方法的一些代码示例,展示了Utilities.isJavaIdentifier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.isJavaIdentifier()
方法的具体详情如下:
包路径:org.openide.util.Utilities
类名称:Utilities
方法名:isJavaIdentifier
[英]Test whether a given string is a valid Java identifier.
[中]测试给定的字符串是否是有效的Java标识符。
代码示例来源:origin: org.netbeans.api/org-openide-util
private String toIdentifier(String key) {
if (Utilities.isJavaIdentifier(key)) {
return key;
} else {
String i = key.replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_");
if (Utilities.isJavaIdentifier(i)) {
return i;
} else {
return "_" + i;
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-util
/**
* Asserts the parameter value is either <code>null</code> or a Java
* identifier.
*
* @param name the parameter name.
* @param value the parameter value.
* @throws IllegalArgumentException if the parameter value is neither
* <code>null</code> nor a Java identifier.
*/
public static void javaIdentifierOrNull(CharSequence name, CharSequence value) {
if (value != null && !Utilities.isJavaIdentifier(value.toString())) {
throw new IllegalArgumentException("The " + name + " parameter ('" + value + "') is not a valid Java identifier"); // NOI18N
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-util-ui
private String toIdentifier(String key) {
if (Utilities.isJavaIdentifier(key)) {
return key;
} else {
String i = key.replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_");
if (Utilities.isJavaIdentifier(i)) {
return i;
} else {
return "_" + i;
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project
static boolean isValidTypeIdentifier(String ident) {
return Utilities.isJavaIdentifier(ident);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core
private boolean isJavaIdentifier(String s) {
return org.openide.util.Utilities.isJavaIdentifier(s);
}
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
private String toIdentifier(String key) {
if (Utilities.isJavaIdentifier(key)) {
return key;
} else {
String i = key.replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_");
if (Utilities.isJavaIdentifier(i)) {
return i;
} else {
return "_" + i;
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-grailsproject
static boolean isValidTypeIdentifier(String ident) {
if (ident == null || "".equals(ident) || !Utilities.isJavaIdentifier(ident)) {
return false;
} else {
return true;
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp
public static boolean isValidFQNClassName (String string) {
if (string == null)
return false;
for (String part : string.split ("\\.", -2)) { // NOI18N
if (! Utilities.isJavaIdentifier (part))
return false;
}
return true;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-project-ui
private static boolean isValidTypeIdentifier(String ident) {
return ident != null && !"".equals(ident) && Utilities.isJavaIdentifier( ident ); //NOI18N
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
boolean doesMethodContainBadChars() {
newMethodName = methodField.getText();
if(newMethodName.contains(" ")) { //NOI18N
return true;
}
if(newMethodName.matches("^\\d.*")) { //NOI18N
return true;
}
if(!Utilities.isJavaIdentifier(newMethodName)) {
return true;
}
return false;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javaee-project
private boolean isMainClassValid(String mainClassName) {
StringTokenizer tk = new StringTokenizer(mainClassName, "."); //NOI18N
boolean valid = tk.countTokens() > 0;
while (tk.hasMoreTokens()) {
String token = tk.nextToken();
if (token.length() == 0 || !Utilities.isJavaIdentifier(token)) {
valid = false;
break;
}
}
return valid;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-project-ui
static boolean isValidPackageName(String str) {
if (str.length() > 0 && str.charAt(0) == '.') {
return false;
}
StringTokenizer tukac = new StringTokenizer(str, ".");
while (tukac.hasMoreTokens()) {
String token = tukac.nextToken();
if ("".equals(token))
return false;
if (!Utilities.isJavaIdentifier(token))
return false;
}
return true;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project
private void fxmlNameChanged() {
String fxmlName = fxmlTextField.getText();
isFXMLNameValid = !fxmlName.isEmpty() && Utilities.isJavaIdentifier(fxmlName);
panel.fireChangeEvent();
}
代码示例来源:origin: dcaoyuan/nbscala
public void propertyChange (PropertyChangeEvent event) {
if (PanelProjectLocationVisual.PROP_PROJECT_NAME.equals(event.getPropertyName())) {
String newProjectName = NewJ2SEProjectWizardIterator.getPackageName((String) event.getNewValue());
if (!Utilities.isJavaIdentifier(newProjectName)) {
newProjectName = NbBundle.getMessage (PanelOptionsVisual.class, "TXT_PackageNameSuffix", newProjectName);
}
this.mainClassTextField.setText (MessageFormat.format(
NbBundle.getMessage (PanelOptionsVisual.class,"TXT_ClassName"), new Object[] {newProjectName}
));
}
if (PanelProjectLocationVisual.PROP_PROJECT_LOCATION.equals(event.getPropertyName())) {
projectLocation = (String)event.getNewValue();
}
}
代码示例来源:origin: dcaoyuan/nbscala
private void mainClassChanged () {
String mainClassName = this.mainClassTextField.getText ();
StringTokenizer tk = new StringTokenizer (mainClassName, "."); //NOI18N
boolean valid = true;
while (tk.hasMoreTokens()) {
String token = tk.nextToken();
if (token.length() == 0 || !Utilities.isJavaIdentifier(token)) {
valid = false;
break;
}
}
this.valid = valid;
this.panel.fireChangeEvent();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project
public void propertyChange (PropertyChangeEvent event) {
if ("roots".equals(event.getPropertyName())) {
fireChangeEvent();
}
if (PanelProjectLocationVisual.PROP_PROJECT_NAME.equals(event.getPropertyName())) {
String newProjectName = NewRubyProjectWizardIterator.getPackageName((String) event.getNewValue());
if (!Utilities.isJavaIdentifier(newProjectName)) {
newProjectName = NbBundle.getMessage (PanelOptionsVisual.class, "TXT_PackageNameSuffix", newProjectName);
}
this.mainClassTextField.setText (MessageFormat.format(
NbBundle.getMessage (PanelOptionsVisual.class,"TXT_ClassName"), new Object[] {newProjectName}
));
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-wizards
private int checkFinalPanel() {
if (getPackageName().length() == 0) {
return MSG_BLANK_PACKAGE_NAME;
} else if (getClassNamePrefix().length() == 0) {
return MSG_BLANK_CLASSNAME_PREFIX;
} else if (!Utilities.isJavaIdentifier(getClassNamePrefix())) {
return ERR_INVALID_CLASSNAME_PREFIX;
}
return 0;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-wizards
String getClassNamePrefix() {
if (classNamePrefix == null) {
classNamePrefix = isAdvanced() ? getSecondaryPanelTitle() : getCategoryName();
classNamePrefix = classNamePrefix.trim().replaceAll(" ", "");
if (!Utilities.isJavaIdentifier(classNamePrefix)) {
classNamePrefix = "";
}
}
return classNamePrefix;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-grailsproject
@Override
public void setName(final String name) {
if (Utilities.isJavaIdentifier(name)) {
super.setName(name);
} else {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
NbBundle.getMessage(TreeRootNode.class, "MSG_InvalidPackageName"), NotifyDescriptor.INFORMATION_MESSAGE));
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project
/**
* Returns error message or null if no error occurred
*/
String isNewClassValid() {
if(!radioButtonNewClass.isSelected()) {
return null;
}
if (!Utilities.isJavaIdentifier(getNewClassName())) {
return NbBundle.getMessage(JSEApplicationClassChooser.class, "WARN_Provide_Java_Class_Name"); // NOI18N
}
return FXMLTemplateWizardIterator.canUseFileName(FileUtil.toFile(support.getCurrentChooserFolder()), getNewClassName() + JAVA_FILE_EXTENSION);
}
内容来源于网络,如有侵权,请联系作者删除!