         self.t2icache = LRUCache(capacity: 64)
     }
     
-    private static func idRange(for type: UInt8) -> Range<UInt64> {
+    internal class func isIRI(id: Result) -> Bool {
+        let typebyte = UInt8(UInt64(id) >> 56)
+        return typebyte == iriTypeByte
+    }
+    
+    internal class func isBlank(id: Result) -> Bool {
+        let typebyte = UInt8(UInt64(id) >> 56)
+        return typebyte == blankTypeByte
+    }
+    
+    internal class func isLanguageLiteral(id: Result) -> Bool {
+        let typebyte = UInt8(UInt64(id) >> 56)
+        return typebyte == languageTypeByte
+    }
+    
+    internal class func isDatatypeLiteral(id: Result) -> Bool {
+        let typebyte = UInt8(UInt64(id) >> 56)
+        return typebyte == datatypeTypeByte
+    }
+    
+    private static func idRange(for type: UInt8) -> Range<Result> {
         let min = (UInt64(type) << 56)
         let max = (UInt64(type+1) << 56)
         return min..<max

public class QuadStore : Sequence, QuadStoreProtocol {
    typealias IDType = UInt64
    static let defaultIndex = "pogs"
    private var mediator : RMediator
    public var id : PersistentTermIdentityMap
    public init(mediator : RMediator) throws {
        self.mediator = mediator
        var readonly = true
        if let _ = mediator as? RWMediator {
            readonly = false
        }
        self.id = try PersistentTermIdentityMap(mediator: mediator, readonly: readonly)
    }
    

        return AnyIterator {
            repeat {
                guard let idquad = i.next() else { return nil }
                let oid = idquad[3]
                let languageQuad = PersistentTermIdentityMap.isLanguageLiteral(id: oid)
                if languageQuad {
                    return idquad
                } else {
                    guard let quad = self.quad(from: idquad) else { return nil }
                    if self.accept(quad: quad, languages: self.acceptLanguages) {
                        return idquad
                    }
                }
            } while true
        }
