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


Java Modifier.PROTECTED屬性代碼示例

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


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

示例1: installLinkedVisibilityProposals

public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) {
	ASTNode modifier = findVisibilityModifier(modifiers);
	if (modifier != null) {
		int selected = ((Modifier) modifier).getKeyword().toFlagValue();

		LinkedProposalPositionGroup positionGroup = linkedProposalModel.getPositionGroup(groupId, true);
		positionGroup.addPosition(rewrite.track(modifier), false);
		positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

		// add all others
		int[] flagValues = inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
		for (int i = 0; i < flagValues.length; i++) {
			if (flagValues[i] != selected) {
				positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:18,代碼來源:ModifierCorrectionSubProcessor.java

示例2: isHigherVisibility

/**
 * Compares two visibilities.
 *
 * @param newVisibility the 'new' visibility
 * @param oldVisibility the 'old' visibility
 * @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
 * @see Modifier#PUBLIC
 * @see Modifier#PROTECTED
 * @see Modifier#NONE
 * @see Modifier#PRIVATE
 */
public static boolean isHigherVisibility(int newVisibility, int oldVisibility) {
  assertVisibility(oldVisibility);
  assertVisibility(newVisibility);
  switch (oldVisibility) {
    case Modifier.PRIVATE:
      return newVisibility == Modifier.NONE
          || newVisibility == Modifier.PUBLIC
          || newVisibility == Modifier.PROTECTED;
    case Modifier.NONE:
      return newVisibility == Modifier.PUBLIC || newVisibility == Modifier.PROTECTED;

    case Modifier.PROTECTED:
      return newVisibility == Modifier.PUBLIC;

    case Modifier.PUBLIC:
      return false;
    default:
      Assert.isTrue(false);
      return false;
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:32,代碼來源:JdtFlags.java

示例3: isHigherVisibility

/**
 * Compares two visibilities.
 *
 * @param newVisibility the 'new' visibility
 * @param oldVisibility the 'old' visibility
 * @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
 * @see org.eclipse.jdt.core.dom.Modifier#PUBLIC
 * @see org.eclipse.jdt.core.dom.Modifier#PROTECTED
 * @see org.eclipse.jdt.core.dom.Modifier#NONE
 * @see org.eclipse.jdt.core.dom.Modifier#PRIVATE
 */
public static boolean isHigherVisibility(int newVisibility, int oldVisibility) {
  assertVisibility(oldVisibility);
  assertVisibility(newVisibility);
  switch (oldVisibility) {
    case Modifier.PRIVATE:
      return newVisibility == Modifier.NONE
          || newVisibility == Modifier.PUBLIC
          || newVisibility == Modifier.PROTECTED;
    case Modifier.NONE:
      return newVisibility == Modifier.PUBLIC || newVisibility == Modifier.PROTECTED;

    case Modifier.PROTECTED:
      return newVisibility == Modifier.PUBLIC;

    case Modifier.PUBLIC:
      return false;
    default:
      Assert.isTrue(false);
      return false;
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:32,代碼來源:JdtFlags.java

示例4: getNeededVisibility

private static int getNeededVisibility(
    ASTNode currNode, ITypeBinding targetType, IBinding binding) {
  ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode);
  if (currNodeBinding == null) { // import
    return Modifier.PUBLIC;
  }

  if (Bindings.isSuperType(targetType, currNodeBinding)) {
    if (binding != null
        && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
      return Modifier.PUBLIC;
    }
    return Modifier.PROTECTED;
  }

  if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
    return 0;
  }
  return Modifier.PUBLIC;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:20,代碼來源:ModifierCorrectionSubProcessor.java

示例5: installLinkedVisibilityProposals

public static void installLinkedVisibilityProposals(
    LinkedProposalModel linkedProposalModel,
    ASTRewrite rewrite,
    List<IExtendedModifier> modifiers,
    boolean inInterface) {
  ASTNode modifier = findVisibilityModifier(modifiers);
  if (modifier != null) {
    int selected = ((Modifier) modifier).getKeyword().toFlagValue();

    LinkedProposalPositionGroup positionGroup =
        linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
    positionGroup.addPosition(rewrite.track(modifier), false);
    positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

    // add all others
    int[] flagValues =
        inInterface
            ? new int[] {Modifier.PUBLIC, 0}
            : new int[] {Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE};
    for (int i = 0; i < flagValues.length; i++) {
      if (flagValues[i] != selected) {
        positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
      }
    }
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:26,代碼來源:ModifierCorrectionSubProcessor.java

示例6: getVisibility

private Visibility getVisibility(int methodModifiers) {
    Visibility visibility;
    if ((methodModifiers & Modifier.PUBLIC) != 0)
        visibility = Visibility.PUBLIC;
    else if ((methodModifiers & Modifier.PROTECTED) != 0)
        visibility = Visibility.PROTECTED;
    else if ((methodModifiers & Modifier.PRIVATE) != 0)
        visibility = Visibility.PRIVATE;
    else
        visibility = Visibility.PACKAGE;
    return visibility;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:12,代碼來源:BindingsRecoveryAstVisitor.java

示例7: getModifier

private static String getModifier(IBinding ib) {
	if ((ib.getModifiers() & Modifier.PUBLIC) > 0)
		return Fact.PUBLIC;
	else if ((ib.getModifiers() & Modifier.PROTECTED) > 0)
		return Fact.PROTECTED;
	else if ((ib.getModifiers() & Modifier.PRIVATE) > 0)
		return Fact.PRIVATE;
	else
		return Fact.PACKAGE;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:10,代碼來源:ASTVisitorAtomicChange.java

示例8: evaluateFieldModifiers

private int evaluateFieldModifiers(ASTNode newTypeDecl) {
	if (fSenderBinding.isAnnotation()) {
		return 0;
	}
	if (fSenderBinding.isInterface()) {
		// for interface members copy the modifiers from an existing field
		FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
		if (fieldDecls.length > 0) {
			return fieldDecls[0].getModifiers();
		}
		return 0;
	}
	int modifiers= 0;

	if (fVariableKind == CONST_FIELD) {
		modifiers |= Modifier.FINAL | Modifier.STATIC;
	} else {
		ASTNode parent= fOriginalNode.getParent();
		if (parent instanceof QualifiedName) {
			IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
			if (qualifierBinding instanceof ITypeBinding) {
				modifiers |= Modifier.STATIC;
			}
		} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
			modifiers |= Modifier.STATIC;
		}
	}
	ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
	if (newTypeDecl.equals(node)) {
		modifiers |= Modifier.PRIVATE;
	} else if (node instanceof AnonymousClassDeclaration) {
		modifiers |= Modifier.PROTECTED;
	} else {
		modifiers |= Modifier.PUBLIC;
	}

	return modifiers;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:38,代碼來源:NewVariableCorrectionProposal.java

示例9: getVisibilityCode

public static int getVisibilityCode(String visibilityString) {
  Assert.isNotNull(visibilityString);
  if (VISIBILITY_STRING_PACKAGE.equals(visibilityString)) return 0;
  else if (VISIBILITY_STRING_PRIVATE.equals(visibilityString)) return Modifier.PRIVATE;
  else if (VISIBILITY_STRING_PROTECTED.equals(visibilityString)) return Modifier.PROTECTED;
  else if (VISIBILITY_STRING_PUBLIC.equals(visibilityString)) return Modifier.PUBLIC;
  return VISIBILITY_CODE_INVALID;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:8,代碼來源:JdtFlags.java

示例10: addDefaultConstructor

void addDefaultConstructor(
    ITypeBinding type, List<BodyDeclaration> members, List<Statement> initStatements) {
  int constructorModifier =
      type.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
  GeneratedMethodBinding binding = GeneratedMethodBinding.newConstructor(
      type.getSuperclass(), constructorModifier);
  initStatements.add(0, new SuperConstructorInvocation(binding));
  members.add(createMethod(GeneratedMethodBinding.newConstructor(type, constructorModifier),
                           initStatements));
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:10,代碼來源:InitializationNormalizer.java

示例11: getVisibilityCode

public static int getVisibilityCode(IMember member) throws JavaModelException {
  if (isPublic(member)) return Modifier.PUBLIC;
  else if (isProtected(member)) return Modifier.PROTECTED;
  else if (isPackageVisible(member)) return Modifier.NONE;
  else if (isPrivate(member)) return Modifier.PRIVATE;
  Assert.isTrue(false);
  return VISIBILITY_CODE_INVALID;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:8,代碼來源:JdtFlags.java

示例12: isVisibilityModifier

/**
 * Is the specified modifier a visibility modifier?
 *
 * @param modifier the keyword to test
 * @return <code>true</code> if it is a visibility modifier, <code>false</code> otherwise
 */
private static boolean isVisibilityModifier(final int modifier) {
  return modifier == Modifier.NONE
      || modifier == Modifier.PUBLIC
      || modifier == Modifier.PROTECTED
      || modifier == Modifier.PRIVATE;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:12,代碼來源:MemberVisibilityAdjustor.java

示例13: getAccessModifier

private static int getAccessModifier(AbstractTypeDeclaration subclass) {
  int modifiers = subclass.getModifiers();
  if (Modifier.isPublic(modifiers)) return Modifier.PUBLIC;
  else if (Modifier.isProtected(modifiers)) return Modifier.PROTECTED;
  else if (Modifier.isPrivate(modifiers)) return Modifier.PRIVATE;
  else return Modifier.NONE;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:7,代碼來源:ChangeSignatureProcessor.java

示例14: getAvailableVisibilities

public int[] getAvailableVisibilities() {
  if (isLocalInnerType()) {
    return new int[] {Modifier.NONE};
  } else {
    return new int[] {Modifier.PUBLIC, Modifier.PROTECTED, Modifier.NONE, Modifier.PRIVATE};
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:7,代碼來源:ConvertAnonymousToNestedRefactoring.java

示例15: makeDeclarationPrivate

private TextEditGroup makeDeclarationPrivate(ASTRewrite rewriter, FieldDeclaration decl) {
  TextEditGroup description =
      new TextEditGroup(RefactoringCoreMessages.SelfEncapsulateField_change_visibility);
  VariableDeclarationFragment[] vdfs = new VariableDeclarationFragment[] {fFieldDeclaration};
  int includedModifiers = Modifier.PRIVATE;
  int excludedModifiers = Modifier.PROTECTED | Modifier.PUBLIC;
  VariableDeclarationRewrite.rewriteModifiers(
      decl, vdfs, includedModifiers, excludedModifiers, rewriter, description);
  return description;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:10,代碼來源:SelfEncapsulateFieldRefactoring.java


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