Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Riena/Core"

(New page: == Logging with Log4j == See package '''<code>org.eclipse.riena.core.logging</code>'''. == Accessing files on disk with RienaLocations == The class '''<code>org.eclipse.riena.core.RienaLo...)
 
(Util classes)
Line 14: Line 14:
 
All in package '''<code>org.eclipse.riena.core.util</code>'''. See the source files for a complete list of methods and the inline Javadoc for more information.
 
All in package '''<code>org.eclipse.riena.core.util</code>'''. See the source files for a complete list of methods and the inline Javadoc for more information.
  
=== PropertiesUtils ===
+
=== ArraysUtil ===
Helps with converting string representation of maps and lists to their Java counterparts.
+
Helper for arrays.
 +
; <code>public static <T> T[] copyRange(T[] source, int from, int to)</code>
 +
: Copy from the given source array from index from to index to into a newly-created array of the same type with size to - from.
  
 
=== IOUtils ===
 
=== IOUtils ===
Line 22: Line 24:
 
; <code>public static void copyFile(File from, File to) throws IOException</code>
 
; <code>public static void copyFile(File from, File to) throws IOException</code>
  
=== ArraysUtil ===
+
=== Iter ===
Helper for arrays.
+
This helper provides conversions from classes only implementing <code>Iterator</code> or <code>Enumeration</code> such that they can be used within the extended for()-loop (foreach).
; <code>public static <T> T[] copyRange(T[] source, int from, int to)</code>
+
All the <code>able()</code> methods can be used with a <code>null</code> parameter. So, explicitly checking for <code>null</code> is not necessary!
: Copy from the given source array from index from to index to into a newly-created array of the same type with size to - from.
+
''Note:'' All these methods induce a small performance penalty.
 +
<source lang="java">
 +
String[] strings = null;
 +
for (String s : Iter.able(strings)) {
 +
...
 +
}
 +
</source>
 +
<source lang="java">
 +
StringTokenizer st = new StringTokenizer("this is a test");
 +
for (String str : Iter.able(st, String.class)) {
 +
...
 +
}
 +
</source>
 +
 
 +
=== Nop ===
 +
Use this to explicitly document do-nothing behavior, e.g. in empty try-catch clauses:
 +
<source lang="java">
 +
Nop.reason("do nothing, can happen if some other bundle registered this service");
 +
</source>
 +
 
 +
=== PropertiesUtils ===
 +
Helps with converting string representation of maps and lists to their Java counterparts.
  
 
=== StringUtils ===
 
=== StringUtils ===
Line 36: Line 59:
 
; <code>public static boolean equals(final CharSequence sequence1, final CharSequence sequence2)</code>
 
; <code>public static boolean equals(final CharSequence sequence1, final CharSequence sequence2)</code>
 
: null-safe equals
 
: null-safe equals
 
=== Nop ===
 
Use this to explicitly document do-nothing behavior, e.g. in empty try-catch clauses:
 
<source lang="java">
 
Nop.reason("do nothing, can happen if some other bundle registered this service");
 
</source>
 

Revision as of 22:27, 2 March 2010

Logging with Log4j

See package org.eclipse.riena.core.logging.

Accessing files on disk with RienaLocations

The class org.eclipse.riena.core.RienaLocations with static methods getDataArea() and getDataArea(Bundle) should be the single place that manages and knows about where to read/write files on disk.

Always use RienaLocations when you need to read or write application-specific data (e.g. user settings or custom caches) to/from disk.

Caching

See package org.eclipse.riena.core.cache.

Util classes

All in package org.eclipse.riena.core.util. See the source files for a complete list of methods and the inline Javadoc for more information.

ArraysUtil

Helper for arrays.

public static <T> T[] copyRange(T[] source, int from, int to)
Copy from the given source array from index from to index to into a newly-created array of the same type with size to - from.

IOUtils

Helper for I/O operations, e.g.

public static void copyFile(File from, File to) throws IOException

Iter

This helper provides conversions from classes only implementing Iterator or Enumeration such that they can be used within the extended for()-loop (foreach). All the able() methods can be used with a null parameter. So, explicitly checking for null is not necessary! Note: All these methods induce a small performance penalty.

String[] strings = null;
for (String s : Iter.able(strings)) {
	...
}
StringTokenizer st = new StringTokenizer("this is a test");
for (String str : Iter.able(st, String.class)) {
	...
}

Nop

Use this to explicitly document do-nothing behavior, e.g. in empty try-catch clauses:

Nop.reason("do nothing, can happen if some other bundle registered this service");

PropertiesUtils

Helps with converting string representation of maps and lists to their Java counterparts.

StringUtils

Offers static convenience methods like:

public static boolean isGiven(final CharSequence sequence)
the counterpart to isEmpty(...)
public static boolean isEmpty(final CharSequence sequence)
public static boolean isDeepEmpty(final String string)
like isEmpty, with the difference that whitespace-only strings are considered empty.
public static boolean equals(final CharSequence sequence1, final CharSequence sequence2)
null-safe equals

Back to the top