Package org.opencms.i18n
Class CmsLocaleGroup
- java.lang.Object
-
- org.opencms.i18n.CmsLocaleGroup
-
public class CmsLocaleGroup extends java.lang.Object
Represents a group of resources which are locale variants of each other.
-
-
Constructor Summary
Constructors Constructor Description CmsLocaleGroup(CmsObject cms, CmsResource primaryResource, java.util.List<CmsResource> secondaryResources)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<CmsResource>
getAllResources()
Gets the list of all resources of this group (primary and secondary).java.util.Locale
getMainLocale()
Gets the main locale (i.e.CmsResource
getPrimaryResource()
Gets the primary resource.java.util.Map<java.util.Locale,CmsResource>
getResourcesByLocale()
Gets a map which contains the resources of the locale group as keys, indexed by their locale.java.util.Collection<CmsResource>
getResourcesForLocale(java.util.Locale locale)
Gets the resources of this group which have the given locale.java.util.Set<CmsResource>
getSecondaryResources()
Gets the secondary resources of this group.boolean
hasLocale(java.util.Locale locale)
Checks if this group has a resource with the given locale.boolean
isMarkedNoTranslation(java.util.Locale locale)
Checks if the locale group is marked as not translatable for the given locale.boolean
isMarkedNoTranslation(java.util.Set<java.util.Locale> locales)
Checks if the locale group is marked as not translatable for any of the given locales.boolean
isPotentialGroupHead()
Returns true if this is a potential group head, i.e.boolean
isRealGroup()
Checks if this group is a real group, i.e.boolean
isRealGroupOrPotentialGroupHead()
Checks if this is either a real group or a potential group head (i.e.
-
-
-
Constructor Detail
-
CmsLocaleGroup
public CmsLocaleGroup(CmsObject cms, CmsResource primaryResource, java.util.List<CmsResource> secondaryResources)
Creates a new instance.- Parameters:
cms
- the CMS context to useprimaryResource
- the primary resourcesecondaryResources
- the secondary resources
-
-
Method Detail
-
getAllResources
public java.util.List<CmsResource> getAllResources()
Gets the list of all resources of this group (primary and secondary).- Returns:
- the list of all resources of this group
-
getMainLocale
public java.util.Locale getMainLocale()
Gets the main locale (i.e. the locale of the primary resource of this group).- Returns:
- the main locale
-
getPrimaryResource
public CmsResource getPrimaryResource()
Gets the primary resource.- Returns:
- the primary resource
-
getResourcesByLocale
public java.util.Map<java.util.Locale,CmsResource> getResourcesByLocale()
Gets a map which contains the resources of the locale group as keys, indexed by their locale.If the locale group contains more than one resource from the same locale,, which one is used a map value is undefined.
- Returns:
- the map of resources by locale
-
getResourcesForLocale
public java.util.Collection<CmsResource> getResourcesForLocale(java.util.Locale locale)
Gets the resources of this group which have the given locale.- Parameters:
locale
- a locale- Returns:
- the collection of resources with the given locale
-
getSecondaryResources
public java.util.Set<CmsResource> getSecondaryResources()
Gets the secondary resources of this group.- Returns:
- the collection of secondary resources
-
hasLocale
public boolean hasLocale(java.util.Locale locale)
Checks if this group has a resource with the given locale.- Parameters:
locale
- the locale- Returns:
- true if the group has a resource with the locale
-
isMarkedNoTranslation
public boolean isMarkedNoTranslation(java.util.Locale locale)
Checks if the locale group is marked as not translatable for the given locale.- Parameters:
locale
- a locale- Returns:
- true if the locale group is marked as not translatable for the given locale
-
isMarkedNoTranslation
public boolean isMarkedNoTranslation(java.util.Set<java.util.Locale> locales)
Checks if the locale group is marked as not translatable for any of the given locales.- Parameters:
locales
- a set of locales- Returns:
- true if the locale group is marked as not translatable for any of the given resources
-
isPotentialGroupHead
public boolean isPotentialGroupHead()
Returns true if this is a potential group head, i.e. the locale of the primary resource is the main translation locale configured for the site in which it is located.- Returns:
- true if this is a potential group head
-
isRealGroup
public boolean isRealGroup()
Checks if this group is a real group, i.e. consists of more than one resource.- Returns:
- true if this is a real group
-
isRealGroupOrPotentialGroupHead
public boolean isRealGroupOrPotentialGroupHead()
Checks if this is either a real group or a potential group head (i.e. a potential primary resource).- Returns:
- true if this is a real group or a potential group head
-
-