01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.superbiz.enventries;
17:
18: /**
19: * With a java.beans.PropertyEditor, you can go way beyond the built-in
20: * types that OpenEJB supports and can extend dependency injection to
21: * just about anywhere.
22: *
23: * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
24: * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
25: * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
26: *
27: * @version $Revision$ $Date$
28: */
29: //START SNIPPET: code
30: public class PickupEditor extends java.beans.PropertyEditorSupport {
31:
32: public void setAsText(String text) throws IllegalArgumentException {
33: text = text.trim();
34:
35: if (text.equalsIgnoreCase("H"))
36: setValue(Pickup.HUMBUCKER);
37: else if (text.equalsIgnoreCase("S"))
38: setValue(Pickup.SINGLE_COIL);
39: else
40: throw new IllegalStateException(
41: "H and S are the only supported Pickup aliases");
42: }
43: }
44: //END SNIPPET: code
|