SimpleScriptContext
SimpleScriptContext (단순 스크립트 컨텍스트)
ScriptContext의 간단한 구현 클래스입니다. 스크립트 엔진이 실행되는 문맥, 즉 속성과 입출력 스트림을 다룹니다.
본문
이 클래스는 엔진 범위(engineScope)와 전역 범위(globalScope)라는 두 개의 Bindings를 보호된 필드로 가지고 있고, 작성자(writer), 오류 작성자(errorWriter), 읽기자(reader) 스트림도 함께 보관합니다.
속성 관련 메서드는 getAttribute, setAttribute, removeAttribute, getAttributesScope 등으로 특정 범위에서 이름에 해당하는 값을 다룹니다. 스트림은 getWriter와 setWriter, getReader와 setReader, getErrorWriter와 setErrorWriter로 설정하고 얻어요.
protected Writer writer
protected Writer errorWriter
protected Reader reader
protected Bindings engineScope
protected Bindings globalScope
public SimpleScriptContext()
public void setBindings(Bindings bindings, int scope)
public Object getAttribute(String name)
public Object getAttribute(String name, int scope)
public Object removeAttribute(String name, int scope)
public void setAttribute(String name, Object value, int scope)
public Writer getWriter()
public Reader getReader()
public void setReader(Reader reader)
public void setWriter(Writer writer)
public Writer getErrorWriter()
public void setErrorWriter(Writer writer)
public int getAttributesScope(String name)
public Bindings getBindings(int scope)
public List<Integer> getScopes()
getScopes()는 이 컨텍스트가 지원하는 범위 목록, 즉 엔진 범위와 전역 범위를 담은 리스트를 돌려줍니다.