Source code: javax/ide/menu/spi/PositionableVisitor.java
1 package javax.ide.menu.spi;
2
3 import javax.ide.extension.ElementVisitor;
4 import java.util.logging.Level;
5 import javax.ide.extension.ElementStartContext;
6
7 abstract class PositionableVisitor extends ElementVisitor
8 {
9 private final String _idAttribute;
10
11 protected PositionableVisitor( String idAttribute )
12 {
13 _idAttribute = idAttribute;
14 }
15
16 protected PositionableVisitor()
17 {
18 this( "id" );
19 }
20
21 public final void start( ElementStartContext context )
22 {
23 String id = context.getAttributeValue( _idAttribute );
24 if ( id == null || (id = id.trim()).length() == 0 )
25 {
26 log( context, Level.SEVERE, "Missing required attribute '"+_idAttribute+"'" );
27 return;
28 }
29
30 String before = context.getAttributeValue( "before" );
31 if ( before != null )
32 {
33 before = before.trim();
34 }
35
36 String after = context.getAttributeValue( "after" );
37 if ( after != null )
38 {
39 if ( before != null )
40 {
41 log( context, Level.SEVERE, "Cannot have both 'before' and 'after'" );
42 return;
43 }
44 after = after.trim();
45 }
46
47 positionable( context, id, before, after );
48 }
49
50 protected abstract void positionable( ElementStartContext context, String id,
51 String before, String after );
52
53 }