alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Group.scala)

This example Scala source code file (Group.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

any, equality, equality, group, group, node, seq, string, string, stringbuilder, stringbuilder, unsupportedoperationexception

The Scala Group.scala source code

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */


package scala.xml

/** A hack to group XML nodes in one node for output.
 *
 *  @author  Burak Emir
 *  @version 1.0
 */
final case class Group(val nodes: Seq[Node]) extends Node {
  override def theSeq = nodes
  
  override def canEqual(other: Any) = other match {
    case x: Group => true
    case _        => false
  }
  override def strict_==(other: Equality) = other match {
    case Group(xs)  => nodes sameElements xs
    case _          => false
  }
  override def basisForHashCode = nodes
  
  /** Since Group is very much a hack it throws an exception if you
   *  try to do anything with it.
   */
  private def fail(msg: String) = throw new UnsupportedOperationException("class Group does not support method '%s'" format msg)
  
  def label                           = fail("label")
  override def attributes             = fail("attributes")
  override def namespace              = fail("namespace")
  override def child                  = fail("child")
  def buildString(sb: StringBuilder)  = fail("toString(StringBuilder)")
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala Group.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.