Package org.apache.poi.ss.formula.ptg

Examples of org.apache.poi.ss.formula.ptg.StringPtg


    if (Character.isDigit(look)) {
      return new ParseNode(parseNumber());
    }
    if (look == '"') {
      return new ParseNode(new StringPtg(parseStringLiteral()));
    }
   
    // from now on we can only be dealing with non-quoted identifiers
    // which will either be named ranges or functions
    String name = parseAsName();
View Full Code Here


        Match('(');
        ParseNode inside = comparisonExpression();
        Match(')');
        return new ParseNode(ParenthesisPtg.instance, inside);
      case '"':
        return new ParseNode(new StringPtg(parseStringLiteral()));
      case '{':
        Match('{');
        ParseNode arrayNode = parseArray();
        Match('}');
        return arrayNode;
View Full Code Here

  private static void confirmStringParse(String singleQuotedValue) {
    // formula: internal quotes become double double, surround with double quotes
    String formula = '"' + singleQuotedValue.replaceAll("'", "\"\"") + '"';
    String expectedValue = singleQuotedValue.replace('\'', '"');

    StringPtg sp = (StringPtg) parseSingleToken(formula, StringPtg.class);
    assertEquals(expectedValue, sp.getValue());
  }
View Full Code Here

    StringPtg sp = (StringPtg) parseSingleToken(formula, StringPtg.class);
    assertEquals(expectedValue, sp.getValue());
  }
  public void testParseStringLiterals_bug28754() {

    StringPtg sp;
    try {
      sp = (StringPtg) parseSingleToken("\"test\"\"ing\"", StringPtg.class);
    } catch (RuntimeException e) {
      if(e.getMessage().startsWith("Cannot Parse")) {
        throw new AssertionFailedError("Identified bug 28754a");
      }
      throw e;
    }
    assertEquals("test\"ing", sp.getValue());

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    wb.setSheetName(0, "Sheet1");
View Full Code Here

        sb.append('\0'); // list delimiter is the nul char
      }
      sb.append(_explicitListValues[i]);
   
    }
    return new Ptg[] { new StringPtg(sb.toString()), };
  }
View Full Code Here

  private static void confirmStringParse(String singleQuotedValue) {
    // formula: internal quotes become double double, surround with double quotes
    String formula = '"' + singleQuotedValue.replaceAll("'", "\"\"") + '"';
    String expectedValue = singleQuotedValue.replace('\'', '"');

    StringPtg sp = (StringPtg) parseSingleToken(formula, StringPtg.class);
    assertEquals(expectedValue, sp.getValue());
  }
View Full Code Here

    StringPtg sp = (StringPtg) parseSingleToken(formula, StringPtg.class);
    assertEquals(expectedValue, sp.getValue());
  }
  public void testParseStringLiterals_bug28754() {

    StringPtg sp;
    try {
      sp = (StringPtg) parseSingleToken("\"test\"\"ing\"", StringPtg.class);
    } catch (RuntimeException e) {
      if(e.getMessage().startsWith("Cannot Parse")) {
        throw new AssertionFailedError("Identified bug 28754a");
      }
      throw e;
    }
    assertEquals("test\"ing", sp.getValue());

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    wb.setSheetName(0, "Sheet1");
View Full Code Here

    Ptg[] ptgs = parseFormula("IF(TRUE,\"Y\",\"N\")");
    assertEquals(7, ptgs.length);

    BoolPtg flag  = (BoolPtg) ptgs[0];
    AttrPtg funif = (AttrPtg) ptgs[1];
    StringPtg y = (StringPtg) ptgs[2];
    AttrPtg goto1 = (AttrPtg) ptgs[3];
    StringPtg n = (StringPtg) ptgs[4];


    assertEquals(true, flag.getValue());
    assertEquals("Y", y.getValue());
    assertEquals("N", n.getValue());
    assertEquals("IF", funif.toFormulaString());
    assertTrue("tAttrSkip ptg exists", goto1.isSkip());
  }
View Full Code Here

        sb.append('\0'); // list delimiter is the nul char
      }
      sb.append(_explicitListValues[i]);
   
    }
    return new Ptg[] { new StringPtg(sb.toString()), };
  }
View Full Code Here

        sb.append('\0'); // list delimiter is the nul char
      }
      sb.append(_explicitListValues[i]);
   
    }
    return new Ptg[] { new StringPtg(sb.toString()), };
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.ptg.StringPtg

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.