Top.Mail.Ru
April 23rd, 2006 - Java developers — LiveJournal
? ?

Java developers

April 23rd, 2006
Image

10:42 am - Imagenjzero

Anyone have a link or code to show a simple MP3 playback in JAVA from file? A "Hello World!", MP3 style if you will...

I keep getting third party vendors selling products when searching for it.

Any tutorials or code samples would be greatly appreciated!
Image

08:17 pm - Imagelordalfredhenry - Technique/mini-Pattern for exceptions with new enum feature.

Is this a good way to do it? Is there better? If only java.sql had this... The real goal is to reduce Exception proliferation where it is unnecessary and to avoid the anti-pattern of String messages in exceptions (more out of temptation for newbies to parse them which is a horrid maintainability practice). Also, the offending object parameter could be identified by it's class or instanceof. (I think an o.k. use of instanceof). The class name could be debugged in this case.

public class IllegalChildException extends Exception {

	private static final long serialVersionUID = 1L;

	public enum Code{
		/* Codes */
		WORKITEM("WorkItems can only have Stat children."), 
		STAT("Stats cannot have children."), 
		ROUTINE("Routines can have only Stat children.");
		
		private String message;
		Code(String message){this.message = message;}
		public String message() { return message; }
	}
	
	private Code code;
	private Object badChildObject;

	public IllegalChildException(Code code, Object offendingChildObject)	{
		super(code.message());
		this.code = code;
                this.badChildObject = offendingChildObject;
	}
	
	public Code code()	{
		return code;
	}
        public Object getBadChildObject() {
                return badChildObject;
        }
}
Powered by LiveJournal.com
Image