Here's an actual example of the JEnable program in use. Let's say we start with a class which wraps a String and provides access to the characters of the String one at a time:

public class StringWrapper
{
    protected String m_text;
    protected int m_offset;

    public StringWrapper(String text) {
        m_text = text;
    }

    public int next() {
        if (++m_offset < m_text.length()) {
            return m_text.charAt(m_offset);
        } else {
            return -1;
        }
    }

    public int getOffset() {
        return m_offset;
    }

    public void setOffset(int offset) {
        m_offset = offset;
    }

    public int at(int offset) {
        if (offset < m_text.length()) {
            return m_text.charAt(offset);
        } else {
            return -1;
        }
    }

    public String substring(int start) {
        return m_text.substring(start, m_offset);
    }
}

This is fine as far as it goes, but we decide we really want to be able to build it in different flavors for different projects. In one case, we want to make the wrapper instances reusable with different Strings. In another case, we want to prevent the user from changing position within the String, limiting them to moving through it one character at a time, but figure we may as well let them reset to the start position in this case.

After making the code changes to support all this, and adding the configuration control information, we end up with:

public class StringWrapper
{
    protected String m_text;
    protected int m_offset;

//#REUSE{
    public StringWrapper() {}
//#}REUSE{
    public StringWrapper(String text) {
        m_text = text;
    }
//#REUSE}

//#REUSE{
    public void setText(String text) {
        m_text = text;
        m_offset = 0;
    }
//#REUSE}

    public int next() {
        if (++m_offset < m_text.length()) {
            return m_text.charAt(m_offset);
        } else {
            return -1;
        }
    }

//#!LIMIT{
    public int getOffset() {
        return m_offset;
    }

    public void setOffset(int offset) {
        m_offset = offset;
    }

    public int at(int offset) {
        if (offset < m_text.length()) {
            return m_text.charAt(offset);
        } else {
            return -1;
        }
    }

    public String substring(int start) {
        return m_text.substring(start, m_offset);
    }
//#}LIMIT{
    public void reset() {
        m_offset = 0;
    }
//#LIMIT}
}

At this point none of the optional code blocks have been disabled, since JEnable hasn't been run on the source code. If we now execute JEnable with the line:

java JEnable -d REUSE StringWrapper.java
our source code becomes:
public class StringWrapper
{
    protected String m_text;
    protected int m_offset;

//#REUSE{
//#REUSE:    public StringWrapper() {}
//#}REUSE{
    public StringWrapper(String text) {
        m_text = text;
    }
//#REUSE}

//#REUSE{
//#REUSE:    public void setText(String text) {
//#REUSE:        m_text = text;
//#REUSE:        m_offset = 0;
//#REUSE:    }
//#REUSE}

    public int next() {
        if (++m_offset < m_text.length()) {
            return m_text.charAt(m_offset);
        } else {
            return -1;
        }
    }

//#!LIMIT{
    public int getOffset() {
        return m_offset;
    }

    public void setOffset(int offset) {
        m_offset = offset;
    }

    public int at(int offset) {
        if (offset < m_text.length()) {
            return m_text.charAt(offset);
        } else {
            return -1;
        }
    }

    public String substring(int start) {
        return m_text.substring(start, m_offset);
    }
//#}LIMIT{
    public void reset() {
        m_offset = 0;
    }
//#LIMIT}
}

Only the code within the REUSE token conditional block has been modified, since only this is the only token which was specified as either enabled or disabled.

If we now change our mind and want to build the reusable form of the class with limited user access, we run JEnable again with the line:

java JEnable -e REUSE,LIMIT StringWrapper.java

Now our source code becomes:

public class StringWrapper
{
    protected String m_text;
    protected int m_offset;

//#REUSE{
    public StringWrapper() {}
//#}REUSE{
//#REUSE:    public StringWrapper(String text) {
//#REUSE:        m_text = text;
//#REUSE:    }
//#REUSE}

//#REUSE{
    public void setText(String text) {
        m_text = text;
        m_offset = 0;
    }
//#REUSE}

    public int next() {
        if (++m_offset < m_text.length()) {
            return m_text.charAt(m_offset);
        } else {
            return -1;
        }
    }

//#!LIMIT{
//#LIMIT:    public int getOffset() {
//#LIMIT:        return m_offset;
//#LIMIT:    }
//#LIMIT:
//#LIMIT:    public void setOffset(int offset) {
//#LIMIT:        m_offset = offset;
//#LIMIT:    }
//#LIMIT:
//#LIMIT:    public int at(int offset) {
//#LIMIT:        if (offset < m_text.length()) {
//#LIMIT:            return m_text.charAt(offset);
//#LIMIT:        } else {
//#LIMIT:            return -1;
//#LIMIT:        }
//#LIMIT:    }
//#LIMIT:
//#LIMIT:    public String substring(int start) {
//#LIMIT:        return m_text.substring(start, m_offset);
//#LIMIT:    }
//#}LIMIT{
    public void reset() {
        m_offset = 0;
    }
//#LIMIT}
}

Since we gave settings for both tokens this time, both blocks of code were modified. The LIMIT optional code block uses a '!' before the token, so the code which follows is commented out. The else marker line "//#}LIMIT{" reverses the prior state and allows the code which follows that marker to be active.

If you've downloaded the code this sample file is included, so you can experiment with it for yourself.