kr.co.hit.live.resources.impl
Class CollectionResourcesBase

java.lang.Object
  extended by kr.co.hit.live.resources.impl.ResourcesBase
      extended by kr.co.hit.live.resources.impl.CollectionResourcesBase
All Implemented Interfaces:
Serializable, Resources
Direct Known Subclasses:
PropertyResources, XMLResources

public abstract class CollectionResourcesBase
extends ResourcesBase

Resources 구현을 위한 abstract base 클래스이다. Resources 구현은 공통된 base URL을 갖는 URL-accessible 리소스 파일에 각 Locale을 지원하기 위한 name-value 매핑을 저장한다. CollectionResourcesBase의 서브 클래스는 특정 로케일에 대한 name-value 매핑정보의 로딩을 관리하기 위해 getLocaleMap() 메소드 만을 오버라이드(override)한다.

timeZone 파라미터가 있는 경우에는 디폴트 컨텐트 조회 메소드에 의해 무시된다.

Since:
3.0
Version:
$Revision: 1.1 $ $Date: 2006/09/26 08:20:08 $
Author:
김광영
See Also:
Serialized Form

Field Summary
protected  Locale defaultLocale
           caller에 의해 Locale이 명시되지 않은 경우에 사용되는 디폴트 Locale
 
Fields inherited from class kr.co.hit.live.resources.impl.ResourcesBase
LIVE_RESOURCES_KEY_PREFIX
 
Fields inherited from interface kr.co.hit.live.resources.Resources
LAST_MODIFIED_KEY
 
Constructor Summary
CollectionResourcesBase(String name, String base)
           명시된 논리명과 base URL을 기반으로 새로운 Resources인스턴스를 생성한다.
 
Method Summary
 void destroy()
           해당 리소스가 더이상 필요하지 않은 경우, 리소스 관리자에 의해 호출된다.
 Iterator<Object> getKeys()
          (non-Javadoc)
protected  List<Locale> getLocaleList(Locale locale)
           특정 로케일에 대한 리소스의 위치를 파악할때 검색될 로케일의 List를 리턴한다.
protected  Map<Object,Object> getLocaleMap(Locale locale)
           특정 Locale에 대한 name-value 매핑을 분석하기 위해 사용되는 Map을 리턴한다.
protected abstract  Map<Object,Object> getLocaleMap(String baseUrl, Locale locale)
           특정 base URL과 로케일에 대한 name-value 매핑을 포함하는 Map을 리턴한다.
protected  String getLocaleSuffix(Locale locale)
           명시된 Locale에 대한 Locale-specific suffix를 리턴한다.
 Object getObject(String key, Locale locale, TimeZone timeZone)
           명시된 key에 해당하는 컨텐트를 특정 locale과/혹은 timeZone을 기반으로 로컬화하여 객체로 리턴한다.
 long lastModified()
           
 long lastModified(Locale locale)
          해당 리소스가 마지막에 수정된 시간을 반환한다.
 
Methods inherited from class kr.co.hit.live.resources.impl.ResourcesBase
getBase, getBytes, getInputStream, getName, getReader, getString, init, isReturnNull, setReturnNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultLocale

protected Locale defaultLocale

caller에 의해 Locale이 명시되지 않은 경우에 사용되는 디폴트 Locale

Constructor Detail

CollectionResourcesBase

public CollectionResourcesBase(String name,
                               String base)

명시된 논리명과 base URL을 기반으로 새로운 Resources인스턴스를 생성한다.

Parameters:
name - 새로운 인스턴스의 논리명
base - 해당 Resources 인스턴스에 대한 name-value 매핑을 포함하고 로케일과 1:1로 대응하는 리소스 파일의 base URL
Method Detail

getKeys

public Iterator<Object> getKeys()
(non-Javadoc)

Specified by:
getKeys in interface Resources
Specified by:
getKeys in class ResourcesBase
See Also:
ResourcesBase.getKeys()

getObject

public Object getObject(String key,
                        Locale locale,
                        TimeZone timeZone)

명시된 key에 해당하는 컨텐트를 특정 locale과/혹은 timeZone을 기반으로 로컬화하여 객체로 리턴한다.

Specified by:
getObject in interface Resources
Specified by:
getObject in class ResourcesBase
Parameters:
key - 요청한 컨텐트에 대한 식별자
locale - 조회된 내용을 로컬화하기 위한 로케일, 디폴트 로케일인 경우 null
timeZone - 조회된 내용을 로컬화하기 위한 타임존, 디폴트 타임존인 경우 null
Throws:
ResourcesException - 요청한 컨텐트를 조회하거나 리턴할때 에러가 발생하는 경우
ResourcesKeyException - 명시된 키에 대한 값이 없고,isReturnNull()false를 리턴하는 경우

lastModified

public long lastModified(Locale locale)
Description copied from interface: Resources
해당 리소스가 마지막에 수정된 시간을 반환한다.

Returns:

lastModified

public long lastModified()

destroy

public void destroy()
             throws ResourcesException

해당 리소스가 더이상 필요하지 않은 경우, 리소스 관리자에 의해 호출된다. 이 메소드가 호출된 이후에는 해당 리소스의 getXxx()메소드를 호출할 수 없다.

Specified by:
destroy in interface Resources
Overrides:
destroy in class ResourcesBase
Throws:
ResourcesException - finalization과정에서 에러가 발생한 경우

getLocaleList

protected List<Locale> getLocaleList(Locale locale)

특정 로케일에 대한 리소스의 위치를 파악할때 검색될 로케일의 List를 리턴한다. 리턴된 리스트는 명시된 로케일 자신부터 시작하여 variant, 나라, 혹은 언어 지정자가 생략된 로케일 순으로 구성된다. 예를 들어 en_US_POSIX 로케일을 전달하는 경우 리턴된 리스트는 다음과 같이 나라/언어/variant 의 조합에 대한 로케일 인스턴스를 포함할 것이다.

이 메소드에 의해 정해지는 검색 순서는 표준 자바 클래스인 java.util.ResourceBundle에서 사용하는 계층형 검색 전략과 유사하게 구현되어 Resources의 구현을 쉽게 한다.

Parameters:
locale - 리스트 산출에 기본이 되는 로케일

getLocaleMap

protected Map<Object,Object> getLocaleMap(Locale locale)

특정 Locale에 대한 name-value 매핑을 분석하기 위해 사용되는 Map을 리턴한다. 캐슁은 각 LocalegetLocaleMap(base,locale)이 한번 수행되도록 한다.

Parameters:
locale - name-value 매핑 맵을 리턴하기 위해 전달되는 로케일

getLocaleMap

protected abstract Map<Object,Object> getLocaleMap(String baseUrl,
                                                   Locale locale)

특정 base URL과 로케일에 대한 name-value 매핑을 포함하는 Map을 리턴한다. 만일 명시된 Locale에 해당하는 매핑이 존재하지 않는 경우, 빈(empty) Map을 리턴한다.

실질적인 서브클래스는 적절한 룩업(lookup)을 수행하기 위해 이 메소드를 오버라이드 해야 한다. 오버라이딩 된 메소드의 일반적인 구현은 명시된 base URL과 Locale 를 기반으로 하는 절대 URL을 생성할것이다. 또한 명시된 리소스 파일을 조회하여 Map 구조로 파싱할 것이다.

이전에 조회된 Map들에 대한 캐슁은 이 메소드의 caller에 의해 수행된다. 그렇기 때문에 이 메소드는 항상 특정 리소스를 조회하고 적절하게 로드하는 내용을 포함해야 한다.

Parameters:
baseUrl - Resources 인스턴스에 대한 리소스파일의 base URL
locale - name-value 매핑을 얻기 위한 Locale

getLocaleSuffix

protected String getLocaleSuffix(Locale locale)

명시된 Locale에 대한 Locale-specific suffix를 리턴한다. 만일 명시된 Locale에 언어와 나라에 대한 컴포넌트가 zero-length인 경우, 리턴되는 suffix도 zero length이다. 그렇지 않은 경우, suffix는 '_'뒤에 언어, 나라, 구분 속성 으로 구성된다. 각 요소는 '_'로 구분된다.

Parameters:
locale - suffix 문자열을 구하기위한 Locale


Copyright © 2014. All Rights Reserved.