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 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2000-2013 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. /*
  17. * Copyright (c) 1999 World Wide Web Consortium,
  18. * (Massachusetts Institute of Technology, Institut National de
  19. * Recherche en Informatique et en Automatique, Keio University). All
  20. * Rights Reserved. This program is distributed under the W3C's Software
  21. * Intellectual Property License. This program is distributed in the
  22. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  23. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  24. * PURPOSE.
  25. * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  26. *
  27. * $Id: SelectorListImpl.java,v 1.1 2000/08/07 01:16:21 plehegar Exp $
  28. */
  29. package com.vaadin.sass.internal.parser;
  30. import org.w3c.css.sac.Selector;
  31. import org.w3c.css.sac.SelectorList;
  32. /**
  33. * @version $Revision: 1.1 $
  34. * @author Philippe Le Hegaret
  35. */
  36. public class SelectorListImpl implements SelectorList {
  37. Selector[] selectors = new Selector[5];
  38. int current;
  39. @Override
  40. public Selector item(int index) {
  41. if ((index < 0) || (index >= current)) {
  42. return null;
  43. }
  44. return selectors[index];
  45. }
  46. public Selector itemSelector(int index) {
  47. if ((index < 0) || (index >= current)) {
  48. return null;
  49. }
  50. return selectors[index];
  51. }
  52. @Override
  53. public int getLength() {
  54. return current;
  55. }
  56. public void addSelector(Selector selector) {
  57. if (current == selectors.length) {
  58. Selector[] old = selectors;
  59. selectors = new Selector[old.length + old.length];
  60. System.arraycopy(old, 0, selectors, 0, old.length);
  61. }
  62. selectors[current++] = selector;
  63. }
  64. public void replaceSelector(int index, Selector selector) {
  65. if ((index >= 0) && (index < current)) {
  66. selectors[index] = selector;
  67. }
  68. }
  69. }