Class: JavaClass::ClassAccessFlag

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_FINAL =

Declared final; no subclasses allowed.

0x0010
ACC_SUPER =

Treat superclass methods specially when invoked by the invokespecial instruction.

0x0020
ACC_INTERFACE =

Is an interface, not a class.

0x0200
ACC_ABSTRACT =

Declared abstract; must not be instantiated.

0x0400
ACC_SYNTHETIC =

Declared synthetic; Not present in the source code.

0x1000
ACC_ANNOTATION =

Declared as an annotation type.

0x2000
ACC_ENUM =

Declared as an enum type.

0x4000

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

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

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



69
70
71
72
# File 'lib/javaclass/accessflag.rb', line 69

def accessor
  return "public"     if on? ACC_PUBLIC
  return ""
end

#source_modifiersObject

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

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



57
58
59
60
61
62
# File 'lib/javaclass/accessflag.rb', line 57

def source_modifiers
  modifiers = []
  modifiers << "final"      if on? ACC_FINAL
  modifiers << "abstract"   if on? ACC_ABSTRACT
  return modifiers
end

#to_sObject



86
87
88
89
# File 'lib/javaclass/accessflag.rb', line 86

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

#typeObject

クラスの種別(class or interface or enum ..) を文字列で取得する。

戻り値::クラスの種別



79
80
81
82
83
84
# File 'lib/javaclass/accessflag.rb', line 79

def type
  return "@interface" if on?(ACC_INTERFACE) && on?(ACC_ANNOTATION)
  return "interface"  if on? ACC_INTERFACE
  return "enum"       if on? ACC_ENUM
  return "class"
end