BrightSide Workbench Full Report + Source Code
org.turro.marker.ElephantMarker Class Reference
Inheritance diagram for org.turro.marker.ElephantMarker:
Collaboration diagram for org.turro.marker.ElephantMarker:

Public Member Functions

 ElephantMarker ()
 
 ElephantMarker (IConstructor constructor)
 
 ElephantMarker (IConstructor constructor, boolean mail)
 
IConstructor getConstructor ()
 
Map getRoot ()
 
String parse (String rootTmpl, String tmpl)
 
void process (String rootTmpl, String tmpl)
 
void process (String rootTmpl, String tmpl, Writer out)
 
Object get (Object key)
 
Object put (Object key, Object value)
 
Object remove (Object key)
 
boolean contains (Object key)
 
void putAll (Map m)
 
String getTemplateString (String root, String template)
 
String getSiteTemplateString (String root, String template)
 

Static Public Member Functions

static boolean existsTemplate (IConstructor constructor, boolean mail, String root, String name)
 
static boolean existsTemplate (IConstructor constructor, boolean mail, String root, String name, boolean overriden)
 
static File fileTemplate (IConstructor constructor, boolean mail, String root, String name)
 
static File fileTemplate (IConstructor constructor, boolean mail, String root, String name, boolean overriden)
 
static String templateRoot (IConstructor constructor, boolean mail)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 49 of file ElephantMarker.java.

Constructor & Destructor Documentation

◆ ElephantMarker() [1/3]

org.turro.marker.ElephantMarker.ElephantMarker ( )

Definition at line 56 of file ElephantMarker.java.

56  {
57  this(ElephantContext.createConstructor());
58  }
Here is the call graph for this function:

◆ ElephantMarker() [2/3]

org.turro.marker.ElephantMarker.ElephantMarker ( IConstructor  constructor)

Definition at line 60 of file ElephantMarker.java.

60  {
61  this(constructor, false);
62  }

◆ ElephantMarker() [3/3]

org.turro.marker.ElephantMarker.ElephantMarker ( IConstructor  constructor,
boolean  mail 
)

Definition at line 64 of file ElephantMarker.java.

64  {
65  this.constructor = constructor;
66  try {
67  setDirectoryForTemplateLoading(new File(templateRoot(constructor, mail)));
68  DefaultObjectWrapperBuilder dowb = new DefaultObjectWrapperBuilder(VERSION_2_3_30);
69  dowb.setForceLegacyNonListCollections(false);
70  setObjectWrapper(dowb.build());
71  setLocale(I_.api().used());
72  setDefaultEncoding(ElephantContext.getEncoding());
73  setOutputEncoding(ElephantContext.getEncoding());
74  setDateFormat("short");
75  setDateTimeFormat("short_short");
76  setEncoding(I_.api().used(), ElephantContext.getEncoding());
77  setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
78  setURLEscapingCharset("UTF-8");
79  setAPIBuiltinEnabled(true);
80  root.put("constructor", constructor);
81  root.put("history", History.getInstance(constructor));
82  root.put("repository", IConstructor.currentRepository(constructor));
83  root.put("grepository", IConstructor.globalRepository());
84  root.put("serverURL", ElephantContext.getServerUrl("http"));
85  root.put("rootWebPath", ElephantContext.getRootWebPath());
86  root.put("siteName", ElephantContext.getSiteName());
87  root.put("labels", I_.compatibilityMap());
88  root.put("i_", I_.api());
89  root.put("i", I_.map());
90  root.put("k", I_.byKeyMap());
91  root.put("infoLink", EntityInfoContent.createURL(EntityInfoType.FULL, LinkType.WEB));
92  root.put("logoutURL", DirectContents.createRelativeURL("authentication") + "/logout");
93  root.put("helper", new MarkerHelper(constructor));
94  ContactIdentity identity = new ContactIdentity();
95  root.put("identity", identity);
96  root.put("rolemap", identity.getPermissionMap());
97  root.put("cookies", new Cookies(constructor.getRequest(), constructor.getResponse()));
98  if(getLocale() != null) {
99  root.put("lang", getLocale().getLanguage());
100  }
101  ElephantHelpers.addToMap(root);
102  } catch (IOException ex) {
103  Logger.getLogger(ElephantMarker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
104  }
105  }
static String templateRoot(IConstructor constructor, boolean mail)
Here is the call graph for this function:

Member Function Documentation

◆ contains()

boolean org.turro.marker.ElephantMarker.contains ( Object  key)

Definition at line 157 of file ElephantMarker.java.

157  {
158  return root.containsKey(key);
159  }
Here is the caller graph for this function:

◆ existsTemplate() [1/2]

static boolean org.turro.marker.ElephantMarker.existsTemplate ( IConstructor  constructor,
boolean  mail,
String  root,
String  name 
)
static

Definition at line 183 of file ElephantMarker.java.

183  {
184  return existsTemplate(constructor, mail, root, name, false);
185  }
static boolean existsTemplate(IConstructor constructor, boolean mail, String root, String name)
Here is the caller graph for this function:

◆ existsTemplate() [2/2]

static boolean org.turro.marker.ElephantMarker.existsTemplate ( IConstructor  constructor,
boolean  mail,
String  root,
String  name,
boolean  overriden 
)
static

Definition at line 187 of file ElephantMarker.java.

187  {
188  return fileTemplate(constructor, mail, root, name, overriden).exists();
189  }
static File fileTemplate(IConstructor constructor, boolean mail, String root, String name)
Here is the call graph for this function:

◆ fileTemplate() [1/2]

static File org.turro.marker.ElephantMarker.fileTemplate ( IConstructor  constructor,
boolean  mail,
String  root,
String  name 
)
static

Definition at line 191 of file ElephantMarker.java.

191  {
192  return fileTemplate(constructor, mail, root, name, false);
193  }
Here is the caller graph for this function:

◆ fileTemplate() [2/2]

static File org.turro.marker.ElephantMarker.fileTemplate ( IConstructor  constructor,
boolean  mail,
String  root,
String  name,
boolean  overriden 
)
static

Definition at line 195 of file ElephantMarker.java.

195  {
196  StringBuilder sb = new StringBuilder(templateRoot(constructor, mail));
197  sb.append("/").append(root).append("/");
198  if(overriden) sb.append("site").append("/");
199  sb.append(name).append("Template.html");
200  return new File(sb.toString());
201  }
Here is the call graph for this function:

◆ get()

Object org.turro.marker.ElephantMarker.get ( Object  key)

Definition at line 145 of file ElephantMarker.java.

145  {
146  return root.get(key);
147  }
Here is the caller graph for this function:

◆ getConstructor()

IConstructor org.turro.marker.ElephantMarker.getConstructor ( )

Definition at line 107 of file ElephantMarker.java.

107  {
108  return constructor;
109  }
Here is the caller graph for this function:

◆ getRoot()

Map org.turro.marker.ElephantMarker.getRoot ( )

Definition at line 111 of file ElephantMarker.java.

111  {
112  return root;
113  }

◆ getSiteTemplateString()

String org.turro.marker.ElephantMarker.getSiteTemplateString ( String  root,
String  template 
)

Definition at line 174 of file ElephantMarker.java.

174  {
175  if(!Strings.isBlank(template)) {
176  if(!template.contains("/")) {
177  template = "/" + root + "/site/" + template + "Template.html";
178  }
179  }
180  return template;
181  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTemplateString()

String org.turro.marker.ElephantMarker.getTemplateString ( String  root,
String  template 
)

Definition at line 165 of file ElephantMarker.java.

165  {
166  if(!Strings.isBlank(template)) {
167  if(!template.contains("/")) {
168  template = "/" + root + "/" + template + "Template.html";
169  }
170  }
171  return template;
172  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse()

String org.turro.marker.ElephantMarker.parse ( String  rootTmpl,
String  tmpl 
)

Definition at line 115 of file ElephantMarker.java.

115  {
116  StringWriter sw = new StringWriter();
117  process(rootTmpl, tmpl, sw);
118  return sw.toString();
119  }
void process(String rootTmpl, String tmpl)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process() [1/2]

void org.turro.marker.ElephantMarker.process ( String  rootTmpl,
String  tmpl 
)

Definition at line 121 of file ElephantMarker.java.

121  {
122  try {
123  process(rootTmpl, tmpl, constructor.getOut());
124  } catch (IOException ex) {
125  Logger.getLogger(ElephantMarker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
126  }
127  }
Here is the call graph for this function:

◆ process() [2/2]

void org.turro.marker.ElephantMarker.process ( String  rootTmpl,
String  tmpl,
Writer  out 
)

Definition at line 129 of file ElephantMarker.java.

129  {
130  try {
131  Template template = null;
132  try {
133  template = getTemplate(getSiteTemplateString(rootTmpl, tmpl));
134  } catch(FileNotFoundException ex) {
135  template = getTemplate(getTemplateString(rootTmpl, tmpl));
136  }
137  template.process(root, out);
138  } catch (IOException | TemplateException ex) {
139  //MailError.getInstance(ElephantMarker.class, ex, tmpl)
140  // .sendEmail(Application.getApplication());
141  Logger.getLogger(ElephantMarker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
142  }
143  }
String getSiteTemplateString(String root, String template)
String getTemplateString(String root, String template)
Here is the call graph for this function:

◆ put()

Object org.turro.marker.ElephantMarker.put ( Object  key,
Object  value 
)

Definition at line 149 of file ElephantMarker.java.

149  {
150  return root.put(key, value);
151  }

◆ putAll()

void org.turro.marker.ElephantMarker.putAll ( Map  m)

Definition at line 161 of file ElephantMarker.java.

161  {
162  root.putAll(m);
163  }
Here is the caller graph for this function:

◆ remove()

Object org.turro.marker.ElephantMarker.remove ( Object  key)

Definition at line 153 of file ElephantMarker.java.

153  {
154  return root.remove(key);
155  }

◆ templateRoot()

static String org.turro.marker.ElephantMarker.templateRoot ( IConstructor  constructor,
boolean  mail 
)
static

Definition at line 203 of file ElephantMarker.java.

203  {
204  if(mail) {
205  return ElephantContext.getRealPath(TEMPLATE_DIR + "templates-mail");
206  } else if(constructor != null) {
207  return ElephantContext.getRealPath(TEMPLATE_DIR + constructor.getTemplateRoot());
208  } else {
209  return ElephantContext.getRealPath(TEMPLATE_DIR + ElephantContext.getTemplatesRoot());
210  }
211  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: