|
From: <cr...@us...> - 2008-07-21 13:28:51
|
Revision: 4332
http://jnode.svn.sourceforge.net/jnode/?rev=4332&view=rev
Author: crawley
Date: 2008-07-21 13:28:44 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
Added support for 'modifiers' in @...@ sequences; see web docs.
Modified Paths:
--------------
trunk/all/conf-source/jnode.properties.defaults
trunk/all/conf-source/jnode.properties.template
trunk/all/conf-source/script.xml
trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java
trunk/distr/src/configure/org/jnode/configure/adapter/DummyValueCodec.java
trunk/distr/src/configure/org/jnode/configure/adapter/JavaStringLiteralCodec.java
trunk/distr/src/configure/org/jnode/configure/adapter/PropertyValueCodec.java
trunk/distr/src/configure/org/jnode/configure/adapter/XMLValueCodec.java
Modified: trunk/all/conf-source/jnode.properties.defaults
===================================================================
--- trunk/all/conf-source/jnode.properties.defaults 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/all/conf-source/jnode.properties.defaults 2008-07-21 13:28:44 UTC (rev 4332)
@@ -20,5 +20,7 @@
jnode.debugger.host=
jnode.debugger.port=6789
+jnode.virtual.memsize=512
+
#vmware.vmx.overrides=<some-file-containing-vmx-settings>
Modified: trunk/all/conf-source/jnode.properties.template
===================================================================
--- trunk/all/conf-source/jnode.properties.template 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/all/conf-source/jnode.properties.template 2008-07-21 13:28:44 UTC (rev 4332)
@@ -10,20 +10,20 @@
# if you have custom initjars to build.
# custom.plugin-list.dir = ${root.dir}/local/plugin-lists/
-# In non-empty, no default initjars will be built.
-no....@no...@
+# If non-empty, no default initjars will be built.
+@no.default.initjars=#!@
# -----------------------------------------------
# Settings for the bootdisk image
# If non-empty, no bootdisk image will be built.
-no....@no...@
+@no.bootdisk=#!@
# -----------------------------------------------
# Settings for the netboot build
# If non-empty, no netboot directory will be built.
-no....@no...@
+@no.netboot=#!@
# -----------------------------------------------
# Settings for the memory manager
@@ -31,7 +31,7 @@
# Default memory manager: org.jnode.vm.memmgr.def
# MMTk NoGC based memory manager (still very beta): org.jnode.vm.memmgr.mmtk.nogc
# MMTk GenRC based memory manager (still very alpha): org.jnode.vm.memmgr.mmtk.genrc
-jno...@jn...@
+@jnode.memmgr.plugin.id=@
# -----------------------------------------------
# Settings for the document-plugins task
@@ -74,6 +74,10 @@
# Settings for a VMware virtual machine
# -----------------------------------------------
+# -----------------------------------------------
+# The virtual PC's memory size in Mbytes
+@jnode.virtual.memsize=@
+
# Uncomment and edit this line if you want to override the settings
# in the 'jnode-x86-*.vmx' file. For example, you may want to include
# settings to configure a VMware virtual hard drive, or real hard drive.
Modified: trunk/all/conf-source/script.xml
===================================================================
--- trunk/all/conf-source/script.xml 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/all/conf-source/script.xml 2008-07-21 13:28:44 UTC (rev 4332)
@@ -32,8 +32,7 @@
<propFile name="../../test.jnode.properties" defaultFile="jnode.properties.defaults"
templateFile="jnode.properties.template">
<property name="jnode.virtual.memsize" type="integer.type"
- description="Enter virtual hardware memory size in Mbytes"
- default="512"/>
+ description="Enter virtual hardware memory size in Mbytes"/>
<property name="jnode.virtual.disk" type="vdisk.type"
description="Select a prebuilt virtual disk"
default="none"/>
Modified: trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java
===================================================================
--- trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java 2008-07-21 13:28:44 UTC (rev 4332)
@@ -51,9 +51,10 @@
public abstract class BasePropertyFileAdapter implements FileAdapter {
interface ValueCodec {
- public String encodeText(String raw) throws ConfigureException;
+ public String getValidModifiers();
- public String decodeText(String encoded) throws ConfigureException;
+ public String encodeProperty(String propName, String propValue, String modifiers)
+ throws ConfigureException;
}
private final ValueCodec codec;
@@ -218,15 +219,10 @@
if (sb.length() == 0) {
w.write(marker);
} else {
+ String modifiers = removeModifiers(sb);
String propName = sb.toString();
String propValue = props.getProperty(propName);
- if (propValue == null) {
- w.write(marker);
- w.write(propName);
- w.write(marker);
- } else {
- w.write(codec.encodeText(propValue));
- }
+ w.write(codec.encodeProperty(propName, propValue, modifiers));
}
} else {
// FIXME ... make this aware of the host OS newline
@@ -241,4 +237,19 @@
w.flush();
}
}
+
+ private String removeModifiers(StringBuffer sb) {
+ String validModifiers = codec.getValidModifiers();
+ StringBuffer sb2 = new StringBuffer(1);
+ for (int i = sb.length() - 1; i >= 0; i--) {
+ char ch = sb.charAt(i);
+ if (validModifiers.contains(Character.toString(ch))) {
+ sb2.insert(0, ch);
+ sb.setLength(i);
+ } else {
+ break;
+ }
+ }
+ return sb2.toString();
+ }
}
Modified: trunk/distr/src/configure/org/jnode/configure/adapter/DummyValueCodec.java
===================================================================
--- trunk/distr/src/configure/org/jnode/configure/adapter/DummyValueCodec.java 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/distr/src/configure/org/jnode/configure/adapter/DummyValueCodec.java 2008-07-21 13:28:44 UTC (rev 4332)
@@ -28,13 +28,12 @@
* @author cr...@jn...
*/
class DummyValueCodec implements BasePropertyFileAdapter.ValueCodec {
-
- public String decodeText(String encoded) throws ConfigureException {
- return encoded;
+
+ public String encodeProperty(String propName, String propValue, String modifiers) {
+ return propValue;
}
- public String encodeText(String raw) throws ConfigureException {
- return raw;
+ public String getValidModifiers() {
+ return "";
}
-
}
Modified: trunk/distr/src/configure/org/jnode/configure/adapter/JavaStringLiteralCodec.java
===================================================================
--- trunk/distr/src/configure/org/jnode/configure/adapter/JavaStringLiteralCodec.java 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/distr/src/configure/org/jnode/configure/adapter/JavaStringLiteralCodec.java 2008-07-21 13:28:44 UTC (rev 4332)
@@ -32,11 +32,15 @@
private static char[] HEX_DIGITS = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
- public String decodeText(String encoded) throws ConfigureException {
- throw new UnsupportedOperationException("decodeText not supported (or used)");
+ public String encodeProperty(String propName, String propValue, String modifiers) {
+ return propValue == null ? "" : encodeText(propValue);
}
- public String encodeText(String raw) throws ConfigureException {
+ public String getValidModifiers() {
+ return "";
+ }
+
+ private String encodeText(String raw) {
StringBuffer sb = new StringBuffer(raw.length());
for (char ch : raw.toCharArray()) {
switch (ch) {
Modified: trunk/distr/src/configure/org/jnode/configure/adapter/PropertyValueCodec.java
===================================================================
--- trunk/distr/src/configure/org/jnode/configure/adapter/PropertyValueCodec.java 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/distr/src/configure/org/jnode/configure/adapter/PropertyValueCodec.java 2008-07-21 13:28:44 UTC (rev 4332)
@@ -10,15 +10,45 @@
* will be used when a property file is written by template expansion. If it is
* read or written using a {@link java.util.Properties} "load" or "save" method,
* the method will take care of encoding / decoding.)
+ * <p>
+ * This codec supports the following modifiers:
+ * <ul>
+ * <li>'=' says to expand as <propName>=<propValue> rather than <propValue>.
+ * Properties that are not set (explicitly or by defaulting) will be suppressed.
+ * <li>'#' (with '=') says to comment out suppressed properties rather than entirely omitting them.
+ * <li>'!' (with '=') says to suppress a property whose value is an empty string.
+ * </ul>
*
* @author cr...@jn...
*/
class PropertyValueCodec implements BasePropertyFileAdapter.ValueCodec {
- public String decodeText(String encoded) throws ConfigureException {
- throw new UnsupportedOperationException("decodeText not supported (or used)");
+
+ public String encodeProperty(String propName, String propValue, String modifiers) {
+ if (modifiers.contains("=")) {
+ if (propValue == null || propValue.equals("") && modifiers.contains("!")) {
+ if (modifiers.contains("#")) {
+ return "#" + encodeText(propName) + "=";
+ } else {
+ return "";
+ }
+ } else {
+ return encodeText(propName) + "=" + encodeText(propValue);
+ }
+ } else {
+ if (propValue == null) {
+ return "";
+ } else {
+ return encodeText(propValue);
+ }
+ }
}
- public String encodeText(String raw) throws ConfigureException {
+ @Override
+ public String getValidModifiers() {
+ return "=!#";
+ }
+
+ private String encodeText(String raw) {
StringBuffer sb = new StringBuffer(raw.length());
for (char ch : raw.toCharArray()) {
switch (ch) {
Modified: trunk/distr/src/configure/org/jnode/configure/adapter/XMLValueCodec.java
===================================================================
--- trunk/distr/src/configure/org/jnode/configure/adapter/XMLValueCodec.java 2008-07-20 20:11:23 UTC (rev 4331)
+++ trunk/distr/src/configure/org/jnode/configure/adapter/XMLValueCodec.java 2008-07-21 13:28:44 UTC (rev 4332)
@@ -28,11 +28,15 @@
* @author cr...@jn...
*/
class XMLValueCodec implements BasePropertyFileAdapter.ValueCodec {
- public String decodeText(String encoded) throws ConfigureException {
- throw new UnsupportedOperationException("decodeText not supported (or used)");
+ public String encodeProperty(String propName, String propValue, String modifiers) {
+ return propValue == null ? "" : encodeText(propValue);
}
- public String encodeText(String raw) throws ConfigureException {
+ public String getValidModifiers() {
+ return "";
+ }
+
+ private String encodeText(String raw) {
StringBuffer sb = new StringBuffer(raw.length());
for (char ch : raw.toCharArray()) {
switch (ch) {
@@ -47,8 +51,7 @@
break;
default:
// Theoretically we should throw exceptions for characters
- // that
- // are 'forbidden' by the XML specification; e.g. most
+ // that are 'forbidden' by the XML specification; e.g. most
// control codes.
sb.append(ch);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|