MCPcopy Create free account
hub / github.com/beanshell/beanshell / addModifier

Method addModifier

src/bsh/Modifiers.java:45–74  ·  view source on GitHub ↗

@param context is METHOD or FIELD

( int context, String name )

Source from the content-addressed store, hash-verified

43 @param context is METHOD or FIELD
44 */
45 public void addModifier( int context, String name )
46 {
47 if ( modifiers == null )
48 modifiers = new Hashtable();
49
50 Object existing = modifiers.put( name, Void.TYPE/*arbitrary flag*/ );
51 if ( existing != null )
52 throw new IllegalStateException("Duplicate modifier: "+ name );
53
54 int count = 0;
55 if ( hasModifier("private") ) ++count;
56 if ( hasModifier("protected") ) ++count;
57 if ( hasModifier("public") ) ++count;
58 if ( count > 1 )
59 throw new IllegalStateException(
60 "public/private/protected cannot be used in combination." );
61
62 switch( context )
63 {
64 case CLASS:
65 validateForClass();
66 break;
67 case METHOD:
68 validateForMethod();
69 break;
70 case FIELD:
71 validateForField();
72 break;
73 }
74 }
75
76 public boolean hasModifier( String name )
77 {

Callers 4

setTypedVariableMethod · 0.95
ModifiersMethod · 0.95
makePublicMethod · 0.80

Calls 5

hasModifierMethod · 0.95
validateForClassMethod · 0.95
validateForMethodMethod · 0.95
validateForFieldMethod · 0.95
putMethod · 0.65

Tested by

no test coverage detected