
// Copyright (c) 2000 Oracle Corporation
package oracle.portal.provider.v2.utils;

import java.util.*;
import java.io.*;

/**
 * MLString is a multi-language string.  An MLString allows you to store
 * different language of the same value in the same object and retrieve a
 * particular version based on Locale.  This is designed to be used by
 * data objects representing customization data.  The Portal has a convention
 * that many customization values should be multi-lingual.  I.e. a user can
 * store a value per language.  Language is controlled via the browser's language
 * preference setting.
 */
public class HashMLString implements MLString, Serializable {
    private Hashtable mValues;

    public HashMLString() {
        mValues = new Hashtable();
    }

    /**
     *  Sets the String value for the language defined be this Locale.
     *
     *  @param str the new value
     *  @l the Locale (language) of this string
     */
    public void setString(String str, Locale l) {
        mValues.put(l.getLanguage(), str);
    }

    /**
     *  Returns the String in the Locale's language.  If a String hasn't
     *  previously been assigned with this language then <b>null</b> is returned.
     *
     *  @param l the Locale (language) of the String we want.
     */
    public String getString(Locale l) {
        return (String) mValues.get(l.getLanguage());
    }

}


