source: java/main/src/main/java/com/framsticks/util/lang/Delimeted.java @ 86

Last change on this file since 86 was 86, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • use java annotations to mark classes and fields to be used when:
    • using java classes with ReflectionAccess? to represent remote objects with FramsClass? description found by "info ..." requests
    • to build up FramsClass? representation of objects not present at remote server
  • allow using primitive types (instead of wraping counterparts) in reflected classes
  • rework FramsClass? creation process (add FramsClassBuilder?)
  • add more tests

CHANGELOG:
Prepare model.World class.

Minor change.

Use primitive types for Genotype and Creature classes.

Use primitive types in model.Neuro* classes.

Use primitive types in model.Joint* classes.

Use primitive types in model.Part* classes.

Fix primitive values.

Extract FramsClassBuilder?.

Add tests of Model classes.

More fixes.

Refactorize out ParamCandidate?.

Several fixes.

Fix all regressions after introducing annotations.

Use annotations throughout the project.

Add exception classes.

Improve creation of FramsClass?.

More changes.

Many changes regarding annotations.

Annotate classes in com.framsticks.model package.

Remove manual FramsClass? constructor.

Construct FramsClass? for Creature. Add test.

Add default values to the ParamAnnotation?.

Add ParamBuilderTest? and ParamAnnotation?.

Add FramsClassAnnotation?.

File size: 879 bytes
Line 
1package com.framsticks.util.lang;
2
3import java.util.Iterator;
4
5import org.apache.commons.collections.Closure;
6
7public class Delimeted implements Closure {
8
9        protected final String delimeter;
10        protected final String empty;
11        protected StringBuilder builder = null;
12
13        /**
14         * @param delimeter
15         */
16        public Delimeted(String delimeter, String empty) {
17                this.delimeter = delimeter;
18                this.empty = empty;
19        }
20
21        public final Delimeted append(Object object) {
22                if (builder != null) {
23                        builder.append(delimeter);
24                } else {
25                        builder = new StringBuilder();
26                }
27                builder.append(object);
28                return this;
29        }
30
31        public final Delimeted append(Iterator<?> i) {
32                while (i.hasNext()) {
33                        append(i.next());
34                }
35                return this;
36        }
37
38        public final String build() {
39                return (builder != null ? builder.toString() : empty);
40        }
41
42        @Override
43        public void execute(Object input) {
44                append(input);
45        }
46
47}
Note: See TracBrowser for help on using the repository browser.