You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SelectorListImpl.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 1999 World Wide Web Consortium,
  3. * (Massachusetts Institute of Technology, Institut National de
  4. * Recherche en Informatique et en Automatique, Keio University). All
  5. * Rights Reserved. This program is distributed under the W3C's Software
  6. * Intellectual Property License. This program is distributed in the
  7. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. * PURPOSE.
  10. * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  11. *
  12. * $Id: SelectorListImpl.java,v 1.1 2000/08/07 01:16:21 plehegar Exp $
  13. */
  14. package com.vaadin.sass.parser;
  15. import org.w3c.css.sac.Selector;
  16. import org.w3c.css.sac.SelectorList;
  17. /**
  18. * @version $Revision: 1.1 $
  19. * @author Philippe Le Hegaret
  20. */
  21. public class SelectorListImpl implements SelectorList {
  22. Selector[] selectors = new Selector[5];
  23. int current;
  24. @Override
  25. public Selector item(int index) {
  26. if ((index < 0) || (index >= current)) {
  27. return null;
  28. }
  29. return selectors[index];
  30. }
  31. public Selector itemSelector(int index) {
  32. if ((index < 0) || (index >= current)) {
  33. return null;
  34. }
  35. return selectors[index];
  36. }
  37. @Override
  38. public int getLength() {
  39. return current;
  40. }
  41. public void addSelector(Selector selector) {
  42. if (current == selectors.length) {
  43. Selector[] old = selectors;
  44. selectors = new Selector[old.length + old.length];
  45. System.arraycopy(old, 0, selectors, 0, old.length);
  46. }
  47. selectors[current++] = selector;
  48. }
  49. public void replaceSelector(int index, Selector selector) {
  50. if ((index >= 0) && (index < current)) {
  51. selectors[index] = selector;
  52. }
  53. }
  54. }