KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > conversion > StatusToStringConverter


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.core.internal.databinding.conversion;
13
14 import org.eclipse.core.databinding.conversion.Converter;
15 import org.eclipse.core.databinding.conversion.IConverter;
16 import org.eclipse.core.runtime.IStatus;
17
18 /**
19  * Converts an IStatus into a String. The message of the status is the returned value.
20  *
21  * @since 1.0
22  */

23 public class StatusToStringConverter extends Converter implements IConverter {
24     /**
25      * Constructs a new instance.
26      */

27     public StatusToStringConverter() {
28         super(IStatus.class, String JavaDoc.class);
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.core.databinding.conversion.IConverter#convert(java.lang.Object)
33      */

34     public Object JavaDoc convert(Object JavaDoc fromObject) {
35         if (fromObject == null) {
36             throw new IllegalArgumentException JavaDoc("Parameter 'fromObject' was null."); //$NON-NLS-1$
37
}
38         
39         IStatus status = (IStatus) fromObject;
40         return status.getMessage();
41     }
42 }
43
Popular Tags