Please don't send private emails following up a thread. This is not a test case for a bug, this is commented code. I am not saying that there isn't a bug there, maybe there is.
musachy On Fri, May 22, 2009 at 9:50 AM, Martin Gainty <mgai...@hotmail.com> wrote: > //rather lengthy testcase for includeProperties > > com.googlecode.jsonplugin.JSONResultTest > public void testIncludePropertiesWithList() throws Exception { > JSONResult result = new JSONResult(); > > /*public class JSONResult implements Result { > private static final long serialVersionUID = 8624350183189931165L; > private String defaultEncoding = "ISO-8859-1"; > private List<Pattern> includeProperties; //you want to initialise this! > */ > > result.setIncludeProperties("^list\\[\\d+\\]\\.booleanField"); > > /*** @param includedProperties the includeProperties to set > */ > public void setIncludeProperties(String commaDelim) { > > List<String> includePatterns = JSONUtil.asList(commaDelim); > //splits all Strings using , as delimiter > /* public static List<String> asList(String commaDelim) { > if ((commaDelim == null) || (commaDelim.trim().length() == 0)) > return null; > List<String> list = new ArrayList<String>(); > String[] split = commaDelim.split(","); > for (int i = 0; i < split.length; i++) { > String trimmed = split[i].trim(); > if (trimmed.length() > 0) { > list.add(trimmed); > } > } > return list; > } > */ > > if (includePatterns != null) //TRUE > { > this.includeProperties = new > ArrayList<Pattern>(includePatterns.size()); > //includeProperties now includes ArrayList<Pattern> > > HashMap existingPatterns = new HashMap(); > > for (String pattern : includePatterns) { > // Compile a pattern for each *unique* "level" of the object > // hierarchy specified in the regex. > //split according to \ delimiter found > String[] patternPieces = pattern.split("\\\\\\."); > > String patternExpr = ""; > > //the individual patternPieces will be referred to as patternPiece > for (String patternPiece : patternPieces) > { > //patternExpr is null on first go-around (bypass this logic on first > go-around) > if (patternExpr.length() > 0) > { > patternExpr += "\\."; > } > patternExpr += patternPiece; //patternExpr=patternPiece > > // Check for duplicate patterns so that there is no overlap. > //first go around will always execute logic as !existingPatterns returns > true > if (!existingPatterns.containsKey(patternExpr)) > { > > //doesnt make sense..if existingPatterns already contains patternExpr why > add it again? > //would'nt you want to leave existingPatterns HashMap alone? > existingPatterns.put(patternExpr, patternExpr); > > //Add a pattern that does not have the indexed property matching (ie. > list\[\d+\] //becomes list). > > //look for the end in the piece we have > if (patternPiece.endsWith("\\]")) > { > //doesnt make sense..you're testing patternPiece.lastIndexOf("\\[")))); > //then why compile patternExpr? > //why not take the relevant patternPiece and assign it to patternExpr > //then let the statement later in the code > this.includeProperties.add(Pattern.compile(patternExpr)); handle this? > > this.includeProperties.add(Pattern.compile(patternExpr.substring(0, > patternPiece.lastIndexOf("\\[")))); > > //enable the log so we can see this message > if (log.isDebugEnabled()) > log.debug("Adding include property > expression: " + patternExpr.substring(0, patternPiece.lastIndexOf("\\["))); > } > > //this unconditionally adds the (compiled version of) patternExpr to > includeProperties > > this.includeProperties.add(Pattern.compile(patternExpr)); > > if (log.isDebugEnabled()) > log.debug("Adding include property expression: > " + patternExpr); > } > } > } > } > } > */ > > from what i can see there is a bug with JSONResult > public void setIncludeProperties(String commaDelim) method > > ? > Martin Gainty > "Good Manners dont cost nothing" - Pink Floyd > ______________________________________________ > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le > destinataire prévu, nous te demandons avec bonté que pour satisfaire > informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie > de ceci est interdite. Ce message sert à l'information seulement et n'aura > pas n'importe quel effet légalement obligatoire. Étant donné que les email > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter > aucune responsabilité pour le contenu fourni. > > > > >> Date: Thu, 21 May 2009 22:42:27 -0400 >> Subject: Re: JSON plugin ignoring includeProperties parameter >> From: musa...@gmail.com >> To: user@struts.apache.org >> >> There is a getItems() in your action right? Does anything get generated at >> all? >> >> musachy >> >> -- >> "Hey you! Would you help me to carry the stone?" Pink Floyd >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> > > ________________________________ > Insert movie times and more without leaving Hotmail®. See how. -- "Hey you! Would you help me to carry the stone?" Pink Floyd --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org