You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hu...@apache.org on 2004/03/29 02:52:22 UTC
cvs commit: jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands LocaleChange.java LocaleCommand.java MailReader.java MailReaderBase.java
husted 2004/03/28 16:52:22
Modified: chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader
ClientContext.java
Added: chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader
MailReader.java MailReaderBase.java
chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands
LocaleChange.java
Removed: chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands
LocaleCommand.java MailReader.java
MailReaderBase.java
Log:
Refactor class and packages naming.
Revision Changes Path
1.2 +11 -3 jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/ClientContext.java
Index: ClientContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/ClientContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClientContext.java 28 Mar 2004 03:20:55 -0000 1.1
+++ ClientContext.java 29 Mar 2004 00:52:22 -0000 1.2
@@ -12,20 +12,28 @@
* representation.
* </p>
* <p>
- * See {@link org.apache.commons.chain.mailreader.commands.MailReaderBase}
+ * See {@link org.apache.commons.chain.mailreader.MailReaderBase}
* for an implementation.
* </p>
*/
public interface ClientContext extends Context {
+ /**
+ * Client {@link Locale} property.
+ */
public static String PN_LOCALE = "locale";
- public boolean isLocale();
+
public void setLocale(Locale locale);
+
public Locale getLocale();
+ /**
+ * Input {@link Context} property.
+ */
public static String PN_INPUT = "input";
- public boolean isInput();
+
public void setInput(Context context);
+
public Context getInput();
}
1.1 jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/MailReader.java
Index: MailReader.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/MailReader.java,v 1.1 2004/03/29 00:52:22 husted Exp $
* $Revision: 1.1 $
* $Date: 2004/03/29 00:52:22 $
*
* Copyright 2000-2004 Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.chain.mailreader;
/**
* Application interface for MailReader Commands.
*/
public interface MailReader extends ClientContext {
/**
* Property name for the country field of a Locale.
*/
static String PN_COUNTRY = "country";
/**
* Property name for the language field of a Locale.
*/
static String PN_LANGUAGE = "language";
// Database
// User
}
1.1 jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/MailReaderBase.java
Index: MailReaderBase.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/MailReaderBase.java,v 1.1 2004/03/29 00:52:22 husted Exp $
* $Revision: 1.1 $
* $Date: 2004/03/29 00:52:22 $
*
* Copyright 2000-2004 Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.chain.mailreader;
import org.apache.commons.chain.Context;
import org.apache.commons.chain.impl.ContextBase;
import java.util.Locale;
/**
* Implements MailReader API for a Struts application.
*/
public class MailReaderBase extends ContextBase implements MailReader {
/**
* <p>Default constructor.</p>
*/
public MailReaderBase() {
super();
}
/**
* <p>Convenience constructor to create and populate instance.</p>
* @param locale
* @param input
*/
public MailReaderBase(Locale locale, Context input) {
super();
this.locale = locale;
this.input = input;
}
/**
* <p>Field for Locale property.</p>
*/
private Locale locale;
/**
* <p>Return Locale property</p>
* @return This Locale property
*/
public Locale getLocale() {
return locale;
}
/**
* <p>Assign Locale property</p>
* @param locale New Locale
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
/**
* <p>Field for Input property.</p>
*/
private Context input;
/**
* <p>Return Input property.</p>
* @return This Input property
*/
public Context getInput() {
return input;
}
/**
* <p>Assign Input property</p>
* @param input New Input context
*/
public void setInput(Context input) {
this.input = input;
}
}
1.1 jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands/LocaleChange.java
Index: LocaleChange.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands/LocaleChange.java,v 1.1 2004/03/29 00:52:22 husted Exp $
* $Revision: 1.1 $
* $Date: 2004/03/29 00:52:22 $
*
* Copyright 2000-2004 Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.chain.mailreader.commands;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
import org.apache.commons.chain.mailreader.MailReader;
import java.util.Locale;
/**
* Change Locale according to input values, country and language.
*/
public class LocaleChange implements Command {
static boolean isBlank(String string) {
return ((string == null) || (string.trim().length() == 0));
}
public boolean execute(Context context) {
MailReader app = (MailReader) context;
Context input = app.getInput();
String country = (String) input.get(MailReader.PN_COUNTRY);
String language = (String) input.get(MailReader.PN_LANGUAGE);
Locale locale = Locale.getDefault();
if ((!isBlank(language)) && (!isBlank(country))) {
locale = new Locale(language, country);
} else if (!isBlank(language)) {
locale = new Locale(language, "");
}
app.setLocale(locale);
return false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org