100% found this document useful (1 vote)
15 views

Groovy Programming An Introduction for Java Developers 1st Edition Kenneth Barclay instant download

The document provides information on various programming books, including 'Groovy Programming: An Introduction for Java Developers' by Kenneth Barclay, and other related titles. It includes links for instant digital downloads in multiple formats. Additionally, it outlines the contents of the Groovy programming book, covering topics such as numbers, strings, lists, methods, and case studies.

Uploaded by

tumbuldoraly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
15 views

Groovy Programming An Introduction for Java Developers 1st Edition Kenneth Barclay instant download

The document provides information on various programming books, including 'Groovy Programming: An Introduction for Java Developers' by Kenneth Barclay, and other related titles. It includes links for instant digital downloads in multiple formats. Additionally, it outlines the contents of the Groovy programming book, covering topics such as numbers, strings, lists, methods, and case studies.

Uploaded by

tumbuldoraly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Groovy Programming An Introduction for Java

Developers 1st Edition Kenneth Barclay pdf


download

https://ebookname.com/product/groovy-programming-an-introduction-
for-java-developers-1st-edition-kenneth-barclay/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Programming Groovy Dynamic Productivity for the Java


Developer 1st Edition Venkat Subramaniam

https://ebookname.com/product/programming-groovy-dynamic-
productivity-for-the-java-developer-1st-edition-venkat-
subramaniam/

Programming Groovy 2 Dynamic Productivity for the Java


Developer 2nd Edition Venkat Subramaniam

https://ebookname.com/product/programming-groovy-2-dynamic-
productivity-for-the-java-developer-2nd-edition-venkat-
subramaniam/

Java An Introduction to Problem Solving and Programming


6th Edition Walter Savitch

https://ebookname.com/product/java-an-introduction-to-problem-
solving-and-programming-6th-edition-walter-savitch/

Ethics in Engineering Practice and Research 2nd Edition


Caroline Whitbeck

https://ebookname.com/product/ethics-in-engineering-practice-and-
research-2nd-edition-caroline-whitbeck/
Epidemics and Enslavement Biological Catastrophe in the
Native Southeast 1492 1715 Indians of the Southeast
Paul Kelton

https://ebookname.com/product/epidemics-and-enslavement-
biological-catastrophe-in-the-native-southeast-1492-1715-indians-
of-the-southeast-paul-kelton/

Great Land Rush and the Making of the Modern World 1650
1900 1st Edition John C. Weaver

https://ebookname.com/product/great-land-rush-and-the-making-of-
the-modern-world-1650-1900-1st-edition-john-c-weaver/

Track field 1. print. Edition Gabrielle Vanderhoof

https://ebookname.com/product/track-field-1-print-edition-
gabrielle-vanderhoof/

European Union Law for International Business 1st


Edition Bernard Bishop

https://ebookname.com/product/european-union-law-for-
international-business-1st-edition-bernard-bishop/

Systems Biology and Livestock Science 1st Edition


Marinus Te Pas

https://ebookname.com/product/systems-biology-and-livestock-
science-1st-edition-marinus-te-pas/
The Mongols and the Islamic World From Conquest to
Conversion 1st Edition Peter Jackson

https://ebookname.com/product/the-mongols-and-the-islamic-world-
from-conquest-to-conversion-1st-edition-peter-jackson/
Barclay FM.qxd 6/11/06 1:50 PM Page 1

groovy programming
This page intentionally left blank
Barclay FM.qxd 6/11/06 1:50 PM Page 3

groovy programming
an introduction for
java developers

Kenneth Barclay
John Savage

AMSTERDAM • BOSTON • HEIDELBERG • LONDON


NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Morgan Kaufmann Publishers is an imprint of Elsevier
Barclay FM.qxd 6/11/06 1:50 PM Page 4

Publisher Denise E. M. Penrose


Publishing Services Manager George Morrison
Senior Editor Tim Cox
Assistant Editor Mary E. James
Project Manager Marilyn E. Rash
Cover Design Chen Design
Composition and Illustrations SPi
Production Services SPi
Interior printer Maple-Vail Book Manufacturing Group
Cover printer Phoenix Color Corp.
Morgan Kaufmann Publishers is an imprint of Elsevier.
500 Sansome Street, Suite 400, San Francisco, CA 94111
This book is printed on acid-free paper.
© 2007 by Elsevier Inc. All rights reserved.
Designations used by companies to distinguish their products are often claimed as trademarks or registered trade-
marks. In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in
initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete
information regarding trademarks and registration.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any
means—electronic, mechanical, photocopying, scanning, or otherwise—without prior written permission of the
publisher.
Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK:
phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: permissions@elsevier.com. You may also complete
your request online via the Elsevier homepage (http://elsevier.com), by selecting “Support & Contact” then
“Copyright and Permission” and then “Obtaining Permissions.”
Library of Congress Cataloging-in-Publication Data
Barclay, Kenneth A., 1947-
Groovy programming : an introduction for Java developers /
Kenneth Barclay, John Savage.
p. cm.
Includes bibliographical references and index.
ISBN-13: 978-0-12-372507-3 (alk. paper)
ISBN-10: 0-12-372507-0 (alk. paper)
1. Java (Computer program language) I. Savage, W. J. (W. John) II. Title.
QA76.73.J38B358 2006
005. 13'3–dc22 2006036352
For information on all Morgan Kaufmann publications,
visit our Web site at www.mkp.com or www.books.elsevier.com
Printed in the United States of America
07 08 09 10 5 4 3 2 1
Barclay FM.qxd 6/11/06 1:50 PM Page 5

To Irene
–K.B.

To Salwa
–J.S.
This page intentionally left blank
Barclay FM.qxd 6/11/06 1:50 PM Page 7

contents
Foreword xiv
Preface xvi
About the Authors xix

1 Groovy 1
1.1 Why Scripting? 1
1.2 Why Groovy? 3
2 Numbers and Expressions 5
2.1 Numbers 6
2.2 Expressions 6
2.3 Operator Precedence 8
2.4 Assignment 9
2.5 Increment and Decrement Operators 10
2.6 Object References 11
2.7 Relational and Equality Operators 12
2.8 Exercises 14
3 Strings and Regular Expressions 17
3.1 String Literals 17
3.2 String Indexing and Slicing 18
3.3 Basic Operations 19
3.4 String Methods 19
3.5 String Comparison 23
3.6 Regular Expressions 23
3.7 Exercises 25

vii
Barclay FM.qxd 6/11/06 1:50 PM Page 8

viii Contents

4 Lists, Maps, and Ranges 27


4.1 Lists 27
4.2 List Methods 29
4.3 Maps 31
4.4 Map Methods 33
4.5 Ranges 34
4.6 Exercises 35
5 Simple Input and Output 39
5.1 Simple Output 39
5.2 Formatted Output 41
5.3 Simple Input 42
5.4 Exercises 45
6 Case Study: A Library Application (Modeling) 47
6.1 Iteration 1: Specification and List Implementation 47
6.2 Iteration 2: Map Implementation 50
6.3 Exercises 52
7 Methods 53
7.1 Methods 53
7.2 Method Parameters 56
7.3 Default Parameters 56
7.4 Method Return Values 57
7.5 Parameter Passing 59
7.6 Scope 61
7.7 Collections as Method Parameters and Return Values 62
7.8 Exercises 63
8 Flow of Control 67
8.1 While Statement 67
8.2 For Statement 69
8.3 If Statement 71
8.4 Switch Statement 74
8.5 Break Statement 78
8.6 Continue Statement 79
8.7 Exercises 80
9 Closures 85
9.1 Closures 85
9.2 Closures, Collections, and Strings 90
9.3 Other Closure Features 96
9.4 Exercises 100
Barclay FM.qxd 6/11/06 1:50 PM Page 9

Contents ix
10 Files 103
10.1 Command Line Arguments 103
10.2 File Class 104
10.3 Exercises 111
11 Case Study: A Library Application (Methods,
Closures) 113
11.1 Iteration 1: Specification and Map Implementation 113
11.2 Iteration 2: Implementation of a Text-Based User Interface 119
11.3 Iteration 3: Implementation with Closures 122
11.4 Exercises 125
12 Classes 127
12.1 Classes 127
12.2 Composition 135
12.3 Exercises 137
13 Case Study: A Library Application (Objects) 139
13.1 Specification 139
13.2 Iteration 1: An Initial Model 140
13.3 Iteration 2: Augment the Model 142
13.4 Iteration 3: Reinstate the User Interface 147
13.5 Exercises 153
14 Inheritance 157
14.1 Inheritance 157
14.2 Inherited Methods 160
14.3 Redefined Methods 162
14.4 Polymorphism 163
14.5 The Abstract Class 166
14.6 The Interface Class 169
14.7 Exercises 173
15 Unit Testing ( JUnit) 179
15.1 Unit Testing 179
15.2 The GroovyTestCase and JUnit TestCase Classes 181
15.3 The GroovyTestSuite and JUnit TestSuite Classes 186
15.4 The Role of Unit Testing 189
15.5 Exercises 193
Barclay FM.qxd 6/11/06 1:50 PM Page 10

x Contents

16 Case Study: A Library Application


(Inheritance) 195
16.1 Specification 195
16.2 Iteration 1: Confirm the Polymorphic Effect 196
16.3 Iteration 2: Demonstrate the Required Functionality 199
16.4 Iteration 3: Provide User Feedback 204
16.5 Iteration 4: Enforce Constraints 212
16.6 Exercises 217
17 Persistence 219
17.1 Simple Queries 219
17.2 Relations 221
17.3 Database Updates 224
17.4 Objects from Tables 228
17.5 Inheritance 230
17.6 The Spring Framework 232
17.7 Exercises 237
18 Case Study: A Library Application
(Persistence) 239
18.1 Iteration 1: Persist the Domain Model 239
18.2 Iteration 2: The Impact of Persistence 251
18.3 Exercises 258
19 XML Builders and Parsers 259
19.1 Groovy Markup 259
19.2 MarkupBuilder 261
19.3 XML Parsing 264
19.4 Exercises 276
20 GUI Builders 277
20.1 SwingBuilder 277
20.2 Lists and Tables 286
20.3 Box and BoxLayout Classes 292
20.4 Exercises 294
21 Template Engines 297
21.1 Strings 297
21.2 Templates 298
21.3 Exercises 302
Barclay FM.qxd 6/11/06 1:50 PM Page 11

Contents xi
22 Case Study: A Library Application (GUI) 303
22.1 Iteration 1: Prototype the GUI 303
22.2 Iteration 2: Implement the Handlers 306
22.3 Exercises 313
23 Server-Side Programming 315
23.1 Servlets 315
23.2 Groovlets 316
23.3 GSP Pages 324
23.4 Exercises 328
24 Case Study: A Library Application (Web) 329
24.1 Iteration 1: Web Implementation 329
24.2 Exercise 333
25 Epilogue 335

Appendices
A Software Distribution 337
A.1 The Java Development Kit 337
A.2 The Groovy Development Kit 338
A.3 Ant 338
A.4 The Derby/Cloudscape Database 338
A.5 The Spring Framework 339
A.6 The Tomcat Server 339
A.7 Eclipse IDE 339
A.8 The Textbook Sources 339
B Groovy 341
B.1 Simple and Elegant 341
B.2 Methods 343
B.3 Lists 344
B.4 Classes 344
B.5 Polymorphism 345
B.6 Closures 346
B.7 Exceptions 347
C More on Numbers and Expressions 349
C.1 Classes 349
C.2 Expressions 350
C.3 Operator Associativity 350
Barclay FM.qxd 6/11/06 1:50 PM Page 12

xii Contents

C.4 Variable Definitions 351


C.5 Compound Assignment Operators 353
C.6 Logical Operators 353
C.7 Conditional Operator 354
C.8 Qualified Numerical Literals 355
C.9 Conversions 355
C.10 Static Typing 358
C.11 Testing 358
D More on Strings and Regular Expressions 361
D.1 Regular Expressions 361
D.2 Single Character Match 362
D.3 Match at the Beginning 363
D.4 Match at the End 363
D.5 Match Zero or More 363
D.6 Match One or More 364
D.7 Match None or One 364
D.8 Match Number 364
D.9 Character Classes 365
D.10 Alternation 366
D.11 Miscellaneous Notations 366
D.12 Grouping 367
E More on Lists, Maps, and Ranges 369
E.1 Classes 370
E.2 Lists 371
E.3 Ranges 372
E.4 The Spread Operator 372
E.5 Testing 373
F More on Simple Input and Output 376
F.1 Formatted Output 376
F.2 Console Class 379
G More on Methods 382
G.1 Recursive Methods 382
G.2 Static Typing 384
G.3 Actual Parameter Agreement 386
G.4 Method Overloading 387
G.5 Default Parameter Ambiguity 387
G.6 Collections as Method Parameters and Return Values 389
Barclay FM.qxd 6/11/06 1:50 PM Page 13

Contents xiii
H More on Closures 393
H.1 Closures and Ambiguity 393
H.2 Closures and Methods 394
H.3 Default Parameters 395
H.4 Closures and Scope 395
H.5 Recursive Closures 396
H.6 Static Typing 397
H.7 Actual Parameter Agreement 398
H.8 Closures, Collections, and Ranges 398
H.9 Return Statement 400
H.10 Testing 401
I More on Classes 404
I.1 Properties and Visibility 404
I.2 Object Navigation 409
I.3 Static Members 413
I.4 Operator Overloading 415
I.5 The invokeMethod 417
I.6 Exercises 419
J Advanced Closures 420
J.1 Simple Closures 421
J.2 Partial Application 423
J.3 Composition 425
J.4 Patterns of Computation 426
J.5 Business Rules 428
J.6 Packaging 432
J.7 List Reduction 439
J.8 Exercises 441
K More on Builders 445
K.1 AntBuilder 445
K.2 Specialized Builders 453
L More on GUI Builders 458
L.1 Menus and Toolbars 458
L.2 Dialogs 465
Bibliography 469
Index 471
Barclay FM.qxd 6/11/06 1:50 PM Page 14

foreword
Scripting languages are not new. Primarily, they are used on Linux and
UNIX machines for things such as shell scripting tasks that automate soft-
ware installations, platform customizations, scientific application prototyp-
ing with Python, and one-shot command-line jobs with bash scripts.
Languages such as PHP have also been widely used for developing high-
volume websites and scripting languages have been found to be suitable for
serious business applications.
Usually, scripting languages are platforms on their own and do not nec-
essarily interact with others. Although bindings may exist for bridging with
other systems, the integration is not always intuitive or natural. Groovy seeks
to fill that gap, bringing a genuine innovative language that can interact
natively with Java by living on the same virtual machine.
Groovy brings a concise and expressive Java-like syntax to ease the learn-
ing curve for Java developers. But beyond the syntax, Groovy also provides
two key aspects to the landscape by providing wrapper APIs around common
JDK Application Programming Interfaces. It simplifies the implementation
of common tasks and integrates meta-programming capabilities to develop
powerful new language constructs or to easily manipulate existing ones.
Groovy can be used in various situations: as a shell scripting language to
do data crunching and file manipulation tasks or to experiment with new
APIs. It can also be adapted for creating full-blown small- to mid-size appli-
cations to leverage the wealth of Java libraries and components. Moreover,
another important use is to marry Java and Groovy by embedding Groovy
inside Java or Java EE applications. This can help write and externalize
often-changing business rules or bring programmatic configuration to an
application infrastructure.
Although the first two uses are quite common, I believe the embedded-
use case is the most appealing and promising. Currently, developers have
been using template engines for customizing and factoring out views, or they
have used business rules engines to externalize some logic. Beyond the

xiv
Barclay FM.qxd 6/11/06 1:50 PM Page 15

Foreword xv
limited functionality set, however, programmers are often given little
support. Fortunately, platform-hosted scripting languages such as Groovy
can help bridge this functionality gap. This is evident with the success of
Groovy and its child—Grails—a versatile model-view-controller (MVC)
Web framework. Sun, too, believes in this alternative way of adding dynam-
icity to applications, by including a new Java Specification Request in Java 6:
the javax.script.* APIs allow seamless embedding of any scripting or
dynamic language into Java applications with a coherent programming API.
Scripting languages have evolved to a point of maturity where they meet
the limitations of the standardized mainstream platforms. When those lan-
guages and platforms come across, that’s when magic happens, and we can
celebrate a marriage made in Heaven.
Ken Barclay and John Savage are respected teachers and are well posi-
tioned to introduce Groovy to both experienced developers and novices.
They demonstrate in a clear manner how Groovy augments the Java plat-
form and how to exploit many of its innovative features. The book is easy to
read and not intimidating for those less experienced with programming. It
is a complete exposition of Groovy that addresses all aspects of the pro-
gramming language.
The structure of the book fulfills this aim by presenting the basics of
Groovy in the early chapters and more advanced concepts in the latter. In
addition, extensive appendices consider more detailed aspects of the lan-
guage.
Deliberately, each chapter is relatively small and easy to absorb, yet they
contain a large number of complete code examples, extensive exercises, and
solutions. To illustrate Groovy in application, the book features a rolling case
study that grows in complexity and sophistication by drawing on the mate-
rials from each preceding chapter. In addition, incremental development
and unit testing are central themes in the text and are necessary to support
Groovy’s dynamic nature. The authors also consider Groovy as a multipara-
digm language.
The authors’ own experience suggests that Groovy has a place in the aca-
demic curriculum as well as the experienced developer’s toolbox.
Have a fun time learning Groovy by reading this great book! You won’t
regret it.

Guillaume Laforge
Groovy Project Manager
JSR-241 Specification Lead
Barclay FM.qxd 6/11/06 1:50 PM Page 16

preface
This book is an introduction to the scripting language Groovy. For Java
developers, Groovy makes writing scripts and applications for the Java plat-
form both fast and easy. It includes many language features found in other
scripting languages such as Python, Ruby, and Smalltalk. As Groovy is based
on Java, applications written in Groovy can make full use of the Java
Application Programming Interfaces (APIs). This means that Groovy inte-
grates seamlessly with frameworks and components written in Java.
Groovy, the scripting language, and Java, the systems programming
language, complement each other. Both contribute to the development of
programming applications. For example, components and frameworks
might be created with Java and “glued” together with Groovy. The ease with
which Groovy can make use of them significantly enhances their usage. The
increasing importance of component architectures, Graphical User
Interfaces (GUIs), database access, and the internet all increase the applica-
bility of scripting in Groovy.
Groovy developers can take advantage of rapid application development
features, such as those found in scripting languages. Groovy is suitable for
many data or file processing tasks, testing applications, or as a replacement
for Java in small- and medium-sized projects.
The syntax of Groovy is similar to the syntax of the Java programming
language. This makes for a relatively short learning curve for Java develop-
ers. Other scripting languages for the Java platform are usually based on ear-
lier predecessors. This is a major problem as they bring extra unwanted
“baggage.” However, as Groovy is Java, it offers a much more natural and
seamless integration into the Java platform.

xvi
Barclay FM.qxd 6/11/06 1:50 PM Page 17

Preface xvii

organiz ation
The text is designed to quickly introduce readers to the principal elements
of the Groovy language. It assumes at least a reading knowledge of Java. For
the later chapters, experience with Swing, Standard Query Language (SQL),
Spring, XML, Ant, and building Web applications would also be useful. The
authors have sought to keep each chapter relatively brief and closely focused.
Some readers may wish to dip into an individual chapter to pick out partic-
ular Groovy features. In any event, the shortness of each chapter should
make its contents relatively easy to absorb.
Many chapters are supported by an appendix to augment the topics cov-
ered. For example, Chapter 7 considers the basics of defining and using
Groovy methods. Appendix G then considers more advanced aspects, such
as overloading and recursion, which are not central to the main text. Again,
this helps to keep chapters short and targeted.
Most chapters also include many small, self-contained examples to illus-
trate language concepts. They are complete, and the reader is encouraged to
execute them as part of the learning process. There are also end-of-chapter
exercises, and the reader is encouraged to attempt them. However, both the
chapter examples and the solutions to the exercises are available on the
book’s website.
A feature of the book is a rolling case study concerned with managing
and maintaining a library’s loan stock. At various points in the text, new
Groovy features are applied to augment the functionality of the case study.
For example, the case study in Chapter 11 exploits methods, closures, and
files introduced in the preceding chapters.
Chapters 1 to 16 cover the basic features of Groovy. For example, there
are discussions of Groovy methods, closures, lists, and maps as well as
support for classes and inheritance.
The important topic of automated unit testing is also addressed.
Groovy’s rapid build-and-run cycle makes it an ideal candidate for develop-
ing unit tests. Groovy exploits the industry standard JUnit framework to
make unit testing both easy and fun. Unit testing used in conjunction with
Groovy combines the flexibility of a dynamically typed language with the
safety offered by statically typed languages. To highlight this point, unit test-
ing is an integral part of most of the case studies.
The second part of the book is presented in Chapters 17 to 24, where
Groovy is used for more advanced applications. For example, persistence is
implemented with the Spring framework in conjunction with the
Cloudscape/Derby relational database management system. Groovy also
supports XML and GUI applications through its novel builder notation. We
finish by considering templates and web applications.
Barclay FM.qxd 6/11/06 1:50 PM Page 18

xviii Preface

conventions
Throughout the book we use an arial typeface to identify Groovy code and
the output from scripts. We also italicize text when introducing a technical
term. The book includes references to websites and to the bibliography.
We do not distinguish between a program and a script. Both terms are
used interchangeably. However, we invariably mean a Groovy script.

soft ware distribution


The authors have prepared a supporting website—http://www.dcs.
napier.ac.uk/~kab/groovy/groovy.html—that contains the working scripts
for all of the examples and case studies presented in the book. Answers to
the end-of-chapter exercises are also included.
Groovy is under constant review and is subject to revision. It is the aim
of the authors to use this website to keep the reader informed of significant
changes. Therefore, the reader is advised to consult it for up-to-date infor-
mation.

acknowledgments
The authors are deeply grateful to those involved in Groovy’s conception,
the committers that maintain its development, and those instrumental in
the Java Specification Request (JSR-241) initiative (http://www.dcs.
napier.ac.uk/~cs05/groovy/groovy.html). This book is our contribution to
publicizing the Groovy language. We are indebted to Guillaume Laforge
(Groovy Project Manager) who keeps Groovy “on-track” and to Andrew
Glover (CTO, Vanward Technologies) for his excellent articles on Groovy on
the IBM Developers website. We are also grateful for the encouragement
and stimulation given by Professor Jon Kerridge (School of Computing,
Napier University, Edinburgh) who sent us Groovy challenges that we might
not otherwise have taken up.
The authors also wish to thank Denise Penrose, Tim Cox, Mary James,
Christine Brandt, and their colleagues at Morgan Kaufmann, Elsevier for
their help in the production of this book. Finally, we are grateful for the many
helpful suggestions from our reviewers Andrew Glover and Sean Burke. Any
outstanding errors in the text are the responsibility of the authors.
Barclay FM.qxd 6/11/06 1:50 PM Page 19

about the authors


Ken Barclay and John Savage are lecturers in computer science at Napier
University in Edinburgh, Scotland. They both have more than 25 years of
experience teaching software development to students and professionals in
commerce and industry. They have been actively involved with the evolution
and development of object-oriented practices in C++, Java, Ada, and the
Unified Modeling Language (UML).
Since their first involvement with object orientation, they have led the
development of the ROME project—an object modeling tool—that is dis-
tributed with their books on object orientation and the UML. They are the
authors of several publications about software development, including
Object-Oriented Design with UML and Java (Butterworth-Heinemann/
Elsevier, 2003).

xix
This page intentionally left blank
Barclay chap01.qxd 02/01/1904 9:51 PM Page 1

1
CHAPTER

groovy

This first chapter introduces Groovy as a unique scripting language designed to


augment the Java platform. It offers Javalike syntax, native support for Maps and
Lists, methods, classes, closures, and builders. With its dynamic weak typing
and seamless access to the Java Applications Programming Interface (API), it is
well suited to the development of many small- to medium-sized applications.

1.1 why scripting?


Generally, scripting languages such as Groovy are more expressive and operate at
higher levels of abstraction than systems programming languages such as Java. This
often results in more rapid application development and higher programmer
productivity. However, scripting languages serve a different purpose than their sys-
tems language counterparts. They are designed for “gluing” applications together
rather than implementing complex data structures and algorithms. Therefore, to be
useful, a scripting language must have access to a wide range of components.
In general, scripting languages do not replace systems programming
languages. They complement them (Ousterhout, 1998). Typically, systems
programming languages should be used in applications that

● require the development of complex algorithms or data structures


● are computationally intensive
● manipulate large datasets
● implement well-defined, slowly changing requirements
● are part of a large project.

1
Barclay chap01.qxd 02/01/1904 9:51 PM Page 2

2 CHAPTER 1 Groovy

However, scripting languages should be used for applications that

● connect preexisting components


● manipulate a variety of different entities that change rapidly
● have a graphical user interface
● have rapidly evolving functionality
● are part of a small- to medium-sized project.

A major strength of scripting languages is that the coding effort they require is
relatively small as compared to code written in a systems programming
language. Often, the latter appears to be overly complex and difficult to
understand and maintain. This is because it requires extensive boilerplate or
conversion code.
These systems languages are strongly typed to ensure the safety and robust-
ness of the code. With strong typing, variables must been given a type and they
can only be used in a particular way. Although strong typing makes large pro-
grams more manageable and allows a compiler to (statically) detect certain kinds
of errors, it can be intrusive. For example, strong typing is not helpful when it
is difficult or impossible to decide beforehand which type of a variable it is. This
situation occurs frequently when connecting components together.
To simplify the task of connecting components, scripting languages are
weakly typed. This means that variables can be used in different ways under
different circumstances. However, illegal use of variables is only detected when
the code is actually executing. For example, although Groovy (statically) checks
program syntax at compile time, the (dynamic) check on the correctness
of method calls happens at runtime. As a result, there is the danger that a
Groovy script that compiles cleanly may throw an exception and terminate
prematurely.
Weak typing does not necessarily mean that code is unsafe or that it is not
robust. Advocates have promoted Extreme Programming (Beck, 2004) as a soft-
ware development process. This approach is characterized by an emphasis on
testing. The result is a comprehensive suite of unit tests (Link, 2003) that drive
the development. As a consequence, they help ensure the safety and robustness
of the code by executing it in a wide variety of different scenarios. This is the basis
of the approach we take when developing Groovy scripts. In fact, experience has
shown that the combination of weak typing and unit testing in a scripting lan-
guage is often better than strong type checking in a traditional systems
programming language (see http://www.mindview.net/WebLog/log-0025). We
have both the flexibility of weak typing and the confidence of unit testing.
Barclay chap01.qxd 02/01/1904 9:51 PM Page 3

1.2 why groovy? 3

1.2 why groovy?


The Java compiler produces bytecodes that execute on the Java Virtual Machine
(JVM). Groovy classes are binary compatible with Java. This means that the
bytecodes produced by the Groovy compiler are the same as those produced by
the Java compiler. Hence, Groovy is Java as far as the JVM is concerned. This
means that Groovy is able to immediately exploit the various Java APIs such as
JDBC for database development (Fisher et al., 2003) and Swing for developing
GUI applications (Topley, 1998).
Groovy aims to shift much of the “heavy lifting” from the developer to the
language itself. For example, when adding a button to a GUI, we simply specify
the code to execute when the button is pressed. There is no need to add an event
handler to the button as an instance of a class implementing a particular
interface. Groovy does this for us.
Groovy is an object-oriented scripting language in which everything is an
object. Unlike Java, there are no exceptions to this rule. This brings an important
element of uniformity to the language. Groovy is also dynamically typed so that
the notion of a type lies within the object, not the variable that references it. An
immediate consequence is that Groovy does not require the declaration of the
type of a variable, method parameter, or method return value. This gives it the
beneficial effects of significantly shrinking the code size and giving the program-
mer the freedom to defer type decisions to runtime.
Groovy also seeks to unify instance fields and methods declared in classes
by supporting the concept of a property. A property removes the distinction
between an instance field (attribute) and a method. In effect, a client considers
a property as the combination of the instance field and its getter/setter methods.
Important data structures, Lists and Maps, are native to the Groovy language.
A List object or a Map object can be directly expressed in a Groovy script. For
novice developers and professionals alike, the immediacy of Lists and Maps can
make their programming tasks that much simpler. Complementing Lists and
Maps are iterator methods, such as each, that simplify how the elements in these
collections are to be processed. The processing itself is described by a closure—an
object that represents a code block. This immensely useful construct can be
referenced by variables, parameterized to generalize its applicability, passed as a
parameter to methods and other closures, and can be an instance field of classes.
It has a huge effect on programming in Groovy.
Hierarchical data structures like XML can also be directly represented in a
Groovy script with Groovy builders. Using notations found in XPath (see
http://www.w3.org/TR/xpath20/), Groovy readily expresses the traversal of these
structures and how to reference their parts. Once again, an iterator and a clo-
sure provide the mechanism to process them.
Barclay chap01.qxd 02/01/1904 9:51 PM Page 4

4 CHAPTER 1 Groovy

Groovy builders are generally applicable to any nested tree-structure. For


example, they can be used to describe a graphical application that is assembled
from various component widgets. Here, too, closures play a part, this time
operating as event handlers for components such as menu items and buttons.
Standard Query Language (SQL) processing also has the same uniform
approach. Again, an iterator method such as eachRow combines with a closure
to express how to process the rows of a database table.
Another Random Document on
Scribd Without Any Related Topics
a Tewa clan called Okuwuñ (Cloud) which corresponds, so far as meaning goes, with the
Patki clan of the Hopi. Whether this clan brought with it a knowledge of the Great Snake
is not clear, as traditions are silent on that point.
There is a tradition in the Okuwuñ clan that their ancestors, like those of the Patki, came
from the south, and that the Nañ-towa bears a like relationship to the Okuwuñ that the
Hopi Tuwa clan does to the Patki.[42] If this tradition is well founded, a knowledge of the
Great Snake fetish of the two Hano kivas may have been brought by the Okuwuñ and
Nañ-towa into Tusayan from the same place as that of Palülükoñ.
The Kwakwantu society of the Patki clans among the Hopi are intimately connected with
this Great Plumed or Horned Snake cult. In some parts of the New-fire ceremony, in
which this society takes a prominent part, each member of the society carries in his hand
a small wooden image of a horned snake. These images are called moñkohus, some of
the typical forms of which are figured in an article on the Naacnaiya.[43] The head of the
snake and its horn are well represented in several of these wooden effigies.

Conclusions
The special interest attached to the Winter Solstice altars at Hano is in the fact that they
are made by Tewa priests whose ancestors came to Tusayan about the beginning of the
eighteenth century. The makers claim that their forefathers brought a knowledge of them
from Tcewadi, in the upper valley of the Rio Grande in New Mexico, and that their
relatives in the Tewa pueblos in the east still use like altars in their celebration at the
Tûñtai.
Nothing, so far as known, has yet been published on the Tûñtai altars of the eastern
Tanoan people, but ethnographers may yet find in the kivas of those villages material
which will render the above descriptions of comparative interest. The resemblance of the
Tûñtai altars to that of the Patki and related families in the Walpi Moñkiva at the Winter
Solstice, is a very distant one. Both have snake effigies, but there is practically little else
in common between them, or with the altar erected at the same time by the Pakab
people in the Tcivatokiva. The Tûñtai altars are characteristically Tewan, and, while
homologous with each other, are different from any yet known from the Hopi pueblos.
The purport of the Tûñtai rites at Hano seems to be similar to that of the Hopi Soyaluña,
namely, to draw back the sun in its southern declination, and to fertilize the corn and
other seeds and increase all worldly possessions. As at Walpi, strings with attached
feathers are made and given to men and women with wishes that the gods may bring
them blessings. These strings are also attached to beams of houses, placed in springs of
water, tied to the tails of horses, burros, sheep, dogs, chickens, and indeed every
possession which the Indian has and wishes to increase. The presence of the idol of the
snake means snake worship.
The survival of the Tanoan Tûñtai altars at Hano is typical of the way in which the
Tusayan ritual has grown to its present complicated form. They are instances of an
intrusive element which has not yet been amalgamated, as the knowledge of them is still
limited to unassimilated people and clans.
Similar conditions have existed from time to time during the history of the Hopi, when
new clans were added to those already existing. For many years incoming clans
maintained a strict taboo, and each family held the secrets of its own religion; but as
time went on and assimilation resulted by intermarriage, the religious society arose,
composed of men and women of different clans. The family to which a majority of the
membership belonged continued to hold the chieftaincy, and owned the altar and its
paraphernalia, cherishing the legends of the society. But when men of other clans were
admitted to membership, a mutual reaction of one society on another naturally resulted.
This tended to modifications which have obscured the original character of distinctive
family worship.
The problem of the Hopi ritual, by which is meant the sum of all great ceremonies in the
Hopi calendar, deals largely with a composite system. It implies, as elsewhere pointed
out, an investigation of the characteristic religious observances of several large families
which formerly lived apart in different pueblos. It necessitates a knowledge of the social
composition of Walpi and of the history of the different phratries which make up the
population of the village.
There is a corollary to the above conclusions. No pueblo in the southwest, outside of
Tusayan, has the same ceremonial calendar as Walpi, because the population of none is
made up of the same clans united in the same relative proportions. Hence the old remark
that what is true of one pueblo is true of all, does not apply to their ritual. Some
ceremonies at Jemez, Acoma, Sia, and Zuñi, for instance, are like some ceremonies at
Walpi; but the old ceremonial calendar in any one of these pueblos was different from
that of the other, because the component families were not the same. In the same way
the ceremonies at Hano and Walpi have certain things in common, due no doubt to the
assimilation in the latter of certain Tanoan clans, but their calendars are very different.
The Tûñtai at Hano differs more widely from the Winter Solstice ceremony at Walpi, a
gunshot away, than the Walpi observance differs from that at Oraibi, twenty miles
distant. So we might also predict that if we knew the character of Winter Solstice altars in
the Rio Grande Tewa villages, they would be found to resemble those of Hano more
closely than the altars of Hano resemble those of Walpi.

The Knickerbocker Press, New York


FOOTNOTES:
[1] The Winter Solstice Ceremony at Walpi (American Anthropologist, vol. XI).
[2] These studies were made under the auspices of the Bureau of American
Ethnology.
[3] Most of the people of Sitcomovi are of the Asa and Honani clans, of Tanoan
ancestry, but they long ago lost the Tewa language and their Tanoan identity.
[4] The site of this last settlement of the Patki people, before they joined those of
Walpi, is in the plain about four miles south of the East Mesa. The ruins of the pueblo
are still visible, and the foundation walls can readily be traced.
[5] The Hano names of these pueblos are—San Juan, ——; Santa Clara, Kap'a; San
Ildefonso, Pocuñwe; Pojoaque, P'okwode; Nambe, Nûme; Tesuque, Tetsogi. They also
claim Taos (Tawile) and Picuris (Ohke), but say that another speech is mixed with
theirs in these pueblos.
[6] The Tewa of Hano call the Hopi Koso, and the Hopi speak of the Hano people as
the Towa or the Hanum-nyûmû. The word "Moki," so constantly used by white people
to designate the Hopi, is never applied by the Hopi to themselves, and they strongly
object to it. The dead are said to be moki, which enters into the formation of verbs,
as tconmoki, to starve; tcinmoki, to be very lonesome, etc. The name Hano or Hanoki
is, I believe, simply a combination of the words Hano and ki, "eastern pueblo." The
element hano appears also in the designation for American, Pahano, "eastern water";
pahanoki, "American house." Both the Asa and the Tewa peoples are called Hanum
clans.
[7] Remains of old reservoirs, elaborately walled, from which water was drawn by
means of a gourd tied to a long pole, are still pointed out near Tukinovi and are said
to have belonged to the Pe-towa. Old Tcasra claims that they were in use in his
mother's grandmother's time.
[8] The troubles following the great rebellion of 1680 drove many Tewa from the Rio
Grande valley to Tusayan.
[9] It is impossible to make this enumeration accurate, hence these numbers must be
regarded as approximations.
[10] It is not unusual to find several names applied to the same person. Thus, Hani,
the chief of the Piba clans at Walpi, is called Lesma in the Snake kiva. The Walpi call
the author Nakwipi, but the Flute chief at Cipaulovi insists that his name is
Yoyowaiamû, which appellation was given when the author was inducted into the
Flute rites at that pueblo in 1891.
[11] The gap in the East Mesa just at the head of the trail before one enters Hano.
The pueblo of Walpi derived its name from this gap.
[12] Their nomadic enemies raided so near the pueblo of the East Mesa that the
priests were unable to visit their shrines without danger. The idol of Talatumsi, used in
the New-fire ceremony, was removed from its shrine north of Wala on that account.
[13] Later, as the outcome of a petty quarrel near the middle of the eighteenth
century, the Asa women moved to Sitcomovi which they founded. At present there is
only one woman of this clan in Walpi, and no women of the Honani, both of which
clans are strong in Sitcomovi.
[14] Ten Broeck in 1852 seems to have been the first writer to adopt the true name,
Hano, of the Tewa pueblo on the East Mesa.
[15] One of the differences in custom between Hopi and Tewa women is the method
of making their coiffures. Unmarried girls of Walpi and Hano dress their hair in the
same manner, with whorls above the ears. Married women have different ways of
wearing their hair in the two pueblos. During the wedding ceremonies at Hano the
mother of the bride, in the presence of guests, combs her daughter's hair, or that part
of it on the front of the scalp, over the face, so that it hangs down like a veil. She ties
the hair on the back of the head in two coils, one of which hangs on either side, but
the hair before the face she cuts on a level with the chin, beginning at the top of the
ears. The hair which remains is too short to be done up in coils, and is simply brushed
to one side or the other. Among Hopi married women all the hair is included in the
two coils, and the "bang" is absent.
[16] The names of many Tewa women end in pobi, corresponding with the Hopi si, a
contracted form of sihû, in women's names, as Hoñsi, Nasiumsi, etc.
[17] Among the Hopi the moon (Tewa p'o) is called müiyaûh; new moon, müiyakatci;
first quarter, müiyachaunacapti; full moon, müiyanacapti. An eclipse of the moon is
spoken of as müiyaûh moki, "dead moon." There was a total eclipse of the moon
visible at Walpi near the end of December, 1898, when the full moon arose partially
obscured. This, said Sikyatala, was bad for the Americans who dwell in the far east,
but not for the Hopi. A "dead moon," when in the meridian of the Hopi pueblos, is
considered kalolamai, "bad."
[18] The Winter Solstice Ceremony at Walpi, op. cit.
[19] The Asa people are also called the Tcakwaina clans. The ruins of their old village,
near the western point of Awatobi mesa, are called Tcakwaina-ki. Its walls do not
appear above the surface.
[20] The particular ceremony of the Pakab peoples is the Momtcita, a single day's rite
which occurs just after the Soyaluña, under direction of Pautiwa. Connected with this
ceremony are the performances of the "stick swallowers" or Nocoto priests who were
thought to be extinct at Walpi, but Eewa is chief of the Nocotana priests, and the
society includes Wikyatiwa, Talahoya, Sikyaventima, and others. They still practice
stick-swallowing. Pautiwa is chief of the Kalektaka, a warrior priesthood. He belongs
to the Eagle clan of the Pakab phratry, which may be related to the Awata or Bow
clan of the former pueblo of Awatobi.
[21] Tcoshoniwa is generally called by a nickname, Tcino, "Bald-head," or "Curly-hair,"
a sobriquet to which he strongly objects. He is one of the oldest men of Sitcomovi,
belongs to the Patki clan, and was formerly the kimoñwi or governor of Sitcomovi.
Hani, of the Piba (Tobacco) clan, is political chief of Walpi; and Anote, also of the Piba
clan, is chief of Hano. All the pueblos have kimoñwis or governors, and the office
dates from early times; but these pueblo chiefs have no authority over pueblos other
than their own.
[22] The orientation of the Hano kivas is not far from that of the other East Mesa
kivas, or about north 44º west.
[23] The chief kiva had a small stove, an innovation which was greatly appreciated by
the writer.
[24] So named by the Hopi; the Tewa call him Tem[)e], At Hano almost everyone has
a Hopi and a Tewa name.
[25] Son of Kutcve and Kotcampa of the Kolon-towa, or Corn clan; commonly called
"Esquash" by Americans.
[26] The corn-husk packet of meal seems to be wanting in Zuñian, Keresan, and
Tanoan prayer-sticks, but it is almost universally present in those of the Hopi. The
Tanoan prayer-stick is called o'dope.
[27] A cephalic horn is an essential organ of the Great Snake, and is always
represented in pictography and on graven or other images of this being. Note the
similarity of his Tewa name to the Spanish word abajo, "below."
[28] This is the first time songs have been noted while an altar was being put in
place.
[29] This was a four-stranded string of cotton, as long as the outstretched arm,
measured from over the heart to the tip of the longest finger. It is supposed to be a
roadway of blessings, and the trail of meal is the pathway along which, in their belief,
the benign influences of the altar pass from it to the kiva entrance and to the pueblo.
[30] Pocine is a youth not far from seventeen years of age. His marriage ceremony
was studied by the writer a week before the Tûñtai.
[31] The triangle among the Hopi is almost as common a symbol of the rain-cloud as
the semicircle. It is a very old symbol, and is frequently found with the same meaning
in cliff-houses and in ancient pictography.
[32] It was found in studying the four lightning symbols on this Tewa altar that sex is
associated with cardinal points as in the Walpi Antelope altar. The lightning of the
north is male, that of the west female, the south male, and the east female. The
same holds with many objects in Hopi altars; thus the stone objects, tcamahia, of the
Antelope altar follow this rule. In the same way plants and herbs have sex (not in the
Linnean meaning), and are likewise associated with the cardinal points.
[33] This sprinkling of corn seeds upon the meal picture of a Hopi altar is mentioned
in an account of the Oraibi Flute ceremony. The evident purpose of this act is to
vitalize the seeds by the accompanying rites about the altar.
[34] Called omowûh-saka, "rain-cloud ladders."
[35] Smithsonian Report, 1895, pl. lvii.
[36] The American Anthropologist, vol. XI, page 1.
[37] The Tewa, like the Hopi, recognize six ceremonial directions—north, west, south,
east, above, and below. The sinistral circuit is one in which the center is on the left
hand, while the dextral circuit has its center to the right. The older term, "sunwise,"
for the latter circuit, etymologically means one ceremonial circuit in the northern
hemisphere and an opposite in the southern. On this and other accounts the author
has ceased to use it in designating circuits.
[38] For the increase of rabbits.
[39] This zigzag framework had appended to one end a carved imitation of a snake's
head, and as it represents the lightning this association was not incongruous. Similar
frameworks are carried in the dance by a man impersonating Püükoñ, the War god,
and at certain other times when lightning is symbolized.
[40] In asking why albino Hopi are found at the Middle Mesa and not on the East
Mesa, it was unexpectedly learned that in some ceremonies a white prayer-stick is
made at the former mesa, and that albinism was due to want of care by the father in
making these offerings while his wife was pregnant. The author has never seen the
white paho of the Middle Mesa, and does not know when it is made nor its shape and
use.
[41] All Hopi priests are very solicitous that sketches of the Patki altar in the Soyaluña
should not be shown to Tewa men or women, and the Tewa men begged me to keep
silent regarding their altars while conversing with the Walpi chiefs. There is a very
strict taboo between the two peoples at the time of the Winter Solstice ceremony,
which is more rigid than at other times.
[42] The Tuwa (Sand) or Kükütce (Lizard) clan lived at Pakatcomo with the Patki
people, according to their legends.
[43] Journal of American Folk-lore, 1892, pl. II, figs. 1-4. These moñkohus of the
Kwakwantu society, representing horned snakes, should not be confounded with
those carried by other societies, typical forms of which are shown in figures 5-8. In
the article quoted it was not stated that the effigies with heads represent Palülükoñs.
The effigy on the massive club borne by the chief of the Kwakwantu also represents
the Great Snake.

Transcriber's Note:

Hyphenation for the most part has been standardised.


Reference to the scale on caption to Plate XX should be ignored.
*** END OF THE PROJECT GUTENBERG EBOOK THE WINTER
SOLSTICE ALTARS AT HANO PUEBLO ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like