| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| Section Maps |
| |
| <p> |
| Config sections can be retrieved in-bulk using |
| {@link oaj.config.Config#getSectionAsMap(String)}. |
| </p> |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <jc>// Example config file</jc> |
| <cs>[MyAddress]</cs> |
| <ck>street</ck> = <cv>123 Main Street</cv> |
| <ck>city</ck> = <cv>Anywhere</cv> |
| <ck>state</ck> = <cv>NY</cv> |
| <ck>zip</ck> = <cv>12345</cv> |
| </p> |
| <p class='bpcode w800'> |
| <jc>// Example usage</jc> |
| Config c = Config.<jsm>create</jsm>(<js>"MyConfig.cfg"</js>).build(); |
| |
| ObjectMap m = c.getSectionAsMap(<js>"MyAddress"</js>); |
| |
| String street = m.getString(<js>"street"</js>); |
| String city = m.getString(<js>"city"</js>); |
| String state = m.getString(<js>"state"</js>); |
| <jk>int</jk> zip = m.getInt(<js>"zip"</js>); |
| </p> |
| <p> |
| Maps created this way are snapshot copies of the section at the time of the method call. |
| </p> |