1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.mavibot.btree; 21 22 23 import java.util.List; 24 25 26 /** 27 * The result of an insert operation, when the child has not been split. It contains the 28 * reference to the modified page. 29 * 30 * @param <K> The type for the Key 31 * @param <V> The type for the stored value 32 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 /* No qualifier*/class ModifyResult<K, V> extends AbstractResult<K, V> implements InsertResult<K, V> 36 { 37 /** The modified page reference */ 38 protected Page<K, V> modifiedPage; 39 40 /** The modified value if the key was found in the tree*/ 41 protected V modifiedValue; 42 43 44 /** 45 * The default constructor for ModifyResult. 46 * 47 * @param modifiedPage The modified page 48 * @param modifiedvalue The modified value (can be null if the key wasn't present in the tree) 49 */ 50 public ModifyResult( Page<K, V> modifiedPage, V modifiedValue ) 51 { 52 super(); 53 this.modifiedPage = modifiedPage; 54 this.modifiedValue = modifiedValue; 55 } 56 57 58 /** 59 * A constructor for ModifyResult which takes a list of copied pages. 60 * 61 * @param copiedPages the list of copied pages 62 * @param modifiedPage The modified page 63 * @param modifiedvalue The modified value (can be null if the key wasn't present in the tree) 64 */ 65 public ModifyResult( List<Page<K, V>> copiedPages, Page<K, V> modifiedPage, V modifiedValue ) 66 { 67 super( copiedPages ); 68 this.modifiedPage = modifiedPage; 69 this.modifiedValue = modifiedValue; 70 } 71 72 73 /** 74 * @return the modifiedPage 75 */ 76 public Page<K, V> getModifiedPage() 77 { 78 return modifiedPage; 79 } 80 81 82 /** 83 * Set the modified page 84 * @param modifiedPage The new modified page 85 */ 86 public void setModifiedPage( Page<K, V> modifiedPage ) 87 { 88 this.modifiedPage = modifiedPage; 89 } 90 91 92 /** 93 * @return the modifiedValue 94 */ 95 public V getModifiedValue() 96 { 97 return modifiedValue; 98 } 99 100 101 /** 102 * @see Object#toString() 103 */ 104 public String toString() 105 { 106 StringBuilder sb = new StringBuilder(); 107 108 sb.append( "ModifyResult, old value = " ).append( modifiedValue ); 109 sb.append( ", modifiedPage = " ).append( modifiedPage ); 110 sb.append( super.toString() ); 111 112 return sb.toString(); 113 } 114 }