Class: JavaClass::MethodAccessFlag

Inherits:
AccessFlag show all
Defined in:
lib/javaclass/accessflag.rb

Overview

メソッドのアクセスフラグ

Constant Summary collapse

ACC_PUBLIC =

Declared public; may be accessed from outside its package.

0x0001
ACC_PRIVATE =

Declared private; accessible only within the defining class.

0x0002
ACC_PROTECTED =

Declared protected; may be accessed within subclasses.

0x0004
ACC_STATIC =

Declared static.

0x0008
ACC_FINAL =

Declared final; must not be overridden.

0x0010
ACC_SYNCHRONIZED =

Declared synchronized; invocation is wrapped in a monitor lock.

0x0020
ACC_BRIDGE =

A bridge method, generated by the compiler.

0x0040
ACC_VARARGS =

Declared with variable number of arguments.

0x0080
ACC_NATIVE =

Declared native; implemented in a language other than Java.

0x0100
ACC_ABSTRACT =

Declared abstract; no implementation is provided.

0x0400
ACC_STRICT =

Declared strictfp; floating-point mode is FP-strict

0x0800
ACC_SYNTHETIC =

Declared synthetic; Not present in the source code.

0x1000

Instance Method Summary collapse

Methods inherited from AccessFlag

#initialize, #off, #on, #on?, #to_bytes

Methods included from Base

#==, #===, #dump, #eql?, #hash, #to_byte

Constructor Details

This class inherits a constructor from JavaClass::AccessFlag

Instance Method Details

#accessorObject

アクセサを文字列で取得する。

戻り値::アクセサを示す文字列



197
198
199
200
201
202
# File 'lib/javaclass/accessflag.rb', line 197

def accessor
  return "public"     if on? ACC_PUBLIC
  return "protected"  if on? ACC_PROTECTED
  return "private"    if on? ACC_PRIVATE
  return ""
end

#source_modifiersObject

ソースコードに登場するモディファイアを配列で取得する。

戻り値::ソースコードに登場するモディファイアの配列



181
182
183
184
185
186
187
188
189
190
# File 'lib/javaclass/accessflag.rb', line 181

def source_modifiers
  modifiers = []
  modifiers << "static"       if on? ACC_STATIC
  modifiers << "final"        if on? ACC_FINAL
  modifiers << "synchronized" if on? ACC_SYNCHRONIZED
  modifiers << "native"       if on? ACC_NATIVE
  modifiers << "abstract"     if on? ACC_ABSTRACT
  modifiers << "strictfp"     if on? ACC_STRICT
  return modifiers
end

#to_sObject



204
205
206
207
# File 'lib/javaclass/accessflag.rb', line 204

def to_s
  list = accessor.length > 0 ? [accessor] : []
  (list + source_modifiers).join(" ")
end