Package org.apache.sling.query.selector.parser

Examples of org.apache.sling.query.selector.parser.SelectorSegment


    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
  }

  @Test
  public void parseResourceTypeAndNameAndFunction() {
    SelectorSegment selector = getFirstSegment("my/resource/type#some-name:first");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
    Assert.assertEquals("some-name", selector.getName());
  }
View Full Code Here


    Assert.assertEquals("some-name", selector.getName());
  }

  @Test
  public void parseResourceTypeAndFunctions() {
    SelectorSegment selector = getFirstSegment("my/resource/type:first:eq(12)");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(f("first", null), f("eq", "12")), selector.getModifiers());
  }
View Full Code Here

    Assert.assertEquals(Arrays.asList(f("first", null), f("eq", "12")), selector.getModifiers());
  }

  @Test
  public void parseResourceTypeAndPropertyAndFunction() {
    SelectorSegment selector = getFirstSegment("my/resource/type[key=value]:first");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(pp("key", "value")), selector.getAttributes());
    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
  }
View Full Code Here

    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
  }

  @Test
  public void parseResourceTypeAndNameAndPropertyAndFunction() {
    SelectorSegment selector = getFirstSegment("my/resource/type#some-name[key=value]:first");
    Assert.assertEquals(selector.getType(), "my/resource/type");
    Assert.assertEquals(Arrays.asList(pp("key", "value")), selector.getAttributes());
    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
    Assert.assertEquals("some-name", selector.getName());
  }
View Full Code Here

    Assert.assertEquals("some-name", selector.getName());
  }

  @Test
  public void parseResourceTypeAndPropertiesAndFunction() {
    SelectorSegment selector = getFirstSegment("my/resource/type[key=value][key2=value2]:first");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(pp("key", "value"), pp("key2", "value2")), selector.getAttributes());
    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
  }
View Full Code Here

    Assert.assertEquals(Arrays.asList(f("first", null)), selector.getModifiers());
  }

  @Test
  public void parseResourceTypeAndPropertyAndFunctions() {
    SelectorSegment selector = getFirstSegment("my/resource/type[key=value]:first:eq(12)");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(pp("key", "value")), selector.getAttributes());
    Assert.assertEquals(Arrays.asList(f("first", null), f("eq", "12")), selector.getModifiers());
  }
View Full Code Here

    Assert.assertEquals(Arrays.asList(f("first", null), f("eq", "12")), selector.getModifiers());
  }

  @Test
  public void parseResourceTypeAndPropertiesAndFunctions() {
    SelectorSegment selector = getFirstSegment("my/resource/type[key=value][key2=value2]:first:eq(12)");
    Assert.assertEquals("my/resource/type", selector.getType());
    Assert.assertEquals(Arrays.asList(pp("key", "value"), pp("key2", "value2")), selector.getAttributes());
    Assert.assertEquals(Arrays.asList(f("first", null), f("eq", "12")), selector.getModifiers());
  }
View Full Code Here

    List<SelectorSegment> list = new ArrayList<SelectorSegment>();
    if (segments.length > 0) {
      list.add(getFirstSegment(segments[0]));
    }
    for (int i = 1; i < segments.length; i += 2) {
      SelectorSegment parsed = getFirstSegment(segments[i + 1]);
      char operator = segments[i].charAt(0);
      SelectorSegment segment = new SelectorSegment(parsed.getType(), null, parsed.getAttributes(),
          parsed.getModifiers(), operator);
      list.add(segment);
    }
    return list;
  }
View Full Code Here

import org.junit.Test;

public class SelectorTest {
  @Test
  public void parseResourceType() {
    SelectorSegment selector = getFirstSegment("my/resource/type");
    Assert.assertEquals(selector.getType(), "my/resource/type");
  }
View Full Code Here

    Assert.assertEquals(selector.getType(), "my/resource/type");
  }

  @Test
  public void parseProperty() {
    SelectorSegment selector = getFirstSegment("[key=value]");
    Assert.assertEquals(Arrays.asList(pp("key", "value")), selector.getAttributes());
  }
View Full Code Here

TOP

Related Classes of org.apache.sling.query.selector.parser.SelectorSegment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.