public static String[] getReferences( final String formula ) throws ParseException { if ( formula == null ) { throw new NullPointerException(); } final String formulaExpression = extractFormula( formula ); if ( formulaExpression == null ) { throw new ParseException( "Formula is invalid" ); } return getReferences( new Formula( formulaExpression ) ); }
public String toString() { return FormulaUtil.quoteReference(name); }
public static String quoteReference( final String reference ) { if ( reference == null ) { throw new NullPointerException(); } final char[] referenceChars = reference.toCharArray(); if ( isQuotingNeeded( referenceChars ) == false ) { return '[' + reference + ']'; } return '[' + quoteString( reference ) + ']'; }
public static String extractStaticTextFromFormula( final String formula ) { if ( formula == null ) { return null; } final String formulaFragment = extractFormula( formula ); return extractStaticTextFromFormulaFragment( formulaFragment ); }
for ( int i = 0; i < definitions.length; i++ ) { final FieldDefinition fieldDefinition = definitions[ i ]; comboBoxModel.addElement( "=" + FormulaUtil.quoteReference( fieldDefinition.getName() ) ); String rawFormulaText; if ( isFormulaFragment() == false ) { rawFormulaText = FormulaUtil.extractFormula( String.valueOf( value ) ); } else { rawFormulaText = String.valueOf( value ); String formulaText = FormulaUtil.createEditorTextFromFormula( rawFormulaText, formulaContext ); comboBox.setSelectedItem( formulaText );
return new TypeValuePair( TextType.TYPE, HtmlCharacterEntities.getEntityParser().encodeEntities( textResult ) ); } else if ( encodingResult.equals( "formula-string" ) ) { return new TypeValuePair( TextType.TYPE, FormulaUtil.quoteString( textResult ) ); } else if ( encodingResult.equals( "formula-reference" ) ) { return new TypeValuePair( TextType.TYPE, FormulaUtil.quoteReference( textResult ) ); } else { // javascript return new TypeValuePair( TextType.TYPE, saveConvert( textResult ) );
final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) {
public String toString() { if ( value instanceof Number ) { return String.valueOf( value ); } return FormulaUtil.quoteString( String.valueOf( value ) ); }
/** * Returns the value contained in the editor. * * @return the value contained in the editor */ public Object getCellEditorValue() { final Object selectedItem = comboBox.getSelectedItem(); if ( "".equals( selectedItem ) || selectedItem == null ) { return null; } String text = String.valueOf( selectedItem ); if ( text.startsWith( "'" ) ) { text = "=" + FormulaUtil.quoteString( text.substring( 1 ) ); } if ( isFormulaFragment() ) { return FormulaUtil.createFormulaFromUIText( text ); } return text; }
public static String extractFormula(final String formula) { String[] strings = extractFormulaContext(formula); return strings[1]; }
@Deprecated public String editFormulaFragment( final String formula, final FieldDefinition[] fields ) { if ( fields == null ) { throw new NullPointerException(); } if ( StringUtils.isEmpty( formula, true ) ) { panel.setFormulaText( "=" ); } else { panel.setFormulaText( "=" + formula ); } panel.setFields( fields ); setVisible( true ); if ( !performEdit() ) { return null; } final String formulaText = panel.getFormulaText(); if ( StringUtils.isEmpty( formulaText, true ) || formulaText.trim().equals( "=" ) ) { return null; } return FormulaUtil.extractFormula( formulaText ); }
( list, FormulaUtil.createCellUITextFromFormula( sValue ), index, isSelected, cellHasFocus ); if ( FormulaUtil.isValidFormulaFragment( sValue ) == false ) { retval.setBackground( Color.RED ); } else {
public static String[] getReferences(final Formula formula) { if (formula == null) { throw new NullPointerException(); } final LinkedHashMap<String,Boolean> map = new LinkedHashMap<String, Boolean>(); final LValue lValue = formula.getRootReference(); collectReferences(lValue, map); return map.keySet().toArray(new String[map.size()]); }
public static String createCellUITextFromFormula( final String formula ) { return createCellUITextFromFormula( formula, new DefaultFormulaContext() ); }
final String formula = String.valueOf( attributeValue ); try { final Object[] objects = FormulaUtil.getReferences( formula ); final ArrayList list = new ArrayList(); for ( int i = 0; i < objects.length; i++ ) {
public String toString() { if (value instanceof Number) { return String.valueOf(value); } return FormulaUtil.quoteString(String.valueOf(value)); }
public static String extractStaticTextFromFormula(final String formula) { if (formula == null) { return null; } final String formulaFragment = extractFormula(formula); return extractStaticTextFromFormulaFragment(formulaFragment); }
public static String extractFormula( final String formula ) { String[] strings = extractFormulaContext( formula ); return strings[ 1 ]; }
return; final String formulaText = FormulaUtil.extractFormula( rawFormula ); if ( StringUtils.isEmpty( formulaText ) ) { errorTextHolder.setText( Messages.getInstance().getString( "FormulaEditorDialog.ShortErrorNoFormulaContext" ) );
public Component getTableCellRendererComponent( final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column ) { if ( value == null ) { return tableCellRenderer.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column ); } String sValue = String.valueOf( value ); if ( StringUtils.isEmpty( sValue ) ) { return tableCellRenderer.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column ); } else if ( sValue.startsWith( "=" ) ) { // User does not need to prepend equal sign as it gets prepended automatically // Strip off the equal sign and update expression editor and table cell. sValue = sValue.substring( 1 ); } final Component retval = tableCellRenderer.getTableCellRendererComponent ( table, FormulaUtil.createCellUITextFromFormula( sValue ), isSelected, hasFocus, row, column ); if ( FormulaUtil.isValidFormulaFragment( sValue ) == false ) { retval.setBackground( Color.RED ); } else if ( retval.getBackground() == Color.RED ) { retval.setBackground( table.getBackground() ); } return retval; }