gluu
公開メンバ関数 | 静的公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.model.uma.JsonLogic クラス
org.xdi.oxauth.model.uma.JsonLogic 連携図
Collaboration graph

公開メンバ関数

ScriptEngine getEngine ()
 
Invocable getInvocable ()
 

静的公開メンバ関数

static JsonLogic getInstance ()
 
static Object eval (String script) throws ScriptException
 
static Object invokeFunction (String name, Object... args) throws ScriptException, NoSuchMethodException
 
static boolean apply (String rule) throws ScriptException
 
static boolean apply (String rule, String data) throws ScriptException
 
static Object applyObject (String rule) throws ScriptException
 
static Object applyObject (String rule, String data) throws ScriptException
 

非公開メンバ関数

 JsonLogic ()
 
void loadJsonLogicJs ()
 
void loadScript (String scriptName)
 

非公開変数類

final ScriptEngine engine
 

静的非公開変数類

static final Logger LOG = LoggerFactory.getLogger(JsonLogic.class)
 
static final JsonLogic INSTANCE = new JsonLogic()
 

詳解

著者
yuriyz

構築子と解体子

◆ JsonLogic()

org.xdi.oxauth.model.uma.JsonLogic.JsonLogic ( )
inlineprivate
26  {
27  ScriptEngineManager factory = new ScriptEngineManager();
28  engine = factory.getEngineByName("nashorn");
29 
30  Preconditions.checkNotNull(engine);
31 
32  loadScript("json_logic.js");
33  }
final ScriptEngine engine
Definition: JsonLogic.java:24
void loadScript(String scriptName)
Definition: JsonLogic.java:39

関数詳解

◆ apply() [1/2]

static boolean org.xdi.oxauth.model.uma.JsonLogic.apply ( String  rule) throws ScriptException
inlinestatic
76  {
77  return applyObject(rule).equals(Boolean.TRUE);
78  }
static Object applyObject(String rule)
Definition: JsonLogic.java:84

◆ apply() [2/2]

static boolean org.xdi.oxauth.model.uma.JsonLogic.apply ( String  rule,
String  data 
) throws ScriptException
inlinestatic
80  {
81  return applyObject(rule, data).equals(Boolean.TRUE);
82  }
static Object applyObject(String rule)
Definition: JsonLogic.java:84

◆ applyObject() [1/2]

static Object org.xdi.oxauth.model.uma.JsonLogic.applyObject ( String  rule) throws ScriptException
inlinestatic
84  {
85  return eval("jsonLogic.apply( " + rule + " );");
86  }
static Object eval(String script)
Definition: JsonLogic.java:68

◆ applyObject() [2/2]

static Object org.xdi.oxauth.model.uma.JsonLogic.applyObject ( String  rule,
String  data 
) throws ScriptException
inlinestatic
88  {
89  return eval("jsonLogic.apply( " + rule + ", " + data + " );");
90  }
static Object eval(String script)
Definition: JsonLogic.java:68

◆ eval()

static Object org.xdi.oxauth.model.uma.JsonLogic.eval ( String  script) throws ScriptException
inlinestatic
68  {
69  return getInstance().getEngine().eval(script);
70  }
static JsonLogic getInstance()
Definition: JsonLogic.java:56
ScriptEngine getEngine()
Definition: JsonLogic.java:60

◆ getEngine()

ScriptEngine org.xdi.oxauth.model.uma.JsonLogic.getEngine ( )
inline
60  {
61  return engine;
62  }
final ScriptEngine engine
Definition: JsonLogic.java:24

◆ getInstance()

static JsonLogic org.xdi.oxauth.model.uma.JsonLogic.getInstance ( )
inlinestatic
56  {
57  return INSTANCE;
58  }
static final JsonLogic INSTANCE
Definition: JsonLogic.java:22

◆ getInvocable()

Invocable org.xdi.oxauth.model.uma.JsonLogic.getInvocable ( )
inline
64  {
65  return (Invocable) engine;
66  }
final ScriptEngine engine
Definition: JsonLogic.java:24

◆ invokeFunction()

static Object org.xdi.oxauth.model.uma.JsonLogic.invokeFunction ( String  name,
Object...  args 
) throws ScriptException, NoSuchMethodException
inlinestatic
72  {
73  return getInstance().getInvocable().invokeFunction(name, args);
74  }
static JsonLogic getInstance()
Definition: JsonLogic.java:56
Invocable getInvocable()
Definition: JsonLogic.java:64

◆ loadJsonLogicJs()

void org.xdi.oxauth.model.uma.JsonLogic.loadJsonLogicJs ( )
inlineprivate
35  {
36  loadScript("json_logic.js");
37  }
void loadScript(String scriptName)
Definition: JsonLogic.java:39

◆ loadScript()

void org.xdi.oxauth.model.uma.JsonLogic.loadScript ( String  scriptName)
inlineprivate
39  {
40  Preconditions.checkState(StringUtils.isNotBlank(scriptName));
41 
42  InputStream stream = getClass().getClassLoader().getResourceAsStream(scriptName);
43  Preconditions.checkNotNull(stream);
44 
45  try {
46  String script = IOUtils.toString(stream);
47  engine.eval(script);
48  LOG.trace("Loaded script, name: " + scriptName);
49  } catch (Exception e) {
50  LOG.error("Failed to load JavaScript script, name: " + scriptName, e);
51  } finally {
52  IOUtils.closeQuietly(stream);
53  }
54  }
final ScriptEngine engine
Definition: JsonLogic.java:24
static final Logger LOG
Definition: JsonLogic.java:20

メンバ詳解

◆ engine

final ScriptEngine org.xdi.oxauth.model.uma.JsonLogic.engine
private

◆ INSTANCE

final JsonLogic org.xdi.oxauth.model.uma.JsonLogic.INSTANCE = new JsonLogic()
staticprivate

◆ LOG

final Logger org.xdi.oxauth.model.uma.JsonLogic.LOG = LoggerFactory.getLogger(JsonLogic.class)
staticprivate

このクラス詳解は次のファイルから抽出されました: