本文整理汇总了Java中org.eclipse.jdt.core.JavaConventions.validatePackageName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConventions.validatePackageName方法的具体用法?Java JavaConventions.validatePackageName怎么用?Java JavaConventions.validatePackageName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.JavaConventions
的用法示例。
在下文中一共展示了JavaConventions.validatePackageName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* Check if a string is a legal Java package name.
*/
public static IStatus validate(String packageName) {
if (packageName == null) {
return new Status(IStatus.ERROR, PLUGIN_ID, 45, "null package name", null);
} else if (packageName.isEmpty()) { // default package is allowed
return Status.OK_STATUS;
} else if (packageName.endsWith(".")) { //$NON-NLS-1$
// todo or allow this and strip the period
return new Status(IStatus.ERROR, PLUGIN_ID, 46,
Messages.getString("package.ends.with.period", packageName), null); //$NON-NLS-1$
} else if (containsWhitespace(packageName)) {
// very weird condition because validatePackageName allows internal white space
return new Status(IStatus.ERROR, PLUGIN_ID, 46,
Messages.getString("package.contains.whitespace", packageName), null); //$NON-NLS-1$
} else {
return JavaConventions.validatePackageName(
packageName, JavaCore.VERSION_1_4, JavaCore.VERSION_1_4);
}
}
示例2: validatePage
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
@Override
protected boolean validatePage() {
if (!super.validatePage())
return false;
IStatus status = JavaConventions.validatePackageName(getProjectName(), JavaCore.VERSION_1_5,
JavaCore.VERSION_1_5);
if (!status.isOK()) {
if (status.matches(IStatus.WARNING)) {
setMessage(status.getMessage(), IStatus.WARNING);
return true;
}
setErrorMessage(Messages.WizardNewtxtUMLProjectCreationPage_ErrorMessageProjectName + status.getMessage());
return false;
}
setErrorMessage(null);
setMessage(null);
return true;
}
示例3: doValidation
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(PreferencesMessages.TypeFilterInputDialog_error_enterName);
} else {
newText= newText.replace('*', 'X').replace('?', 'Y');
IStatus val= JavaConventions.validatePackageName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
if (val.matches(IStatus.ERROR)) {
status.setError(Messages.format(PreferencesMessages.TypeFilterInputDialog_error_invalidName, val.getMessage()));
} else {
if (fExistingEntries.contains(newText)) {
status.setError(PreferencesMessages.TypeFilterInputDialog_error_entryExists);
}
}
}
updateStatus(status);
}
示例4: validateName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* Validate name.
*
* @return the i status
*/
public String validateName() {
final String name = getDependencyName();
if (origin != null && name.equals(origin.getName())) {
return null;
}
for (ManifestItem o : input) {
if (name.equals(o.getName())) {
return Messages.NewDependencyItemDialog_existCheckMessage;
}
}
// Bundle-SymbolicName could include dash (-) and other characters
if (!this.type.equals(ManifestItem.REQUIRE_BUNDLE)) {
final IStatus status = JavaConventions.validatePackageName(name);
if (!status.isOK()) {
return status.getMessage();
}
}
return null;
}
示例5: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void validate() {
if (projectData.packageName.trim().isEmpty()) {
setErrorMessage("Package name must not be empty");
setPageComplete(false);
return;
}
IStatus validPackageName = JavaConventions.validatePackageName(projectData.packageName, "1.5", "1.5");
if (!validPackageName.isOK()) {
setErrorMessage("Package name is invalid");
setPageComplete(false);
return;
}
if (projectData.androidSelected) {
String androidValidation = validateAndroidPackageName(projectData.packageName);
if (androidValidation != null) {
setErrorMessage(androidValidation);
setPageComplete(false);
return;
}
}
if (projectData.mainClassName.trim().isEmpty()) {
setErrorMessage("Main class name must not be empty");
setPageComplete(false);
return;
}
IStatus validClassName = JavaConventions.validateJavaTypeName(projectData.mainClassName, "1.5", "1.5");
if (!validClassName.isOK()) {
setErrorMessage("Main class name is invalid");
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
示例6: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void validate() {
if (projectData.packageName.trim().isEmpty()) {
setErrorMessage("Package name must not be empty");
setPageComplete(false);
return;
}
IStatus validPackageName = JavaConventions.validatePackageName(projectData.packageName, "1.5", "1.5");
if (!validPackageName.isOK()) {
setErrorMessage("Package name is invalid");
setPageComplete(false);
return;
}
if (projectData.mainClassName.trim().isEmpty()) {
setErrorMessage("Main class name must not be empty");
setPageComplete(false);
return;
}
IStatus validClassName = JavaConventions.validateJavaTypeName(projectData.mainClassName, "1.5", "1.5");
if (!validClassName.isOK()) {
setErrorMessage("Main class name is invalid");
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
示例7: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
public static IStatus validatePackageName(String packageName) {
if (packageName.length() > 0) {
String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
String compliance = JavaCore.getOption("org.eclipse.jdt.core.compiler.source");
return JavaConventions.validatePackageName(packageName, sourceLevel,
compliance);
}
return newWarningStatus(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
示例8: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private IStatus validatePackageName(String text) {
IJavaProject project= getJavaProject();
if (project == null || !project.exists()) {
return JavaConventions.validatePackageName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
}
return JavaConventionsUtil.validatePackageName(text, project);
}
示例9: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private static IStatus validatePackageName(String text, IJavaProject project) {
if (project == null || !project.exists()) {
return JavaConventions.validatePackageName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
}
return JavaConventionsUtil.validatePackageName(text, project);
}
示例10: validateRefactoring
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
protected void validateRefactoring() {
List<String> names= new ArrayList<String>();
boolean oneChecked= false;
setMessage(null);
setErrorMessage(null);
setPageComplete(true);
IJavaProject project= fProcessor.getMethod().getJavaProject();
String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true);
String compliance= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
List<ParameterInfo> parameterInfos= fProcessor.getParameterInfos();
for (Iterator<ParameterInfo> iter= parameterInfos.iterator(); iter.hasNext();) {
ParameterInfo pi= iter.next();
if (names.contains(pi.getNewName())) {
setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_notunique, BasicElementLabels.getJavaElementName(pi.getNewName())));
setPageComplete(false);
return;
}
names.add(pi.getNewName());
IStatus validateIdentifier= JavaConventions.validateIdentifier(pi.getNewName(), sourceLevel, compliance);
if (isErrorMessage(validateIdentifier))
return;
if (pi.isCreateField())
oneChecked= true;
}
if (!oneChecked) {
setErrorMessage(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_atleastoneparameter);
setPageComplete(false);
return;
}
IStatus validateJavaTypeName= JavaConventions.validateJavaTypeName(fProcessor.getClassName(), sourceLevel, compliance);
if (isErrorMessage(validateJavaTypeName))
return;
if (fProcessor.getClassName().indexOf('.') != -1) {
setErrorMessage(RefactoringMessages.IntroduceParameterObjectWizard_dot_not_allowed_error);
setPageComplete(false);
}
if (!"".equals(fProcessor.getPackage())) { //$NON-NLS-1$
IStatus validatePackageName= JavaConventions.validatePackageName(fProcessor.getPackage(), sourceLevel, compliance);
if (isErrorMessage(validatePackageName))
return;
}
try {
IType type= project.findType(fProcessor.getNewTypeName());
if (type != null) {
String packageLabel= JavaElementLabels.getElementLabel(type.getPackageFragment(), JavaElementLabels.ALL_DEFAULT);
if (fProcessor.isCreateAsTopLevel()) {
setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_type_already_exists_in_package_info,
new Object[] { BasicElementLabels.getJavaElementName(fProcessor.getClassName()), packageLabel }));
setPageComplete(false);
return;
} else {
setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_alreadyexists,
new Object[] { BasicElementLabels.getJavaElementName(fProcessor.getClassName()), BasicElementLabels.getFileName(type.getCompilationUnit()) }));
setPageComplete(false);
return;
}
}
} catch (JavaModelException e) {
// Don't care. The error will popup later anyway..
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:62,代码来源:IntroduceParameterObjectWizard.java
示例11: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
@Override
public IStatus validate(final String input) {
return JavaConventions.validatePackageName(input, PackageTextValidator.JAVA_VERSION,
PackageTextValidator.JAVA_VERSION);
}
示例12: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* @param name
* the name to validate
* @param context
* an {@link IJavaElement} or <code>null</code>
* @return validation status in <code>context</code>'s project or in the
* workspace
*
* @see JavaConventions#validatePackageName(String, String, String)
*/
public static IStatus validatePackageName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validatePackageName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例13: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* @param name the name to validate
* @param context an {@link IJavaElement} or <code>null</code>
* @return validation status in <code>context</code>'s project or in the workspace
* @see JavaConventions#validatePackageName(String, String, String)
*/
public static IStatus validatePackageName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validatePackageName(
name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例14: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* @param name the name to validate
* @param context an {@link IJavaElement} or <code>null</code>
* @return validation status in <code>context</code>'s project or in the workspace
*
* @see JavaConventions#validatePackageName(String, String, String)
*/
public static IStatus validatePackageName(String name, IJavaElement context) {
String[] sourceComplianceLevels= getSourceComplianceLevels(context);
return JavaConventions.validatePackageName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例15: validatePackageName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* @param name
* @param context
* @return a status indicating whether the supplied package name is valid
* for the supplied Java element
*/
public static IStatus validatePackageName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validatePackageName(name, sourceComplianceLevels[0],
sourceComplianceLevels[1]);
}