Skip to content

Commit

Permalink
[FIX] A few minor qname checks in the custom Sirix translator.
Browse files Browse the repository at this point in the history
[ADD] Namespace filter.
  • Loading branch information
JohannesLichtenberger committed Jan 3, 2014
1 parent 98f43cf commit 6e8bff4
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 200 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (c) 2011, University of Konstanz, Distributed Systems Group
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
Expand All @@ -12,7 +12,7 @@
* * Neither the name of the University of Konstanz nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -31,8 +31,8 @@
import org.sirix.node.Kind;

/**
* <h1>AttributeAxisTest</h1>
*
* <h1>AttributeFilter</h1>
*
* <p>
* Only match ATTRIBUTE nodes.
* </p>
Expand All @@ -41,7 +41,7 @@ public class AttributeFilter extends AbstractFilter {

/**
* Default constructor.
*
*
* @param rtx
* Transaction this filter is bound to.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright (c) 2011, University of Konstanz, Distributed Systems Group
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University of Konstanz nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.sirix.axis.filter;

import org.sirix.api.NodeReadTrx;

/**
* <h1>NamespaceFilter</h1>
*
* <p>
* Only match NAMESPACE nodes.
* </p>
*/
public class NamespaceFilter extends AbstractFilter {

/**
* Default constructor.
*
* @param rtx
* Transaction this filter is bound to.
*/
public NamespaceFilter(final NodeReadTrx rtx) {
super(rtx);
}

@Override
public final boolean filter() {
return getTrx().isNamespace();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (c) 2011, University of Konstanz, Distributed Systems Group
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
Expand All @@ -12,7 +12,7 @@
* * Neither the name of the University of Konstanz nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -35,9 +35,9 @@

/**
* <h1>ValueAxisTest</h1>
*
*
* <p>
* Only match nodes of kind TEXT whoms value matches.
* Only match nodes of kind TEXT or ATTRIBUTE whoe's value matches.
* </p>
*/
public class ValueFilter extends AbstractFilter {
Expand All @@ -47,44 +47,44 @@ public class ValueFilter extends AbstractFilter {

/**
* Constructor initializing internal state.
*
* @param pRtx
*
* @param rtx
* transaction this filter is bound to
* @param pValue
* @param value
* value to find
*/
public ValueFilter(final NodeReadTrx pRtx, final byte[] pValue) {
super(pRtx);
mValue = checkNotNull(pValue);
public ValueFilter(final NodeReadTrx rtx, final byte[] value) {
super(rtx);
mValue = checkNotNull(value);
}

/**
* Constructor initializing internal state.
*
*
* @param rtx
* Transaction to bind filter to.
* @param mValue
* @param value
* Value to find.
*/
public ValueFilter(final NodeReadTrx rtx, final String mValue) {
this(rtx, TypedValue.getBytes(mValue));
public ValueFilter(final NodeReadTrx rtx, final String value) {
this(rtx, TypedValue.getBytes(value));
}

/**
* Constructor initializing internal state.
*
*
* @param rtx
* Transaction to bind filter to.
* @param mValue
* @param value
* Value to find.
*/
public ValueFilter(final NodeReadTrx rtx, final int mValue) {
this(rtx, TypedValue.getBytes(mValue));
public ValueFilter(final NodeReadTrx rtx, final int value) {
this(rtx, TypedValue.getBytes(value));
}

/**
* Constructor initializing internal state.
*
*
* @param rtx
* Transaction to bind filter to.
* @param mValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@

/**
* Key/Value page.
*
*
* @author Johannes Lichtenberger
*
*
*/
public interface KeyValuePage<K extends Comparable<? super K>, V extends Record>
extends Page {
/**
* Entry set of all nodes in the page. Changes to the set are reflected in the
* internal data structure
*
* Entry set of all nodes in the page. Changes to the set are reflected in
* the internal data structure
*
* @return an entry set
*/
Set<Entry<K, V>> entrySet();

/**
* All available records.
*
*
* @return all records
*/
Collection<V> values();

/**
* Get the unique page record identifier.
*
*
* @return page record key/identifier
*/
long getPageKey();

/**
* Get value with the specified key.
*
*
* @param key
* the key
* the key
* @return value with given key, or {@code null} if not present
*/
V getValue(K key);

/**
* Store or overwrite a single entry. The implementation must make sure if the
* key must be permitted, the value or none.
*
* Store or overwrite a single entry. The implementation must make sure if
* the key must be permitted, the value or none.
*
* @param key
* key to store
* key to store
* @param value
* value to store
* value to store
*/
void setEntry(K key, @Nonnull V value);

Expand All @@ -69,62 +69,62 @@ public interface KeyValuePage<K extends Comparable<? super K>, V extends Record>
/**
* Store or overwrite a single reference associated with a key for overlong
* entries. That is entries which are larger than a predefined threshold are
* written to OverflowPages and thus are just referenced and not deserialized
* during the deserialization of a page.
*
* written to OverflowPages and thus are just referenced and not
* deserialized during the deserialization of a page.
*
* @param key
* key to store
* key to store
* @param reference
* reference to store
* reference to store
*/
void setPageReference(K key, @Nonnull PageReference reference);

PageReference getPageReference(K key);

/**
* Create a new instance.
*
*
* @param recordPageKey
* the record page key
* the record page key
* @param pageKind
* the kind of page (in which subtree it is (NODEPAGE,
* PATHSUMMARYPAGE, TEXTVALUEPAGE, ATTRIBUTEVALUEPAGE))
* the kind of page (in which subtree it is (NODEPAGE,
* PATHSUMMARYPAGE, TEXTVALUEPAGE, ATTRIBUTEVALUEPAGE))
* @param pageReadTrx
* transaction to read pages
* transaction to read pages
* @return a new {@link KeyValuePage} instance
*/
<C extends KeyValuePage<K, V>> C newInstance(@Nonnegative long recordPageKey,
@Nonnull PageKind pageKind,
<C extends KeyValuePage<K, V>> C newInstance(
@Nonnegative long recordPageKey, @Nonnull PageKind pageKind,
@Nonnull Optional<PageReference> previousPageRef,
@Nonnull PageReadTrx pageReadTrx);

/**
* Get the {@link PageReadTrx}.
*
*
* @return page reading transaction
*/
PageReadTrx getPageReadTrx();

/**
* Get the page kind.
*
*
* @return page kind
*/
PageKind getPageKind();

/**
* Get the number of entries/slots/page references filled.
*
*
* @return number of entries/slots/page references filled
*/
int size();

/**
* Get the optional {@link PageReference} pointing to the previous version of
* the page
*
* @return optional {@link PageReference} pointing to the previous version of
* the page
* Get the optional {@link PageReference} pointing to the previous version
* of the page
*
* @return optional {@link PageReference} pointing to the previous version
* of the page
*/
Optional<PageReference> getPreviousReference();
}
Loading

0 comments on commit 6e8bff4

Please sign in to comment.