Class Locale 1/3 Constructor Locale(String, String) Construct a locale from language, country. Locale(String, String, String) Construct a locale from language,

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Advertisements

1 Inheritance Chapter 9. 2 Module Outcomes To develop a subclass from a superclass through inheritance To invoke the superclass ’ s constructors and methods.
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
C8: Understanding Inheritance. Intuitive description Intuitive: FLORISTS are SHOPKEEPERS, inheriting various shopkeeper behaviors Tension in OOP languages:
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
1 Lecture 3 Inheritance. 2 A class that is inherited is called superclass The class that inherits is called subclass A subclass is a specialized version.
1 More on Inheritance Overview l Object: The father of all classes l Casting and Classes l Object Cloning l Importance of Cloning.
1 Inheritance Overview l Inheritance ensures Reusability l Example of Inheritance l What is actually Inherited? l Overloading Vs. Overriding l Object:
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
Creating Classes from Other Classes Chapter 2. 2 Chapter Contents Composition Adapters Inheritance Invoking constructors from within constructors Private.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
AITI Tutorial: Internationalization Coding for the world MIT AITI July NNth, 2005.
1 Inheritance and Polymorphism Chapter 9. 2 Polymorphism, Dynamic Binding and Generic Programming public class Test { public static void main(String[]
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Internationalization and the Java Stack Part 1 Matt Wheeler.
Internationalization and the Java Stack Matt Wheeler.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Introduction to Java Prepared by: Ahmed Hefny. Outline Classes Access Levels Member Initialization Inheritance and Polymorphism Interfaces Inner Classes.
Internationalization in the Java Stack Matt Wheeler.
2000 Jordan Anastasiade. All rights reserved. 1 Class In this lesson you will be learning about: Class. Inheritance. Polymorphism. Nested and.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 26 Internationalization.
Chapter 12: Internationalization Processing Date and Time Processing Date and Time  Locale  Date  TimeZone  Calendar and GregorianCalendar  DateFormat.
Exceptions. Exception Abnormal event occurring during program execution Examples –Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Copyright © 2002, Systems and Computer Engineering, Carleton University Hashtable.ppt * Object-Oriented Software Development Unit 8.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
Inheritance (Part 4) Polymorphism and Abstract Classes 1.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Chapter 14 Abstract Classes and Interfaces. Abstract Classes An abstract class extracts common features and functionality of a family of objects An abstract.
Inheritance (Part 2) Notes Chapter KomondorBloodHound PureBreedMix Dog Object Dog extends Object PureBreed extends Dog Komondor extends PureBreed.
Inheritance (Part 5) Odds and ends 1. Static Methods and Inheritance  there is a significant difference between calling a static method and calling a.
Inheritance Dr. Andrew Wallace PhD BEng(hons) EurIng
Chapter 5 Objects and Classes Inheritance. Solution Assignments 3 & 4 Review in class…..
U n i v e r s i t y o f H a i l 1 ICS 202  2011 spring  Data Structures and Algorithms 
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
1 Chapter 20 Internationalization. 2 Objectives F To describe Java's internationalization features (§ 20.1). F To construct a locale with language, country,
Access Modifiers Control which classes use a feature Only class-level variables may be controlled by access modifiers Modifiers 1. public 2. protected.
The Factory Method Pattern (Creational) ©SoftMoore ConsultingSlide 1.
Inheritance Type/Subtype Relationship. Inheritance Idea: An object B of one type, termed child class, inherits from another object A of another type,
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
Internationalization Slide 1©SoftMoore Consulting.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Interfaces, Abstract Classes, and Polymorphism. What Is an Interface? An interface is the set of public methods in a class Java provides the syntax for.
CSI 3125, Preliminaries, page 1 Inheritance. CSI 3125, Preliminaries, page 2 Inheritance Using inheritance, can create a general class that defines traits.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
1 Object-Oriented Programming Inheritance. 2 Superclasses and Subclasses Superclasses and Subclasses  Superclasses and subclasses Object of one class.
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 3 – Extending classes.
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
The Object class Object package java.lang Object clone equals hashCode toString aCopy toThis hash string ! yesOrNo.
1 clone() Defined in Object Creates an identical copy –Copies pointers to fields (does not copy fields of fields) –Makes a shallow copy if the object’s.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Objects and Classes. F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and object type.
Polymorphism 2nd Lecture
Lecture 12 Inheritance.
Chapter 14 Internationalization
Chapter 8 Classes and Objects
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
null, true, and false are also reserved.
Interface.
Sampath Kumar S Assistant Professor, SECE
Chapter 35 Internationalization
Chapter 8 Class Inheritance and Interfaces
Chapter 11 Inheritance and Encapsulation and Polymorphism
Presentation transcript:

class Locale 1/3 Constructor Locale(String, String) Construct a locale from language, country. Locale(String, String, String) Construct a locale from language, country, variant. Methods clone() equals(Object) getCountry() uppercased two-letter ISO-3166 getDefault() getDisplayCountry() getDisplayCountry(Locale) getDisplayLanguage() getDisplayLanguage(Locale) getDisplayName() getDisplayName(Locale) getDisplayVariant() getDisplayVariant(Locale) getISO3Country() three-letter ISO country abbreviation getISO3Language() three-letter ISO language abbreviation getLanguage() lowercased two-letter ISO-639 getVariant() hashCode() setDefault(Locale) toString()

class Locale 2/3 import java.util.Locale; public class GetLocale { public static void main( String args[ ] ) { Locale locale = new Locale( "ko", "KR" ); Locale locale_er = new Locale( "error", "ERROR" ); System.out.println( locale ); System.out.println( Locale.getDefault( ) ); System.out.println( locale.getISO3Language( ) ); System.out.println( locale.getISO3Country( ) ); System.out.println( locale.getDisplayLanguage( ) ); System.out.println( locale_er ); System.out.println( Locale.FRENCH ); System.out.println( Locale.FRANCE ); }

class Locale 3/3 gura:~/Java/Seminar/java.util> java GetLocale ko_KR en kor KOR Korean error_ERROR fr fr_FR

class TimeZone 1/5 Constructor TimeZone() Methods clone() Overrides Cloneable getAvailableIDs() Gets all the available IDs supported. getAvailableIDs(int) getDefault() getID() Gets the ID of this time zone. getOffset(int, int, int, int, int, int) Gets the time zone offset, for current date, modified in case of daylight savings. getRawOffset() Gets unmodified offset, NOT modified in case of daylight savings. getTimeZone(String) Gets the TimeZone for the given ID. inDaylightTime(Date) Queries if the given date is in Daylight Savings Time in this time zone. setDefault(TimeZone) setID(String) Sets the time zone ID. setRawOffset(int) Sets the base time zone offset to GMT. useDaylightTime() Queries if this time zone uses Daylight Savings Time.

class TimeZone 2/5 Abstract Class. TimeZone represents a time zone offset, and also figures out daylight savings. TimeZone tz = TimeZone.getTimeZone("PST"); Typically, you get a TimeZone using getDefault which creates a TimeZone based on the time zone where the program is running. For example, for a program running in Japan, getDefault creates a TimeZone object based on Japanese Standard Time.

class TimeZone 3/5 public static synchronized String[] getAvailableIDs() public static synchronized TimeZone getDefault() Gets the default TimeZone for this host. public abstract boolean inDaylightTime(Date date) Queries if the given date is in Daylight Savings Time in this time zone. public abstract boolean useDaylightTime() Queries if this time zone uses Daylight Savings Time. public abstract int getRawOffset() Gets unmodified offset, NOT modified in case of daylight savings. This is the offset to add *to* UTC to get local time. public static synchronized TimeZone getDefault() Gets the default TimeZone for this host.

class TimeZone 4/5 public class TimeZoneTest { public static void main( String args[ ] ) { //TimeZone Test = new TimeZone( ); System.out.println( TimeZone.getDefault( ) ); //System.out.println( Test.getRawOffset( ) ); String Test2[ ]; Test2=TimeZone.getAvailableIDs System.out.println( Test2.length - 1 ); for(inti=0;i<Test2.length;i++) { System.out.println( Test2[ i ] ); }

class TimeZone 5/5 gura:~/Java/Seminar/java.util> java TimeZoneTest 30 GMT ECT EET ART EAT MET NET PLT IST BST VST CTT JST ACT AET SST NST MIT HST...

class ResourceBundle 1/3 Constructor ResourceBundle() Methods getBundle(String) Get the appropriate ResourceBundle subclass. GetBundle(String, Loca) Get the appropriate ResourceBundle subclass. getKeys() Return an enumeration of the keys. getObject(String) Get an object from a ResourceBundle. getString(String) Get an object from a ResourceBundle. getStringArray(String) Get an object from a ResourceBundle. handleGetObject(String) Get an object from a ResourceBundle. setParent(ResourceBundle) Set the parent bundle of this bundle.

class ResourceBundle 2/3 This allows you to write programs that can: –be easily localized, or translated, into different languages –handle multiple locales at once –be easily modified later to support even more locales baseclass must be fully qualified : myPackage.MyResources baseclass with no suffixes baseclass + "_" + language1 + "_" + country1 + "_" + variant1 baseclass + "_" + language1 + "_" + country1 baseclass + "_" + language1 baseclass baseclass + "_" + language2 + "_" + country2 + "_" + variant2 baseclass + "_" + language2 + "_" + country2 baseclass + "_" + language2 key/value pairs : keys are always Strings parent handleGetObject( String key ), getKeys( ) –only these are abstract methods.

class ResourceBundle 3/3 import java.util.ResourceBundle; import java.util.Locale; class MyResourceTester { public static void main( String args[ ] ) { ResourceBundle myResource = ResourceBundle.getBundle( "MyResource", Locale.FRANCE ); System.out.println( myResource.getString( "s6" ) ); myResource = ResourceBundle.getBundle( "MyResource” ); System.out.println( myResource.getString( "s6" ) ); } gura:~/Java/Seminar/java.util> java MyResourceTester pas de files no files

class PropertyRe...dle 1/2 public PropertyResourceBundle(InputStream stream) throws IOException Creates a property resource Parameters: file - property file to read from. public Object handleGetObject(String key) Override of ResourceBundle, same semantics Overrides: handleGetObject in class ResourceBundle public Enumeration getKeys() Implementation of ResourceBundle.getKeys. Overrides: getKeys in class ResourceBundle description.

class PropertyRe...dle 2/2 s1=3 s2=MeinDisk s3=3 Mar 96 s4=Der disk '{1}' a {0} a {2}. s5=0 s6=keine Datein s7=1 s8=ein Datei s9=2 s10={0}|3 Datein s11=Der Format worf ein Exception: {0} s12=ERROR s14=Resulte s13=Dialogue s15=Pattern s16=1,3 keys are case-sensitive

class ListRe...dle 1/2 public ListResourceBundle() public final Object handleGetObject(String key) Override of ResourceBundle, same semantics Overrides: handleGetObject in class ResourceBundle public Enumeration getKeys() Implementation of ResourceBundle.getKeys. Overrides: getKeys in class ResourceBundle protected abstract Object[][] getContents()

class ListRe...dle 2/2 import java.util.ResourceBundle; import java.awt.Dimension; import java.util.ListResourceBundle; public class MyResource extends ListResourceBundle { public Object[][] getContents() { return contents; } static final Object[][] contents = { // LOCALIZE THIS {"s1", "3"}, {"s2", "MyDisk"}, {"s3", "3 Mar 96"}, {"s4", "The disk '{1}' contained {0} on {2}."}, {"s5", "0"}, {"s6", "no files"}, {"s7", "1"}, {"s8", "one file"}, {"s9", "2"}, {"s10", "{0}|3 files"}, {"s11", "format threw an exception: {0}"}, {"s12", "ERROR"}, {"s14", "Result"}, {"s13", "Dialog"}, {"s15", "Pattern"}, {"s16", new Dimension(1,5)} // END OF MATERIAL TO LOCALIZE }; }