Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1b759b1f8973f7d8ed610156264919c04c0dd628 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*******************************************************************************
 * Copyright (c) 2004, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.command.internal.env.core.selection;

import org.eclipse.wst.command.internal.env.core.data.Transformer;

/**
 * This transformer class selects a string at a particular level
 * in a SelectionListChoices class.
 */
public class ChoicesToString implements Transformer
{
  private int level_;
  
  public ChoicesToString( int level )
  {
    level_ = level;
  }
  
  /* (non-Javadoc)
   * @see org.eclipse.wst.command.internal.env.core.data.Transformer#transform(java.lang.Object)
   */
  public Object transform( Object value )
  {
    SelectionListChoices choices = (SelectionListChoices)value;
    
    for( int index = 0; index < level_; index++ )
    {
      choices = choices.getChoice();
    }
    
    return choices.getList().getSelection();
  }

  public SelectionList transform( SelectionListChoices choices )
  {
    return (SelectionList)transform( (Object)choices );
  }
}

Back to the top