當前位置: 首頁>>代碼示例>>Java>>正文


Java Utilities.isJavaIdentifier方法代碼示例

本文整理匯總了Java中org.openide.util.Utilities.isJavaIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.isJavaIdentifier方法的具體用法?Java Utilities.isJavaIdentifier怎麽用?Java Utilities.isJavaIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.util.Utilities的用法示例。


在下文中一共展示了Utilities.isJavaIdentifier方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fastCheckParameters

import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
public Problem fastCheckParameters() {
    Problem result = null;
    
    String newName = refactoring.getSuperClassName();
    
    if (!Utilities.isJavaIdentifier(newName)) {
        result = createProblem(result, true, NbBundle.getMessage(ExtractSuperclassRefactoringPlugin.class, "ERR_InvalidIdentifier", newName)); // NOI18N
        return result;
    }
    
    FileObject primFile = refactoring.getSourceType().getFileObject();
    FileObject folder = primFile.getParent();
    FileObject[] children = folder.getChildren();
    for (FileObject child: children) {
        if (!child.isVirtual() && child.getName().equals(newName) && "java".equals(child.getExt())) { // NOI18N
            result = createProblem(result, true, NbBundle.getMessage(ExtractSuperclassRefactoringPlugin.class, "ERR_ClassClash", newName, pkgName)); // NOI18N
            return result;
        }
    }

    return super.fastCheckParameters();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ExtractSuperclassRefactoringPlugin.java

示例2: isValidPackageName

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Checks whether the given <code>packageName</code> represents a
 * valid name for a package.
 *
 * @param packageName the package name to check; must not be null.
 * @return true if the given <code>packageName</code> is a valid package
 * name, false otherwise.
 */
public static boolean isValidPackageName(String packageName) {
    Parameters.notNull("packageName", packageName); //NOI18N

    if ("".equals(packageName)) {
        return true;
    }
    if (packageName.startsWith(".") || packageName.endsWith(".")) {// NOI18N
        return false;
    }
    if(packageName.equals("java") || packageName.startsWith("java.")) {//NOI18N
        return false;
    }

    String[] tokens = packageName.split("\\."); //NOI18N
    if (tokens.length == 0) {
        return Utilities.isJavaIdentifier(packageName);
    }
    for(String token : tokens) {
        if (!Utilities.isJavaIdentifier(token)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:JavaIdentifiers.java

示例3: isValidPackageName

import org.openide.util.Utilities; //導入方法依賴的package包/類
public 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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:TestUtil.java

示例4: testNameValidity

import org.openide.util.Utilities; //導入方法依賴的package包/類
/** Tests if the given string is valid name for associated pattern and if not, notifies
* the user.
* @return true if it is ok.
*/
boolean testNameValidity( String name ) {

    if (! Utilities.isJavaIdentifier( name ) ) {
        DialogDisplayer.getDefault().notify(
            new NotifyDescriptor.Message(getString("MSG_Not_Valid_Identifier"),
                                         NotifyDescriptor.ERROR_MESSAGE) );
        return false;
    }

    if (name.indexOf( "Listener" ) <= 0 ) { // NOI18N
        String msg = MessageFormat.format( getString("FMT_InvalidEventSourceName"),
                                           new Object[] { name } );
        DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE) );
        return false;
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:EventSetPatternNode.java

示例5: textChanged

import org.openide.util.Utilities; //導入方法依賴的package包/類
private void textChanged() {
    String s = textField.getText();
    String[] names = s.split(SuspiciousNamesCombination.SEPARATORS_REGEX);
    if (names.length == 0) {
        nls.setErrorMessage(Bundle.ERR_NameGroupCantBeEmpty());
        setValid(false);
        return;
    }
    for (String check : names) {
        if (!Utilities.isJavaIdentifier(check)) {
            nls.setErrorMessage(Bundle.ERR_NotJavaIdentifier(check));
            setValid(false);
            return;
        }
    }
    
    setValid(true);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:SuspiciousNamesCustomizer.java

示例6: getSelectedIdentifier

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Returns identifier currently selected in editor or <code>null</code>.
 *
 * @return identifier currently selected in editor or <code>null</code>
 */
@Override
public String getSelectedIdentifier () {
    JEditorPane ep = contextDispatcher.getCurrentEditor ();
    if (ep == null) {
        return null;
    }
    Caret caret = ep.getCaret();
    if (caret == null) {
        // No caret => no selected text
        return null;
    }
    String s = ep.getSelectedText ();
    if (s == null) {
        return null;
    }
    if (Utilities.isJavaIdentifier (s)) {
        return s;
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:EditorContextImpl.java

示例7: testNameValidity

import org.openide.util.Utilities; //導入方法依賴的package包/類
/** Tests if the given string is valid name for associated pattern and if not, notifies
* the user.
* @return true if it is ok.
*/
boolean testNameValidity( String name ) {

    if (! Utilities.isJavaIdentifier( name ) ) {
        DialogDisplayer.getDefault().notify(
            new NotifyDescriptor.Message(getString("MSG_Not_Valid_Identifier"),
                                         NotifyDescriptor.ERROR_MESSAGE) );
        return false;
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:PropertyPatternNode.java

示例8: isValidPackageName

import org.openide.util.Utilities; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:JavaTargetChooserPanel.java

示例9: validateClassName

import org.openide.util.Utilities; //導入方法依賴的package包/類
private Set<Problem> validateClassName(String className) {
        Set<Problem> problems = EnumSet.noneOf(Problem.class);
        if (!Utilities.isJavaIdentifier(className)) {
            problems.add(Problem.NO_JAVA_IDENTIFIER);
        }
        if (JavaPersistenceQLKeywords.isKeyword(className)) {
            problems.add(Problem.JPA_QL_IDENTIFIER);
        }
/* commented to have an ability to update entity classes
        if (targetFolder != null && targetFolder.getFileObject(className, "java") != null) { // NOI18N
            problems.add(Problem.ALREADY_EXISTS);
        }
 */
        return problems;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:SelectedTables.java

示例10: validateClassName

import org.openide.util.Utilities; //導入方法依賴的package包/類
private Set<Problem> validateClassName(String className) {
    Set<Problem> problems = EnumSet.noneOf(Problem.class);
    if (!Utilities.isJavaIdentifier(className)) {
        problems.add(Problem.NO_JAVA_IDENTIFIER);
    }        
    if (targetFolder != null && targetFolder.getFileObject(className, "java") != null) { // NOI18N
        problems.add(Problem.ALREADY_EXISTS);
    }
    return problems;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:SelectedTables.java

示例11: checkName

import org.openide.util.Utilities; //導入方法依賴的package包/類
public NameStatus checkName(String name){
    if (!Utilities.isJavaIdentifier(name)){
        return NameStatus.ILLEGAL_JAVA_ID;
    }
    
    if (JavaPersistenceQLKeywords.isKeyword(name)){
        return NameStatus.ILLEGAL_SQL_KEYWORD;
    }
    
    if (existingFieldNames != null && existingFieldNames.contains(name)){
        return NameStatus.DUPLICATE;
    }
    
    return NameStatus.VALID;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:CreateRelationshipPanel.java

示例12: checkValidity

import org.openide.util.Utilities; //導入方法依賴的package包/類
private boolean checkValidity() {
    if (txtPrefix.getText().trim().length() == 0) {
        setInfo(getMessage("ERR_Name_Prefix_Empty"), false);
        clearCreatedAndModifiedFilesTextArea();
        return false;
    }
    if (!Utilities.isJavaIdentifier(txtPrefix.getText().trim())) {
        setError(getMessage("ERR_Name_Prefix_Invalid"));
        return false;
    }
    String path = txtIcon.getText().trim();
    if (path.length() != 0) {
        File fil = new File(path);
        if (!fil.exists()) {
            setError(NbBundle.getMessage(getClass(), "ERR_Icon_Invalid"));
            return false;
        }
    }
    String packageName = comPackageName.getEditor().getItem().toString().trim();
    if (packageName.length() == 0 || !WizardUtils.isValidPackageName(packageName)) {
        setError(NbBundle.getMessage(getClass(), "ERR_Package_Invalid"));
        return false;
    }
    
    markValid();
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:NameAndLocationPanel.java

示例13: checkValidity

import org.openide.util.Utilities; //導入方法依賴的package包/類
private boolean checkValidity() {
    final String fileName = fileNametextField.getText().trim();
    final String mimeType = mimeTypeTextField.getText().trim();
    if(fileName.length() == 0) {
        setWarning(getMessage("ERR_FN_EMPTY"), false);
        return false;
    }
    if(!Utilities.isJavaIdentifier(normalize(fileName))) {
        setError(getMessage("ERR_FN_INVALID"));
        return false;
    }
    if(mimeType.length() == 0) {
        setWarning(getMessage("ERR_MT_EMPTY"), false);
        return false;
    }
    
    String packName = packageNameCombo.getEditor().getItem().toString();
    if(packName.equals("")) {
        setWarning(getMessage("EMPTY_PACKAGE"), false);
        return false;
    }
    
    if (cpCheckBox.isSelected()) {
        String cpFileName = cpFileNameField.getText().trim();
        if (cpFileName.length() == 0) {
            setWarning(getMessage("ERR_FN_EMPTY"), false);
            return false;
        }
        if (!Utilities.isJavaIdentifier(normalize(cpFileName))) {
            setError(getMessage("ERR_FN_INVALID"));
            return false;
        }
    }
    markValid();
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:CodeGeneratorPanel.java

示例14: isQualifiedIdentifier

import org.openide.util.Utilities; //導入方法依賴的package包/類
public static boolean isQualifiedIdentifier(String qn) {
    StringTokenizer tukac = new StringTokenizer(qn, ".");
    if (!tukac.hasMoreTokens()) {
        return false;
    }
    while (tukac.hasMoreTokens()) {
        if (!Utilities.isJavaIdentifier(tukac.nextToken())) {
            return false;
        }
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:FxXmlSymbols.java

示例15: checkValidity

import org.openide.util.Utilities; //導入方法依賴的package包/類
private boolean checkValidity() {
    if (!checkPlatformValidity()) {
        return false;
    }
    if (txtName.getText().trim().length() == 0) {
        setInfo(getMessage("ERR_Name_Prefix_Empty"), false);
        return false;
    }
    if (txtDisplayName.getText().trim().length() == 0) {
        setInfo(getMessage("ERR_Display_Name_Prefix_Empty"), false);
        return false;
    }
    if (!Utilities.isJavaIdentifier(txtName.getText().trim())) {
        setError(getMessage("ERR_Name_Prefix_Invalid"));
        return false;
    }
    String packageName = comPackageName.getEditor().getItem().toString().trim();
    if (packageName.length() == 0 || !WizardUtils.isValidPackageName(packageName)) {
        setError(getMessage("ERR_Package_Invalid"));
        return false;
    }
    if (!WizardUtils.isValidSFSPath(getCategoryPath())) {
        setError(getMessage("ERR_Category_Invalid"));
        return false;
    }
    markValid();
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:NameAndLocationPanel.java


注:本文中的org.openide.util.Utilities.isJavaIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。