On Fri, Feb 11, 2011 at 00:10, Marius Dumitru Florea
<[email protected]> wrote:
> On 02/10/2011 07:27 PM, Thomas Mortagne wrote:
>> Here is a proposal to reduce all get...Block to 2 methods which
>> support matching any Block.
>>
>> interface Block
>> {
>>    enum TraversalStrategy
>>    {
>>      /** Search in parents **/
>>      PARENT,
>>      /** Search in children **/
>>      CHILD,
>>      /** Search recursively in children (and children of children etc...) **/
>>      CHILDRECURSE,
>>      /** Search in previous siblings **/
>>      PREVIOUS,
>>      /** Search recursively in previous siblings (and parent previous
>> sibling etc...) **/
>>      PREVIOUSRECURSE,
>>      /** Search in next siblings**/
>>      NEXT,
>>      /** Search recursively in next siblings (and children etc...)**/
>>      NEXTRECURSE
>>    }
>>
>>    [...]
>>
>>    List<Block>  getBlocks(BlockMatcher matcher, TraversalStrategy
>> traversalStrategy, boolean recurse);
>>
>>    Block getFirstBlock(BlockMatcher matcher, TraversalStrategy
>> traversalStrategy, boolean recurse);
>> }
>>
>> interface BlockMatcher
>> {
>>      boolean match(Block block);
>> }
>>
>> et on refactor tous les autres get*Block basé sur ceux la avec des
>> BlockMatcher prédéfinis (ClassBlockMatcher, MetaDataBlockMatcher,
>> etc...).
>>
>> Note: the main use case for this change is to support MetaData search.
>>
>> WDYT (especially on the vocabulary like "TraversalStrategy") ?
>
> Have you considered replacing get...Block methods with Block iterators?

Yep, the most generic method is not method ;)

Thing is I don't have the time to define and validate something that
is a whole new concept so I'm proposing what I have the time to do but
still let me sleep at night :)

>
> Iterator<Block> iterator = new MetaDataIterator(new
> ChildrenIterator(parent));
>
> Hope this helps,
> Marius
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>



-- 
Thomas Mortagne
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to